Initial revision

This commit is contained in:
Felix Geyer 2004-01-31 20:56:22 +00:00
parent 88eadb34bc
commit 9e999a0ba6
106 changed files with 24019 additions and 0 deletions

278
amxmodx/CCmd.cpp Executable file
View File

@ -0,0 +1,278 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "CCmd.h"
// *****************************************************
// class CmdMngr
// *****************************************************
CmdMngr::CmdMngr() {
memset(sortedlists,0,sizeof(sortedlists));
srvcmdlist = 0;
clcmdlist = 0;
prefixHead = 0;
buf_type = -1;
buf_access = 0;
buf_id = -1;
buf_cmdid = -1;
buf_cmdtype = -1;
buf_cmdaccess = 0;
}
CmdMngr::Command::Command( CPluginMngr::CPlugin* pplugin,const char* pcmd,
const char* pinfo , int pflags , int pfunc,
bool pviewable, CmdMngr* pparent ) : commandline(pcmd) , info(pinfo) {
char szCmd[64], szArg[64];
*szCmd = 0; *szArg=0;
sscanf(pcmd,"%s %s",szCmd,szArg);
command.set(szCmd);
argument.set(szArg);
plugin = pplugin;
flags = pflags;
cmdtype = 0;
prefix = 0;
function = pfunc;
listable = pviewable;
parent = pparent;
id = --uniqueid;
}
CmdMngr::Command::~Command()
{
++uniqueid;
}
CmdMngr::Command* CmdMngr::registerCommand( CPluginMngr::CPlugin* plugin , int func , char* cmd , char* info , int level , bool listable )
{
Command* b = new Command( plugin , cmd , info , level , func , listable, this );
if ( b == 0 ) return 0;
setCmdLink( &sortedlists[0] , b );
return b;
}
CmdMngr::Command* CmdMngr::getCmd( long int id ,int type, int access )
{
//if ( id >= 1024 || id < 0 ) return (Command*)id;
if ( id < 0 ){
for (CmdMngr::iterator a = begin( type ); a ; ++a){
if ( (*a).id == id )
return &(*a);
}
return 0;
}
if ( (id < buf_cmdid) || (access != buf_cmdaccess) || (type != buf_cmdtype) )
{
buf_cmdptr = begin( type );
buf_cmdaccess = access;
buf_cmdtype = type;
buf_cmdid = id;
}
else
{
int a = id;
id -= buf_cmdid;
buf_cmdid = a;
}
while ( buf_cmdptr )
{
if ( (*buf_cmdptr).gotAccess( access ) &&
(*buf_cmdptr).getPlugin()->isExecutable( (*buf_cmdptr).getFunction() )
&& (*buf_cmdptr).isViewable() )
{
if ( id-- == 0 )
return &(*buf_cmdptr);
}
++buf_cmdptr;
}
return 0;
}
int CmdMngr::getCmdNum( int type, int access )
{
if ( (access == buf_access) && (type == buf_type) )
return buf_num; // once calculated don't have to be done again
buf_access = access;
buf_type = type;
buf_num = 0;
CmdMngr::iterator a = begin( type );
while ( a )
{
if ( (*a).gotAccess( access ) &&
(*a).getPlugin()->isExecutable( (*a).getFunction() )
&& (*a).isViewable() )
++buf_num;
++a;
}
return buf_num;
}
void CmdMngr::setCmdLink( CmdLink** a , Command* c, bool sorted )
{
CmdLink* np = new CmdLink( c );
if ( np == 0 ) return;
if ( sorted )
{
while( *a )
{
int i = strcmp(c->getCommand(),(*a)->cmd->getCommand() );
if ( (i<0) || (i==0) && ( strcmp( c->getArgument() , (*a)->cmd->getArgument() ) < 0 ) )
break;
a = &(*a)->next;
}
np->next = *a;
*a = np;
}
else
{
while ( *a ) a = &(*a)->next;
*a = np;
}
}
void CmdMngr::clearCmdLink( CmdLink** phead, bool pclear )
{
while( *phead ){
CmdLink* pp = (*phead)->next;
if ( pclear ) delete (*phead)->cmd;
delete *phead;
*phead = pp;
}
}
void CmdMngr::Command::setCmdType( int a )
{
switch(a){
case CMD_ConsoleCommand: cmdtype |= 3; break;
case CMD_ClientCommand: cmdtype |= 1; break;
case CMD_ServerCommand: cmdtype |= 2; break;
}
if ( cmdtype & 1 ) { // ClientCommand
parent->setCmdLink( &parent->sortedlists[1] , this );
if ( !parent->registerCmdPrefix( this ) )
parent->setCmdLink( &parent->clcmdlist , this , false );
}
if ( cmdtype & 2 ) { // ServerCommand
parent->setCmdLink( &parent->sortedlists[2] , this );
parent->setCmdLink( &parent->srvcmdlist , this , false );
}
}
const char* CmdMngr::Command::getCmdType() const {
switch( cmdtype ){
case 1: return"client";
case 2: return "server";
case 3: return "console";
}
return "unknown";
}
bool CmdMngr::registerCmdPrefix( Command* cc )
{
CmdPrefix** b = findPrefix( cc->getCommand() );
if (*b){
setCmdLink( &(*b)->list , cc , false );
cc->prefix = (*b)->name.size();
return true;
}
return false;
}
void CmdMngr::registerPrefix( const char* nn )
{
if ( *nn == 0 ) return;
CmdPrefix** b = findPrefix( nn );
if (*b) return;
*b = new CmdPrefix( nn , this );
}
CmdMngr::CmdPrefix** CmdMngr::findPrefix( const char* nn ){
CmdPrefix** aa = &prefixHead;
while(*aa){
if ( !strncmp( (*aa)->name.str(), nn, (*aa)->name.size() ) )
break;
aa=&(*aa)->next;
}
return aa;
}
void CmdMngr::clearPrefix(){
while(prefixHead){
CmdPrefix* a = prefixHead->next;
delete prefixHead;
prefixHead = a;
}
}
void CmdMngr::clear()
{
clearCmdLink(&sortedlists[0], true);
clearCmdLink(&sortedlists[1]);
clearCmdLink(&sortedlists[2]);
clearCmdLink(&srvcmdlist);
clearCmdLink(&clcmdlist);
clearPrefix();
clearBufforedInfo();
}
void CmdMngr::clearBufforedInfo() {
buf_type = -1;
buf_access = 0;
buf_id = -1;
buf_cmdid = -1;
buf_cmdtype = -1;
buf_cmdaccess = 0;
}
int CmdMngr::Command::uniqueid = 0;

165
amxmodx/CCmd.h Executable file
View File

@ -0,0 +1,165 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef COMMANDS_H
#define COMMANDS_H
// *****************************************************
// class CmdMngr
// *****************************************************
enum {
CMD_ConsoleCommand,
CMD_ClientCommand,
CMD_ServerCommand
};
class CmdMngr
{
public:
class Command;
friend class Command;
class Command {
friend class CmdMngr;
CPluginMngr::CPlugin* plugin;
CmdMngr* parent;
String command;
String argument;
String commandline;
String info;
bool listable;
int function;
int flags;
int id;
int cmdtype;
int prefix;
static int uniqueid;
Command( CPluginMngr::CPlugin* pplugin,const char* pcmd, const char* pinfo , int pflags , int pfunc, bool pviewable, CmdMngr* pparent );
~Command();
public:
inline const char* getCommand() const{ return command.str(); }
inline const char* getArgument() const{ return argument.str(); }
inline const char* getCmdInfo() const{ return info.str(); }
inline const char* getCmdLine() const{ return commandline.str(); }
inline bool matchCommandLine(const char* cmd, const char* arg) { return (!stricmp(command.str()+prefix, cmd+prefix ) && (argument.empty() || !stricmp(argument.str() , arg ))); }
inline bool matchCommand(const char* cmd) { return (!strcmp(command.str(), cmd )); }
inline int getFunction() const { return function; }
inline bool gotAccess(int f) const { return (!flags||((flags & f)==flags)); }
inline CPluginMngr::CPlugin* getPlugin() { return plugin; }
inline bool isViewable() const { return listable; }
inline int getFlags() const { return flags; }
inline long int getId() const { return (long int)id; }
const char* getCmdType() const;
void setCmdType( int a );
};
private:
struct CmdPrefix;
friend struct CmdPrefix;
struct CmdLink {
Command* cmd;
CmdLink* next;
CmdLink(Command* c): cmd(c), next(0) {}
};
CmdLink* sortedlists[3];
CmdLink* srvcmdlist;
CmdLink* clcmdlist;
struct CmdPrefix {
CmdMngr* parent;
String name;
CmdLink* list;
CmdPrefix* next;
CmdPrefix( const char* nn , CmdMngr* pp) : name(nn),parent(pp),list(0),next(0){}
~CmdPrefix(){ parent->clearCmdLink(&list); }
} *prefixHead;
bool registerCmdPrefix( Command* cc );
CmdPrefix** findPrefix( const char* nn );
void clearPrefix();
void setCmdLink( CmdLink** a , Command* c, bool sorted = true );
void clearCmdLink( CmdLink** phead, bool pclear = false );
public:
CmdMngr();
~CmdMngr() {clear();}
// Interface
void registerPrefix( const char* nn );
Command* registerCommand( CPluginMngr::CPlugin* plugin , int func , char* cmd , char* info , int level , bool listable );
Command* getCmd( long int id ,int type, int access);
int getCmdNum( int type, int access );
void clearBufforedInfo();
void clear();
class iterator {
CmdLink *a;
public:
iterator(CmdLink*aa = 0) : a(aa) {}
iterator& operator++() { a = a->next; return *this; }
bool operator==(const iterator& b) const { return a == b.a; }
bool operator!=(const iterator& b) const { return !operator==(b); }
operator bool () const { return a ? true : false; }
Command& operator*() { return *a->cmd; }
};
inline iterator clcmdprefixbegin(const char* nn){
CmdPrefix* a = *findPrefix(nn);
return iterator( a ? a->list : 0 );
}
inline iterator clcmdbegin() const {return iterator(clcmdlist);}
inline iterator srvcmdbegin() const {return iterator(srvcmdlist);}
inline iterator begin( int type ) const { return iterator(sortedlists[type]); }
inline iterator end() const { return iterator(0); }
private:
int buf_cmdid;
int buf_cmdtype;
int buf_cmdaccess;
iterator buf_cmdptr;
int buf_id;
int buf_type;
int buf_access;
int buf_num;
};
#endif

337
amxmodx/CEvent.cpp Executable file
View File

@ -0,0 +1,337 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "CEvent.h"
// *****************************************************
// class EventsMngr
// *****************************************************
EventsMngr::EventsMngr()
{
memset( modMsgsFunCall, 0 , sizeof(modMsgsFunCall) );
}
EventsMngr::~EventsMngr()
{
clearEvents();
}
EventsMngr::ClEvent::ClEvent( CPluginMngr::CPlugin* amxplugin, int function, int flags )
{
plugin = amxplugin;
func = function;
stamp = 0.0;
next = 0;
done = false;
alive=true;
dead=true;
if ( flags & 24 ){
alive=(flags&16)?true:false; //e
dead=(flags&8)?true:false; //d
}
world=(flags&1)?true:false; //a
player=(flags&2)?true:false; //b
once=(flags&4)?true:false; //c
memset(cond,0,sizeof(cond));
}
void EventsMngr::ClEvent::registerFilter( char* filter )
{
if ( filter == 0 ) return;
char* value = filter;
while ( isdigit(*value) )
++value;
if ( *value == 0 ) return;
cond_t* b = new cond_t;
if ( b == 0 ) return;
b->type = *value;
*value++ = 0;
b->sValue.set(value);
b->fValue = atof(value);
b->iValue = atoi(value);
int i = atoi(filter);
if (i >= 0 && i < MAX_PARSE_VALUES) {
b->next = cond[i];
cond[i] = b;
}
else delete b;
}
EventsMngr::ClEvent* EventsMngr::registerEvent( CPluginMngr::CPlugin* p, int f, int flags, int pos )
{
ClEvent* a = new ClEvent( p , f , flags );
if ( a == 0 ) return 0;
ClEvent** end = &modMsgsFunCall[pos];
while( *end ) end = &(*end)->next;
return *end = a;
}
void EventsMngr::parserInit(int msg_type, float* tim, CPlayer *pPlayer, int index) {
parseNotDone = false;
timer = tim;
if ( (parseFun = modMsgsFunCall[msg_type]) == 0 ) return;
for(EventsMngr::ClEvent*p=parseFun;p;p=p->next){
if ( p->done ) continue;
if ( !p->plugin->isExecutable(p->func) ){
p->done = true;
continue;
}
if ( pPlayer ) {
if ( !p->player || ( pPlayer->IsAlive() ? !p->alive : !p->dead ) ) {
p->done = true;
continue;
}
}
else if ( !p->world ){
p->done = true;
continue;
}
if ( p->once && p->stamp == (float)(*timer) ){
p->done = true;
continue;
}
parseNotDone = true;
}
if ( parseNotDone ) {
parseVault[parsePos = 0].type = MSG_INTEGER;
parseVault[parsePos].iValue = index;
}
}
const char* EventsMngr::getArgString(int a)
{
if ( a < 0 || a > parsePos ) return "";
static char var[32];
switch(parseVault[a].type){
case MSG_INTEGER:
sprintf( var, "%d", parseVault[a].iValue );
return var;
case MSG_STRING:
return parseVault[a].sValue;
default:
sprintf( var, "%g", parseVault[a].fValue );
return var;
}
}
int EventsMngr::getArgInteger(int a)
{
if ( a < 0 || a > parsePos ) return 0;
switch(parseVault[a].type){
case MSG_INTEGER: return parseVault[a].iValue;
case MSG_STRING: return atoi(parseVault[a].sValue);
default: return (int)parseVault[a].fValue;
}
}
float EventsMngr::getArgFloat(int a)
{
if ( a < 0 || a > parsePos ) return 0.0f;
switch(parseVault[a].type){
case MSG_INTEGER: return parseVault[a].iValue;
case MSG_STRING: return atof(parseVault[a].sValue);
default: return parseVault[a].fValue;
}
}
void EventsMngr::executeEvents() {
int err;
#ifdef ENABLEEXEPTIONS
try
{
#endif
for ( ClEvent*p = parseFun ; p ; p = p->next )
{
if ( p->done )
{
p->done = false;
continue;
}
p->stamp = *timer;
if ((err = amx_Exec(p->plugin->getAMX(), NULL , p->func , 1,parseVault[0].iValue)) != AMX_ERR_NONE)
print_srvconsole("[AMX] Run time error %d on line %ld (plugin \"%s\")\n",err,p->plugin->getAMX()->curline,p->plugin->getName());
}
#ifdef ENABLEEXEPTIONS
}
catch( ... )
{
print_srvconsole( "[AMX] fatal error at event execution\n");
}
#endif
}
void EventsMngr::parseValue(int iValue) {
if ( !parseNotDone ) return;
parseVault[++parsePos].type = MSG_INTEGER;
parseVault[parsePos].iValue = iValue;
bool skip;
for (ClEvent*p=parseFun;p;p=p->next){
if ( p->done || !p->cond[parsePos] ) continue;
skip = false;
ClEvent::cond_t* a = p->cond[parsePos];
do {
switch(a->type){
case '=': if (a->iValue == iValue) skip=true; break;
case '!': if (a->iValue != iValue) skip=true; break;
case '&': if (iValue & a->iValue) skip=true; break;
case '<': if (iValue < a->iValue) skip=true; break;
case '>': if (iValue > a->iValue) skip=true; break;
}
if (skip) break;
} while ( a = a->next );
if (skip) continue;
p->done = true;
}
}
void EventsMngr::parseValue(float flValue) {
if ( !parseNotDone ) return;
parseVault[++parsePos].type = MSG_FLOAT;
parseVault[parsePos].fValue = flValue;
bool skip;
for (ClEvent*p=parseFun;p;p=p->next){
if ( p->done || !p->cond[parsePos] ) continue;
skip = false;
ClEvent::cond_t* a = p->cond[parsePos];
do {
switch(a->type){
case '=': if (a->fValue == flValue) skip=true; break;
case '!': if (a->fValue != flValue) skip=true; break;
case '<': if (flValue < a->fValue) skip=true; break;
case '>': if (flValue > a->fValue) skip=true; break;
}
if (skip) break;
} while ( a = a->next );
if (skip) continue;
p->done = true;
}
}
void EventsMngr::parseValue(const char *sz) {
if ( !parseNotDone ) return;
parseVault[++parsePos].type = MSG_STRING;
parseVault[parsePos].sValue = sz;
bool skip;
for (ClEvent*p=parseFun;p;p=p->next){
if ( p->done || !p->cond[parsePos] ) continue;
skip = false;
ClEvent::cond_t* a = p->cond[parsePos];
do {
switch(a->type){
case '=': if (!strcmp(sz,a->sValue.str())) skip=true; break;
case '!': if (strcmp(sz,a->sValue.str())) skip=true; break;
case '&': if (strstr(sz,a->sValue.str())) skip=true; break;
}
if (skip) break;
} while ( a = a->next );
if (skip) continue;
p->done = true;
}
}
void EventsMngr::clearEvents()
{
for(int i=0;i<MAX_AMX_REG_MSG;++i){
ClEvent**b = &modMsgsFunCall[i];
while (*b){
ClEvent*aa = (*b)->next;
delete *b;
*b = aa;
}
}
}
EventsMngr::ClEvent::~ClEvent(){
for(int a = 0; a < MAX_PARSE_VALUES; ++a){
cond_t** b = &cond[a];
while(*b){
cond_t* nn = (*b)->next;
delete *b;
*b = nn;
}
}
}
EventsMngr::ClEvent* EventsMngr::getValidEvent(ClEvent* a ) {
while(a){
if ( a->done ) {
a->done = false;
a = a->next;
continue;
}
a->stamp = *timer;
return a;
}
return 0;
}
int EventsMngr::getEventId( const char* msg ){
struct CS_Events {
const char* name;
CS_EventsIds id;
} table[] = {
{ "CS_DeathMsg" , CS_DeathMsg },
// { "CS_RoundEnd" , CS_RoundEnd },
// { "CS_RoundStart" , CS_RoundStart },
// { "CS_Restart" , CS_Restart },
{ "" , CS_Null }
};
int pos;
if ( (pos = atoi( msg )) != 0 )
return pos;
for (pos = 0; table[ pos ].id != CS_Null; ++pos )
if ( !strcmp( table[ pos ].name , msg ) )
return table[ pos ].id;
return pos = GET_USER_MSG_ID(PLID, msg , 0 );
}

154
amxmodx/CEvent.h Executable file
View File

@ -0,0 +1,154 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef EVENTS_H
#define EVENTS_H
#define MAX_PARSE_VALUES 32
#define MAX_AMX_REG_MSG MAX_REG_MSGS+16
enum {
CS_DEATHMSG = MAX_REG_MSGS,
// CS_ROUNDEND,
// CS_ROUNDSTART,
// CS_RESTART,
};
// *****************************************************
// class EventsMngr
// *****************************************************
class EventsMngr {
enum MsgValueType{
MSG_INTEGER,
MSG_FLOAT,
MSG_STRING,
};
public:
enum CS_EventsIds {
CS_Null = 0,
CS_DeathMsg = MAX_REG_MSGS, // start from last element
// CS_RoundEnd,
// CS_RoundStart,
// CS_Restart,
};
class iterator;
friend class iterator;
class ClEvent {
friend class EventsMngr;
friend class iterator;
CPluginMngr::CPlugin* plugin;
int func;
bool player;
bool world;
bool once;
bool done;
bool dead;
bool alive;
float stamp;
struct cond_t {
String sValue;
float fValue;
int iValue;
int type;
cond_t* next;
} *cond[MAX_PARSE_VALUES];
ClEvent* next;
ClEvent( CPluginMngr::CPlugin* p, int f, int flags );
~ClEvent();
public:
inline CPluginMngr::CPlugin* getPlugin() { return plugin; }
inline int getFunction() { return func; }
void registerFilter( char* filter );
};
private:
struct MsgDataVault {
float fValue;
int iValue;
const char* sValue;
MsgValueType type;
} parseVault[MAX_PARSE_VALUES];
ClEvent* modMsgsFunCall[MAX_AMX_REG_MSG];
ClEvent* parseFun;
bool parseNotDone;
int parsePos; // is -1 less then args. num.
float* timer;
ClEvent* getValidEvent(ClEvent* a );
public:
EventsMngr();
~EventsMngr();
// Interface
ClEvent* registerEvent( CPluginMngr::CPlugin* p, int f, int flags, int pos );
void parserInit(int msg_type, float* timer , CPlayer* target = 0, int index = 0);
void parseValue(int iValue);
void parseValue(float fValue);
void parseValue(const char *sz);
void executeEvents();
inline int getArgNum() { return (parsePos+1); }
const char* getArgString(int a);
int getArgInteger(int a);
float getArgFloat(int a);
void clearEvents(void);
static int getEventId( const char* msg );
class iterator {
EventsMngr* b;
ClEvent* a;
public:
inline iterator(ClEvent*aa,EventsMngr* bb) : a(aa), b(bb) {}
inline iterator& operator++() {
a = b->getValidEvent( a->next );
return *this;
}
inline bool operator==(const iterator& c) const { return a == c.a; }
inline bool operator!=(const iterator& c) const { return !operator==(c); }
ClEvent& operator*() { return *a; }
operator bool ( ) const { return a ? true : false; }
};
inline iterator begin() { return iterator(getValidEvent(parseFun),this); }
inline iterator end() { return iterator(0,this); }
};
#endif

115
amxmodx/CFile.cpp Executable file
View File

@ -0,0 +1,115 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "CFile.h"
#include <ctype.h>
// *****************************************************
// class File
// *****************************************************
File::File( const char* n, const char* m )
{
fp = fopen( n , m );
}
File::~File( )
{
if ( fp )
fclose( fp );
}
File::operator bool ( ) const
{
return fp && !feof(fp);
}
File& operator<<( File& f, const String& n )
{
if ( f ) fputs( n.str() , f.fp ) ;
return f;
}
File& operator<<( File& f, const char* n )
{
if ( f ) fputs( n , f.fp ) ;
return f;
}
File& operator<<( File& f, int n )
{
if ( f ) fprintf( f.fp , "%d" , n ) ;
return f;
}
File& operator<<( File& f, const char& c )
{
if ( f ) fputc( c , f.fp ) ;
return f;
}
File& operator>>( File& f, String& n )
{
if ( !f ) return f;
char temp[1024];
fscanf( f.fp , "%s", temp );
n.set(temp);
return f;
}
File& operator>>( File& f, char* n )
{
if ( f ) fscanf( f.fp , "%s", n );
return f;
}
int File::getline( char* buf, int sz )
{
int a = sz;
if ( *this )
{
int c;
while ( sz-- && (c = getc( (*this).fp)) && c != EOF && c != '\n' )
*buf++ = c;
*buf = 0;
}
return a - sz;
}
File& File::skipWs( )
{
if ( !*this ) return *this;
int c;
while( isspace( c = getc( fp ) ) ){};
ungetc( c , fp );
return *this;
}

58
amxmodx/CFile.h Executable file
View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "CString.h"
#include <stdio.h>
// *****************************************************
// class File
// *****************************************************
class File
{
FILE* fp;
public:
File( const char* n, const char* m );
~File( );
operator bool ( ) const;
friend File& operator<<( File& f, const String& n );
friend File& operator<<( File& f, const char* n );
friend File& operator<<( File& f, const char& c );
friend File& operator<<( File& f, int n );
friend File& operator>>( File& f, String& n );
friend File& operator>>( File& f, char* n );
int getline( char* buf, int sz );
File& skipWs( );
};

80
amxmodx/CForward.cpp Executable file
View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "CForward.h"
void CForwardMngr::registerForward( CPluginMngr::CPlugin* p, int func , int type ){
CForward** a = &head[ type ];
while(*a) a = &(*a)->next;
*a = new CForward( p , func );
}
void CForwardMngr::clearForwards( CForward** a ){
while( *a ) {
CForward* b = (*a)->next;
delete *a;
*a = b;
}
}
void CForwardMngr::clear()
{
for ( int a = 0; a < FORWARD_NUM; ++a )
clearForwards( &head[ a ] );
}
void CForwardMngr::executeForwards( int type , int num , int player ) {
cell ret = 0;
int err;
CForward* a = head[ type ];
while ( a )
{
if ( a->getPlugin()->isExecutable( a->getFunction() ) )
{
if ((err = amx_Exec(a->getPlugin()->getAMX(), &ret, a->getFunction() , num, player)) != AMX_ERR_NONE)
print_srvconsole("[AMX] Run time error %d on line %ld (plugin \"%s\")\n", err,a->getPlugin()->getAMX()->curline,a->getPlugin()->getName());
if ( ret )
break;
}
a = a->next;
}
}

115
amxmodx/CForward.h Executable file
View File

@ -0,0 +1,115 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef FORWARD_H
#define FORWARD_H
// *****************************************************
// class CmdMngr
// *****************************************************
#define FORWARD_NUM 12
enum {
FF_ClientCommand,
FF_ClientConnect,
FF_ClientDisconnect,
FF_ClientInfoChanged,
FF_ClientPutInServer,
FF_PluginInit,
FF_PluginCfg,
FF_PluginPrecache,
FF_PluginLog,
FF_PluginEnd,
FF_InconsistentFile,
FF_ClientAuthorized,
};
class CForwardMngr
{
public:
class iterator;
class CForward
{
friend class iterator;
friend class CForwardMngr;
CPluginMngr::CPlugin* plugin;
int function;
CForward* next;
CForward( CPluginMngr::CPlugin* p, int func ) : plugin(p) , function(func) {next=0;}
public:
inline CPluginMngr::CPlugin* getPlugin() { return plugin; }
inline int getFunction() { return function; }
};
private:
CForward *head[ FORWARD_NUM ];
void clearForwards( CForward** a );
public:
CForwardMngr() {memset( head, 0, sizeof(head));}
~CForwardMngr() { clear(); }
// Interface
void registerForward( CPluginMngr::CPlugin* p, int func , int type );
void executeForwards( int type , int num = 0, int player = 0 );
void clear();
class iterator {
CForward *a;
public:
iterator(CForward*aa) : a(aa) {}
iterator& operator++() { a = a->next; return *this; }
bool operator==(const iterator& b) const { return a == b.a; }
bool operator!=(const iterator& b) const { return !operator==(b); }
operator bool () const { return a ? true : false; }
CForward& operator*() { return *a; }
};
inline iterator begin( int type ) const { return iterator(head[(int)type]); }
inline iterator end() const { return iterator(0); }
inline bool forwardsExist( int type ) {return head[(int)type]?true:false;}
};
#endif

104
amxmodx/CList.h Executable file
View File

@ -0,0 +1,104 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef CLIST_H
#define CLIST_H
// *****************************************************
// class CList
// *****************************************************
template <typename T, typename F = char* >
class CList {
public:
class iterator;
class CListEle {
friend class CList<T,F>;
friend class iterator;
T* obj;
CListEle* next;
CListEle( T* a , CListEle* nn ) : obj(a) , next(nn) {}
public:
T& operator* () { return *obj; }
};
private:
CListEle *head;
public:
CList<T,F>() { head = 0; }
~CList<T,F>() { clear(); }
void clear() {
iterator a = begin();
while( a ) a.remove();
}
void put( T* a ) {
head = new CListEle( a , head );
}
class iterator {
CListEle** a;
public:
iterator(CListEle** i=0) : a(i){}
T& operator*() const { return *(*a)->obj;}
inline operator bool () const { return (a && *a); }
inline iterator& operator++() {
a = &(*a)->next;
return *this;
}
inline iterator operator++(int) {
iterator tmp(a);
a = &(*a)->next;
return tmp;
}
iterator& remove(){
CListEle* aa = (*a)->next;
delete (*a)->obj;
delete *a;
*a = aa;
return *this;
}
iterator& put( T* aa ){
*a = new CListEle( aa , *a );
return *this;
}
};
inline iterator begin() { return iterator(&head); }
iterator find( F a ){
iterator cc = begin();
while(cc){
if ( *cc == a )
break;
++cc;
}
return cc;
}
};
#endif

253
amxmodx/CLogEvent.cpp Executable file
View File

@ -0,0 +1,253 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "CLogEvent.h"
// *****************************************************
// class LogEventsMngr
// *****************************************************
LogEventsMngr::LogEventsMngr() {
logCurrent = logCounter = 0;
logcmplist = 0;
arelogevents = false;
memset( logevents, 0, sizeof(logevents) );
}
LogEventsMngr::~LogEventsMngr() {
clearLogEvents();
}
int LogEventsMngr::CLogCmp::compareCondition(const char* string){
if ( logid == parent->logCounter )
return result;
logid = parent->logCounter;
if ( in ) return result = strstr( string , text.str() ) ? 0 : 1;
return result = strcmp(string,text.str());
}
LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* filter){
char* temp = filter;
// expand "1=message"
while ( isdigit(*filter) )
++filter;
bool in = (*filter=='&');
*filter++ = 0;
int pos = atoi(temp);
if ( pos < 0 || pos >= MAX_LOGARGS) pos = 0;
CLogCmp* c = logcmplist;
while( c ) {
if ( (c->pos==pos) && (c->in==in) && !strcmp(c->text.str(), filter))
return c;
c = c->next;
}
return logcmplist = new CLogCmp( filter , in , pos , logcmplist,this );
}
void LogEventsMngr::CLogEvent::registerFilter( char* filter ){
CLogCmp *cmp = parent->registerCondition( filter );
if ( cmp == 0 ) return;
for(LogCond* c = filters; c ; c = c->next){
if ( c->argnum == cmp->pos ){
c->list = new LogCondEle( cmp , c->list );
return;
}
}
LogCondEle* aa = new LogCondEle( cmp , 0 );
if ( aa == 0 ) return;
filters = new LogCond( cmp->pos , aa , filters );
}
void LogEventsMngr::setLogString( char* frmt, va_list& vaptr ) {
++logCounter;
int len = vsnprintf (logString, 255 , frmt, vaptr );
if ( len == - 1) {
len = 255;
logString[len] = 0;
}
if ( len ) logString[--len] = 0;
logArgc = 0;
}
void LogEventsMngr::setLogString( char* frmt, ... ) {
++logCounter;
va_list logArgPtr;
va_start ( logArgPtr , frmt );
int len = vsnprintf(logString, 255 , frmt, logArgPtr );
if ( len == - 1) {
len = 255;
logString[len] = 0;
}
va_end ( logArgPtr );
if ( len ) logString[--len] = 0;
logArgc = 0;
}
void LogEventsMngr::parseLogString( ) {
register const char* b = logString;
register int a;
while( *b && logArgc < MAX_LOGARGS ){
a = 0;
if ( *b == '"' ) {
++b;
while ( *b && *b != '"' && a < 127 )
logArgs[logArgc][a++] = *b++;
logArgs[logArgc++][a] = 0;
if ( *b) b+=2; // thanks to double terminator
}
else if ( *b == '(' ) {
++b;
while ( *b && *b != ')' && a < 127 )
logArgs[logArgc][a++] = *b++;
logArgs[logArgc++][a] = 0;
if ( *b) b+=2;
}
else {
while ( *b && *b != '(' && *b != '"' && a < 127 )
logArgs[logArgc][a++] = *b++;
if ( *b ) --a;
logArgs[logArgc++][a] = 0;
}
}
}
LogEventsMngr::CLogEvent* LogEventsMngr::registerLogEvent( CPluginMngr::CPlugin* plugin, int func, int pos )
{
if ( pos < 1 || pos > MAX_LOGARGS)
return 0;
arelogevents = true;
CLogEvent** d = &logevents[pos];
while(*d) d = &(*d)->next;
return *d = new CLogEvent( plugin , func, this );
}
void LogEventsMngr::executeLogEvents()
{
int err;
bool valid;
for(CLogEvent* a = logevents[ logArgc ]; a ; a = a->next){
valid = true;
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next){
valid = false;
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){
valid = true;
break;
}
}
if (!valid) break;
}
#ifdef ENABLEEXEPTIONS
try
{
#endif
if (valid){
if ((err = amx_Exec(a->plugin->getAMX(), NULL , a->func , 0)) != AMX_ERR_NONE)
print_srvconsole("[AMX] Run time error %d on line %ld (plugin \"%s\")\n",
err,a->plugin->getAMX()->curline,a->plugin->getName());
}
#ifdef ENABLEEXEPTIONS
}
catch( ... )
{
print_srvconsole( "[AMX] fatal error at log forward function execution\n");
}
#endif
}
}
void LogEventsMngr::clearLogEvents(){
logCurrent = logCounter = 0;
arelogevents = false;
for(int i = 0; i < MAX_LOGARGS + 1; ++i){
CLogEvent **a = &logevents[i];
while(*a){
CLogEvent* bb = (*a)->next;
delete *a;
*a = bb;
}
}
clearConditions();
}
void LogEventsMngr::clearConditions() {
while (logcmplist){
CLogCmp* a = logcmplist->next;
delete logcmplist;
logcmplist = a;
}
}
LogEventsMngr::CLogEvent::LogCond::~LogCond() {
while( list ) {
LogCondEle* cc = list->next;
delete list;
list = cc;
}
}
LogEventsMngr::CLogEvent::~CLogEvent() {
while( filters ) {
LogCond* cc = filters->next;
delete filters;
filters = cc;
}
}
LogEventsMngr::CLogEvent *LogEventsMngr::getValidLogEvent( CLogEvent * a )
{
bool valid;
while(a){
valid = true;
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next){
valid = false;
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){
valid = true;
break;
}
}
if (!valid) break;
}
if (!valid){
a = a->next;
continue;
}
return a;
}
return 0;
}

166
amxmodx/CLogEvent.h Executable file
View File

@ -0,0 +1,166 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef LOGEVENTS_H
#define LOGEVENTS_H
#define MAX_LOGARGS 12
#include <stdarg.h>
// *****************************************************
// class LogEventsMngr
// *****************************************************
class LogEventsMngr {
char logString[256];
char logArgs[MAX_LOGARGS][128];
int logArgc;
int logCounter;
int logCurrent;
bool arelogevents;
public:
class CLogCmp;
class iterator;
class CLogEvent;
friend class CLogEvent;
friend class CLogCmp;
friend class iterator;
class CLogCmp
{
friend class LogEventsMngr;
friend class CLogEvent;
LogEventsMngr* parent;
String text;
int logid;
int pos;
int result;
bool in;
CLogCmp *next;
CLogCmp( const char* s, bool r, int p, CLogCmp *n, LogEventsMngr* mg ) : text(s) {
logid = result = 0;
pos = p;
parent = mg;
in = r;
next = n;
}
public:
int compareCondition(const char* string);
};
private:
CLogCmp *logcmplist;
public:
class CLogEvent {
friend class LogEventsMngr;
friend class iterator;
struct LogCondEle {
CLogCmp *cmp;
LogCondEle *next;
LogCondEle(CLogCmp *c, LogCondEle *n): cmp(c) , next(n) { }
};
struct LogCond {
LogCondEle *list;
int argnum;
LogCond *next;
LogCond( int a , LogCondEle* ee , LogCond* n ) : argnum(a) , list(ee), next(n) {}
~LogCond();
};
CPluginMngr::CPlugin *plugin;
int func;
LogEventsMngr* parent;
LogCond *filters;
CLogEvent *next;
CLogEvent(CPluginMngr::CPlugin *p,int f, LogEventsMngr* ppp) : plugin(p),func(f), filters(0),parent(ppp) ,next(0) { }
~CLogEvent();
public:
void registerFilter( char* filter );
inline CPluginMngr::CPlugin *getPlugin() { return plugin; }
inline int getFunction() { return func; }
};
private:
CLogEvent *logevents[MAX_LOGARGS+1];
CLogEvent *getValidLogEvent( CLogEvent * a );
CLogCmp* registerCondition(char* filter);
void clearConditions();
public:
LogEventsMngr();
~LogEventsMngr();
// Interface
CLogEvent* registerLogEvent( CPluginMngr::CPlugin* plugin, int func, int pos );
inline bool logEventsExist() { return arelogevents; }
void setLogString( char* frmt, va_list& vaptr );
void setLogString( char* frmt , ... );
void parseLogString( );
void executeLogEvents();
inline const char* getLogString() { return logString; }
inline int getLogArgNum() { return logArgc; }
inline const char* getLogArg( int i ) { return ( i < 0 || i >= logArgc ) ? "" : logArgs[ i ]; }
void clearLogEvents();
class iterator {
LogEventsMngr* b;
CLogEvent* a;
public:
inline iterator(CLogEvent*aa,LogEventsMngr* bb) : a(aa), b(bb) {}
inline iterator& operator++() {
a = b->getValidLogEvent( a->next );
return *this;
}
inline bool operator==(const iterator& c) const { return a == c.a; }
inline bool operator!=(const iterator& c) const { return !operator==(c); }
CLogEvent& operator*() { return *a; }
operator bool ( ) const { return a ? true : false; }
};
inline iterator begin() { return iterator(getValidLogEvent(logevents[ logArgc ]),this); }
inline iterator end() { return iterator(0,this); }
};
#endif

94
amxmodx/CMenu.cpp Executable file
View File

@ -0,0 +1,94 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "CMenu.h"
// *****************************************************
// class MenuMngr
// *****************************************************
MenuMngr::MenuCommand::MenuCommand( CPluginMngr::CPlugin *a, int mi, int k, int f ) {
plugin = a;
keys = k;
menuid = mi;
function = f;
next = 0;
}
MenuMngr::~MenuMngr()
{
clear();
}
int MenuMngr::findMenuId(const char* name, AMX* amx)
{
for( MenuIdEle* b = headid; b ; b = b->next) {
if ( (!b->amx || amx == b->amx) && strstr(name,b->name.str()) )
return b->id;
}
return 0;
}
int MenuMngr::registerMenuId(const char* n, AMX* a )
{
int id = findMenuId( n, a );
if (id) return id;
headid = new MenuIdEle( n, a , headid );
return headid->id;
}
void MenuMngr::registerMenuCmd( CPluginMngr::CPlugin *a,int mi, int k , int f )
{
MenuCommand** temp = &headcmd;
while(*temp) temp = &(*temp)->next;
*temp = new MenuCommand(a,mi, k,f);
}
void MenuMngr::clear()
{
while (headid)
{
MenuIdEle* a = headid->next;
delete headid;
headid = a;
}
while (headcmd)
{
MenuCommand* a = headcmd->next;
delete headcmd;
headcmd = a;
}
}
int MenuMngr::MenuIdEle::uniqueid = 0;

107
amxmodx/CMenu.h Executable file
View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef MENUS_H
#define MENUS_H
// *****************************************************
// class MenuMngr
// *****************************************************
class MenuMngr
{
struct MenuIdEle
{
String name;
AMX* amx;
MenuIdEle* next;
int id;
static int uniqueid;
MenuIdEle( const char* n, AMX* a, MenuIdEle* m ) : name( n ) , amx(a) , next( m ) {
id = ++uniqueid;
}
~MenuIdEle() { --uniqueid; }
} *headid;
public:
class iterator;
private:
class MenuCommand
{
friend class iterator;
friend class MenuMngr;
CPluginMngr::CPlugin *plugin;
int menuid;
int keys;
int function;
MenuCommand* next;
MenuCommand( CPluginMngr::CPlugin *a, int mi, int k, int f );
public:
inline int getFunction() { return function; }
inline CPluginMngr::CPlugin* getPlugin() { return plugin; }
inline bool matchCommand( int m, int k ) { return ((m == menuid) && (keys & k)); }
} *headcmd;
public:
MenuMngr() { headid = 0; headcmd = 0; }
~MenuMngr();
// Interface
int findMenuId(const char* name, AMX* a = 0);
int registerMenuId(const char* n, AMX* a );
void registerMenuCmd( CPluginMngr::CPlugin *a,int mi, int k , int f );
void clear();
class iterator {
MenuCommand* a;
public:
iterator(MenuCommand*aa) : a(aa) {}
iterator& operator++() { a = a->next; return *this; }
bool operator==(const iterator& b) const { return a == b.a; }
bool operator!=(const iterator& b) const { return !operator==(b); }
operator bool () const { return a ? true : false; }
MenuCommand& operator*() { return *a; }
};
inline iterator begin() const { return iterator(headcmd); }
inline iterator end() const { return iterator(0); }
};
#endif

232
amxmodx/CMisc.cpp Executable file
View File

@ -0,0 +1,232 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
// *****************************************************
// class CPlayer
// *****************************************************
void CPlayer::Init( edict_t* e , int i )
{
index = i;
pEdict = e;
initialized = false;
ingame = false;
bot = false;
authorized = false;
current = 0;
teamId = -1;
deaths = 0;
aiming = 0;
menu = 0;
keys = 0;
death_weapon.clear();
name.clear();
ip.clear();
team.clear();
}
void CPlayer::Disconnect() {
ingame = false;
initialized = false;
authorized = false;
}
void CPlayer::PutInServer() {
playtime = gpGlobals->time;
ingame = true;
}
bool CPlayer::Connect(const char* connectname,const char* ipaddress) {
name.set(connectname);
ip.set(ipaddress);
time = gpGlobals->time;
bot = IsBot();
death_killer = 0;
memset(flags,0,sizeof(flags));
memset(weapons,0,sizeof(weapons));
initialized = true;
authorized = false;
const char* authid = GETPLAYERAUTHID( pEdict );
if ( (authid == 0) || (*authid == 0)
|| (strcmp( authid , "STEAM_ID_PENDING") == 0) )
return true;
return false;
}
// *****************************************************
// class Grenades
// *****************************************************
void Grenades::put( edict_t* grenade, float time, int type, CPlayer* player )
{
Obj* a = new Obj;
if ( a == 0 ) return;
a->player = player;
a->grenade = grenade;
a->time = gpGlobals->time + time;
a->type = type;
a->next = head;
head = a;
}
bool Grenades::find( edict_t* enemy, CPlayer** p, int& type )
{
bool found = false;
Obj** a = &head;
while ( *a ){
if ( (*a)->time > gpGlobals->time ) {
if ( (*a)->grenade == enemy ) {
found = true;
(*p) = (*a)->player;
type = (*a)->type;
}
}
else {
Obj* b = (*a)->next;
delete *a;
*a = b;
continue;
}
a = &(*a)->next;
}
return found;
}
void Grenades::clear()
{
while(head){
Obj* a = head->next;
delete head;
head = a;
}
}
// *****************************************************
// class XVars
// *****************************************************
void XVars::clear() {
delete[] head;
head = 0;
num = 0;
size = 0;
}
int XVars::put( AMX* p, cell* v )
{
for(int a = 0; a < num; ++a) {
if ( (head[a].amx == p) && (head[a].value == v) )
return a;
}
if ( (num >= size) && realloc_array( size ? (size * 2) : 8 ) )
return -1;
head[num].value = v;
head[num].amx = p;
return num++;
}
int XVars::realloc_array( int nsize )
{
XVarEle* me = new XVarEle[nsize];
if ( me ){
for(int a = 0 ; a < num; ++a)
me[a] = head[a];
delete[] head;
head = me;
size = nsize;
return 0;
}
return 1;
}
// *****************************************************
// class TeamIds
// *****************************************************
TeamIds::TeamIds() { head = 0; newTeam = 0; }
TeamIds::~TeamIds() {
while( head ) {
TeamEle* a = head->next;
delete head;
head = a;
}
}
void TeamIds::registerTeam( const char* n ,int s )
{
TeamEle** a = &head;
while( *a ){
if ( strcmp((*a)->name.str(),n) == 0 ){
if (s != -1){
(*a)->id = s;
newTeam &= ~(1<<(*a)->tid);
}
return;
}
a = &(*a)->next;
}
*a = new TeamEle( n , s );
if ( *a == 0 ) return;
newTeam |= (1<<(*a)->tid);
}
int TeamIds::findTeamId( const char* n )
{
TeamEle* a = head;
while( a ){
if ( !strcmpi(a->name.str(),n) )
return a->id;
a = a->next;
}
return -1;
}
int TeamIds::findTeamIdCase( const char* n)
{
TeamEle* a = head;
while( a ){
if ( !strcmp(a->name.str(), n) )
return a->id;
a = a->next;
}
return -1;
}
char TeamIds::TeamEle::uid = 0;

252
amxmodx/CMisc.h Executable file
View File

@ -0,0 +1,252 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef CMISC_H
#define CMISC_H
#include "CList.h"
#include "string.h"
// *****************************************************
// class CCVar
// *****************************************************
class CCVar
{
cvar_t cvar;
String name;
String plugin;
public:
CCVar( const char* pname, const char* pplugin,
int pflags, float pvalue ) : name(pname) , plugin(pplugin ) {
cvar.name = (char*)name.str();
cvar.flags = pflags;
cvar.string = "";
cvar.value = pvalue;
}
inline cvar_t* getCvar() { return &cvar; }
inline const char* getPluginName() { return plugin.str(); }
inline const char* getName() { return name.str(); }
inline bool operator == ( const char* string ) const { return (strcmp(name.str(),string)==0); }
};
// *****************************************************
// class CPlayer
// *****************************************************
class CPlayer
{
public:
edict_t* pEdict;
String name;
String ip;
String team;
bool initialized;
bool ingame;
bool bot;
bool authorized;
float time;
float playtime;
struct {
int ammo;
int clip;
} weapons[MAX_WEAPONS];
int current;
int teamId;
int deaths;
int aiming;
int menu;
int keys;
int index;
int flags[32];
int death_headshot;
int death_killer;
int death_victim;
bool death_tk;
String death_weapon;
Vector lastTrace;
Vector thisTrace;
Vector lastHit;
void Init( edict_t* e , int i );
void Disconnect();
void PutInServer();
bool Connect(const char* connectname,const char* ipaddress);
inline bool IsBot(){
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);
return ( auth && !strcmp( auth , "BOT" ) );
}
inline bool IsAlive(){
return ((pEdict->v.deadflag==DEAD_NO)&&(pEdict->v.health>0));
}
inline void Authorize() { authorized = true; }
};
// *****************************************************
// class Grenades
// *****************************************************
class Grenades
{
struct Obj
{
CPlayer* player;
edict_t* grenade;
float time;
int type;
Obj* next;
} *head;
public:
Grenades() { head = 0; }
~Grenades() { clear(); }
void put( edict_t* grenade, float time, int type, CPlayer* player );
bool find( edict_t* enemy, CPlayer** p, int& type );
void clear();
};
// *****************************************************
// class ForceObject
// *****************************************************
class ForceObject {
AMX* amx;
String filename;
FORCE_TYPE type;
Vector mins;
Vector maxs;
public:
ForceObject(const char* n, FORCE_TYPE c,Vector& mi, Vector& ma, AMX* a) :
filename(n) , type(c), mins(mi), maxs(ma), amx(a) {}
inline const char* getFilename() { return filename.str(); }
inline AMX* getAMX() { return amx; }
Vector& getMin() { return mins; }
Vector& getMax() { return maxs; }
inline FORCE_TYPE getForceType() { return type; }
};
// *****************************************************
// class XVars
// *****************************************************
class XVars
{
struct XVarEle {
AMX* amx;
cell* value;
};
XVarEle* head;
int size;
int num;
int realloc_array( int nsize );
public:
XVars() { num = 0; size = 0; head = 0; }
~XVars() { clear(); }
void clear();
int put( AMX* a, cell* v );
inline cell getValue( int a ) {
return ( a >= 0 && a < num ) ? *(head[a].value) : 0;
}
inline int setValue( int a, cell v ) {
if ( a >= 0 && a < num ){
*(head[a].value) = v;
return 0;
}
return 1;
}
};
// *****************************************************
// class CScript
// *****************************************************
class CScript
{
String filename;
AMX* amx;
void* code;
public:
CScript(AMX* aa, void* cc,const char* ff):filename(ff),amx(aa),code(cc){}
inline AMX* getAMX() { return amx; }
inline const char* getName() { return filename.str(); }
inline bool operator==( void* a ) { return (amx == (AMX*)a); }
inline void* getCode() { return code; }
};
// *****************************************************
// class TeamIds
// *****************************************************
class TeamIds
{
struct TeamEle {
String name;
int id;
char tid;
static char uid;
TeamEle* next;
TeamEle(const char* n, int& i) : name(n) , id(i) , next(0) {
tid = uid++;
};
~TeamEle(){ --uid; }
} *head;
int newTeam;
public:
TeamIds();
~TeamIds();
void registerTeam( const char* n ,int s );
int findTeamId( const char* n);
int findTeamIdCase( const char* n);
inline bool isNewTeam() { return newTeam ? true : false; }
};
#endif

188
amxmodx/CModule.cpp Executable file
View File

@ -0,0 +1,188 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
typedef int (FAR *QUERYMOD)(module_info_s**);
typedef int (FAR *ATTACHMOD)(pfnamx_engine_g*,pfnmodule_engine_g*);
typedef int (FAR *DETACHMOD)(void);
QUERYMOD QueryModule;
ATTACHMOD AttachModule;
DETACHMOD DetachModule;
pfnamx_engine_g engAmxFunc = {
amx_Align16,
amx_Align32,
amx_Allot,
amx_Callback,
amx_Clone,
amx_Debug,
amx_Exec,
amx_Execv,
amx_FindPublic,
amx_FindPubVar,
amx_FindTagId,
amx_Flags,
amx_GetAddr,
amx_GetPublic,
amx_GetPubVar,
amx_GetString,
amx_GetTag,
amx_GetUserData,
amx_Init,
amx_InitJIT,
amx_MemInfo,
amx_NameLength,
amx_NativeInfo,
amx_NumPublics,
amx_NumPubVars,
amx_NumTags,
amx_RaiseError,
amx_Register,
amx_Release,
amx_SetCallback,
amx_SetDebugHook,
amx_SetString,
amx_SetUserData,
amx_StrLen,
};
pfnmodule_engine_g engModuleFunc = {
add_amxnatives,
build_pathname,
copy_amxmemory,
format_amxstring,
get_amxaddr,
get_amxscript,
get_amxscriptname,
get_amxstring,
get_modname,
load_amxscript,
print_srvconsole,
report_error,
set_amxnatives,
set_amxstring,
amxstring_len,
unload_amxscript,
alloc_amxmemory,
free_amxmemory,
};
// *****************************************************
// class CModule
// *****************************************************
CModule::CModule(const char* fname) : filename(fname)
{
metamod = false;
info = 0;
module = 0;
status = MODULE_NONE;
}
CModule::~CModule()
{
if ( module ) DLFREE(module);
natives.clear();
}
bool CModule::attachModule()
{
if ( status != MODULE_QUERY )
return false;
AttachModule = (ATTACHMOD)DLPROC(module,"AMX_Attach");
if ( AttachModule ) (*AttachModule)(&engAmxFunc,&engModuleFunc);
status = MODULE_LOADED;
return true;
}
bool CModule::queryModule()
{
if ( status != MODULE_NONE ) // don't check if already quried
return false;
module = DLLOAD( filename.str() ); // link dll
if ( !module ){
status = MODULE_BADLOAD;
return false;
}
int meta = (int)DLPROC(module,"Meta_Attach"); // check if also MM
if ( meta ) metamod = true;
QueryModule = (QUERYMOD)DLPROC(module,"AMX_Query"); // check what version
if (QueryModule == 0) {
status = MODULE_NOQUERY;
return false;
}
(*QueryModule)( &info );
if ( info == 0 ){
status = MODULE_NOINFO;
return false;
}
if ( info->ivers != AMX_INTERFACE_VERSION ) {
status = MODULE_OLD;
return false;
}
AttachModule = (ATTACHMOD)DLPROC(module,"AMX_Attach"); // check for attach
if ( AttachModule == 0) {
status = MODULE_NOATTACH;
return false;
}
info->serial = (long int)this;
status = MODULE_QUERY;
return true;
}
bool CModule::detachModule()
{
if ( status != MODULE_LOADED )
return false;
DetachModule = (DETACHMOD)DLPROC(module,"AMX_Detach");
if (DetachModule) (*DetachModule)();
DLFREE(module);
module = 0;
natives.clear();
status = MODULE_NONE;
return true;
}
const char* CModule::getStatus() const {
switch(status){
case MODULE_NONE: return "error";
case MODULE_QUERY: return "pending";
case MODULE_BADLOAD:return "bad load";
case MODULE_LOADED:return "running";
case MODULE_NOINFO:return "no info";
case MODULE_NOQUERY:return "no query";
case MODULE_NOATTACH:return "no attach";
case MODULE_OLD:return "old";
}
return "unknown";
}

84
amxmodx/CModule.h Executable file
View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
// *****************************************************
// class CModule
// *****************************************************
#ifndef CMODULE_H
#define CMODULE_H
enum MODULE_STATUS {
MODULE_NONE,
MODULE_QUERY,
MODULE_BADLOAD,
MODULE_LOADED,
MODULE_NOINFO,
MODULE_NOQUERY,
MODULE_NOATTACH,
MODULE_OLD
};
class CModule
{
String filename;
bool metamod;
module_info_s* info;
DLHANDLE module;
MODULE_STATUS status;
public:
CModule(const char* fname);
~CModule();
// Interface
bool attachModule();
bool queryModule();
bool detachModule();
const char* getStatus() const;
inline const char* getType() const { return metamod ? "amx&mm" : "amx"; }
inline const char* getAuthor() const { return info ? info->author : "unknown"; }
inline const char* getVersion() const { return info ? info->version : "unknown"; }
inline const char* getName() const { return info ? info->name : "unknown"; }
inline module_info_s* getInfo() const { return info; }
inline int getStatusValue() { return status; }
inline bool operator==( void* fname ) { return !strcmp( filename.str() , (char*)fname ); }
inline bool isReloadable() { return ( (status==MODULE_LOADED) && (info->type==RELOAD_MODULE)); }
CList<AMX_NATIVE_INFO*> natives;
};
#endif

340
amxmodx/COPYING Executable file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

207
amxmodx/CPlugin.cpp Executable file
View File

@ -0,0 +1,207 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "CPlugin.h"
#include "CForward.h"
#include "CFile.h"
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error) {
CPlugin** a = &head;
while( *a ) a = &(*a)->next;
*a = new CPlugin( pCounter++ ,path,name,error);
return *error ? 0 : *a;
}
void CPluginMngr::unloadPlugin( CPlugin** a ) {
CPlugin* next = (*a)->next;
delete *a;
*a = next;
--pCounter;
}
int CPluginMngr::loadPluginsFromFile( const char* filename )
{
File fp( build_pathname("%s",filename) , "r" );
if ( !fp )
{
print_srvconsole( "[AMX] Plugins list not found (file \"%s\")\n",filename);
return 1;
}
// Find now folder
char pluginName[256], line[256], error[256], pluginsDir[256];
strcpy(pluginsDir,filename);
char* ptrEnd = pluginsDir;
for (int i = 0; pluginsDir[i];++i ) {
if (pluginsDir[i] == '/' || pluginsDir[i] == '\\')
ptrEnd = &pluginsDir[i];
}
*ptrEnd = 0;
while ( fp.getline(line , 255 ) )
{
*pluginName = 0;
sscanf(line,"%s",pluginName);
if (!isalnum(*pluginName)) continue;
CPlugin* plugin = loadPlugin( pluginsDir , pluginName , error );
if ( plugin != 0 ) // load_amxscript fills it with info in case of error
{
AMX* amx = plugin->getAMX();
int iFunc;
if(amx_FindPublic(amx, "client_command" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_ClientCommand);
if(amx_FindPublic(amx, "client_connect" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_ClientConnect);
if(amx_FindPublic(amx, "client_disconnect" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_ClientDisconnect);
if(amx_FindPublic(amx, "client_infochanged" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_ClientInfoChanged);
if(amx_FindPublic(amx, "client_putinserver" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_ClientPutInServer);
if(amx_FindPublic(amx, "plugin_init" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_PluginInit);
if(amx_FindPublic(amx, "plugin_cfg" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_PluginCfg);
if(amx_FindPublic(amx, "plugin_precache" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_PluginPrecache);
if(amx_FindPublic(amx, "plugin_log" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_PluginLog);
if(amx_FindPublic(amx, "plugin_end" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_PluginEnd);
if(amx_FindPublic(amx, "inconsistent_file" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_InconsistentFile);
if(amx_FindPublic(amx, "client_authorized" , &iFunc) == AMX_ERR_NONE)
g_forwards.registerForward( plugin , iFunc , FF_ClientAuthorized);
}
else
{
print_srvconsole("[AMX] %s (plugin \"%s\")\n", error, pluginName );
}
}
return pCounter;
}
void CPluginMngr::clear() {
CPlugin**a = &head;
while ( *a )
unloadPlugin(a);
}
CPluginMngr::CPlugin* CPluginMngr::findPluginFast(AMX *amx)
{
return (CPlugin*)(amx->userdata[3]);
/*CPlugin*a = head;
while ( a && &a->amx != amx )
a=a->next;
return a;*/
}
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx) {
CPlugin*a = head;
while ( a && &a->amx != amx )
a=a->next;
return a;
}
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index){
CPlugin*a = head;
while ( a && index--)
a=a->next;
return a;
}
CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name) {
if (!name) return 0;
int len = strlen(name);
if (!len) return 0;
CPlugin*a = head;
while( a && strncmp(a->name.str(), name,len) )
a=a->next;
return a;
}
const char* CPluginMngr::CPlugin::getStatus() const {
switch(status){
case ps_running: return "running";
case ps_paused: return "paused";
case ps_bad_load: return "bad load";
case ps_stopped: return "stopped";
case ps_locked: return "locked";
}
return "error";
}
CPluginMngr::CPlugin::CPlugin(int i, const char* p,const char* n, char* e) : name(n), title(n) {
const char* unk = "unknown";
title.set(unk);
author.set(unk);
version.set(unk);
char* path = build_pathname("%s/%s",p,n);
code = 0;
int err = load_amxscript(&amx,&code,path,e );
if ( err == AMX_ERR_NONE ) status = ps_running;
else status = ps_bad_load;
amx.userdata[3] = this;
paused_fun = 0;
next = 0;
id = i;
}
CPluginMngr::CPlugin::~CPlugin( ){
unload_amxscript( &amx, &code );
}
void CPluginMngr::CPlugin::pauseFunction( int id ) {
if (isValid()){
paused_fun |= (1<<id);
g_commands.clearBufforedInfo();
}
}
void CPluginMngr::CPlugin::unpauseFunction( int id ) {
if (isValid()) {
paused_fun &= ~(1<<id);
g_commands.clearBufforedInfo();
}
}
void CPluginMngr::CPlugin::setStatus( int a ) {
status = a;
g_commands.clearBufforedInfo(); // ugly way
}

132
amxmodx/CPlugin.h Executable file
View File

@ -0,0 +1,132 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef PLUGIN_H
#define PLUGIN_H
// *****************************************************
// class CPluginMngr
// *****************************************************
enum {
ps_bad_load,
ps_error,
ps_paused,
ps_running,
ps_stopped,
ps_locked
};
class CPluginMngr
{
public:
class iterator;
class CPlugin
{
friend class iterator;
friend class CPluginMngr;
AMX amx;
void* code;
String name;
String version;
String title;
String author;
int paused_fun;
int status;
CPlugin* next;
int id;
CPlugin(int i , const char* p,const char* n, char* e);
~CPlugin( );
public:
inline const char* getName() const { return name.str();}
inline const char* getVersion() const { return version.str();}
inline const char* getTitle() const { return title.str();}
inline const char* getAuthor()const { return author.str();}
inline int getId() const { return id; }
inline AMX* getAMX() { return &amx; }
inline void setTitle( const char* n ) { title.set(n); }
inline void setAuthor( const char* n ) { author.set(n); }
inline void setVersion( const char* n ) { version.set(n); }
inline bool isValid() const { return ((status != ps_bad_load) && (status != ps_locked)); }
inline bool isPaused() const { return ( (status == ps_paused) || (status == ps_stopped)); }
inline bool isFunctionPaused( int id ) const { return (paused_fun & (1<<id)) ? true : false; }
inline bool isExecutable(int id) const { return (isValid() && !isPaused() && !isFunctionPaused(id)); }
inline void pausePlugin( ) { if ( isValid() ) setStatus(ps_paused); }
inline void unpausePlugin( ) { if ( isValid() ) setStatus(ps_running); }
void pauseFunction( int id );
void unpauseFunction( int id );
void setStatus( int a );
const char* getStatus() const;
};
private:
CPlugin *head;
int pCounter;
public:
CPluginMngr() { head = 0; pCounter = 0; }
~CPluginMngr() { clear(); }
// Interface
CPlugin* loadPlugin(const char* path, const char* name, char* error);
void unloadPlugin( CPlugin** a );
int loadPluginsFromFile( const char* filename );
CPlugin* findPluginFast(AMX *amx);
CPlugin* findPlugin(AMX *amx);
CPlugin* findPlugin(int index);
CPlugin* findPlugin(const char* name);
inline int getPluginsNum() const { return pCounter; }
void clear();
class iterator {
CPlugin *a;
public:
iterator(CPlugin*aa) : a(aa) {}
iterator& operator++() { a = a->next; return *this; }
bool operator==(const iterator& b) const { return a == b.a; }
bool operator!=(const iterator& b) const { return !operator==(b); }
operator bool () const { return a ? true : false; }
CPlugin& operator*() { return *a; }
};
inline iterator begin() const { return iterator(head); }
inline iterator end() const { return iterator(0); }
};
#endif

69
amxmodx/CString.cpp Executable file
View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "CString.h"
#include "string.h"
#include "CFile.h"
String::String()
{
len = 0;
napis = 0;
}
String::String( const char* n )
{
napis = 0;
set(n);
}
String::~String()
{
clear();
}
void String::set( const char* n )
{
clear();
if ( n != 0 ){
len = strlen( n );
napis = new char[ len + 1 ];
if ( napis ) strcpy( napis , n );
else len = 0;
}
}
void String::clear() {
delete[] napis;
napis = 0;
len = 0;
}

58
amxmodx/CString.h Executable file
View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef STRING_CUSTOM_H
#define STRING_CUSTOM_H
// *****************************************************
// class String
// *****************************************************
class String
{
char* napis;
short int len;
public:
String();
String( const char* n );
~String();
void set( const char* n );
inline bool empty() const { return (len == 0); }
inline const char* str() const { return napis ? napis : "(null)"; }
inline short int size() const { return len; }
void clear();
};
#endif

192
amxmodx/CTask.cpp Executable file
View File

@ -0,0 +1,192 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "CTask.h"
CTaskMngr::CTask::CTask( CPluginMngr::CPlugin* p, int f, int flags,
int i, float base, float exec, int parlen ,
const cell* par, int r){
plugin = p;
func = f;
id = i;
next = 0;
prev = 0;
param_len = 0;
param = 0;
base_time = base;
exec_time = exec;
repeat = (flags & 1) ? r : 0;
loop = (flags & 2) ? true : false;
afterstart = (flags & 4) ? true : false;
beforeend = (flags & 8) ? true : false;
if ( parlen )
{
param = new cell[ parlen + 1 ];
if ( param ){
param_len = parlen + 1;
memcpy( param , par , sizeof( cell ) * parlen );
param[ parlen ] = 0;
}
}
}
CTaskMngr::CTask* CTaskMngr::getFirstValidTask(CTask* h){
CTask* a = h;
while( a ) {
if ( a->isRemoved() ) {
CTask* b = a->next;
unlink( a );
delete a;
a = b;
continue;
}
else if ( a->afterstart ){
if ( *m_timer - *m_timeleft + 1 < a->base_time ) {
a = a->next;
continue;
}
}
else if ( a->beforeend ){
if ( *m_timelimit == 0 ){
a = a->next;
continue;
}
if ( (*m_timeleft + *m_timelimit * 60.0) - *m_timer - 1 >
a->base_time ){
a = a->next;
continue;
}
}
else if ( a->exec_time > *m_timer ) {
a = a->next;
continue;
}
return a;
}
return 0;
}
CTaskMngr::CTask* CTaskMngr::getNextTask(CTask* a) {
if ( a->isRemoved() )
return a->next;
if ( a->loop || a->isToReply() ){
a->exec_time = *m_timer + a->base_time;
return a->next;
}
a->setToRemove();
return a->next;
}
CTaskMngr::CTaskMngr() {
head = 0;
tail = 0;
m_timer = 0;
m_timelimit = 0;
m_timeleft = 0;
}
CTaskMngr::~CTaskMngr() {
clear();
}
void CTaskMngr::clear() {
while ( head ) {
tail = head->next;
delete head;
head = tail;
}
}
void CTaskMngr::registerTimers( float* timer , float* timelimit, float* timeleft ) {
m_timer = timer;
m_timelimit = timelimit;
m_timeleft = timeleft;
}
void CTaskMngr::registerTask( CPluginMngr::CPlugin* plugin, int func,
int flags, int i, float base, float exec,
int parlen , const cell* par, int repeat ){
CTask* a = new CTask(plugin,func,flags,i,base,exec,parlen,par,repeat );
if ( a == 0 ) return;
if ( tail )
{
tail->next = a;
a->prev = tail;
tail = a;
}
else {
head = a;
tail = a;
}
}
CTaskMngr::CTask* CTaskMngr::findTask( int id , AMX* amx )
{
for (CTask* a = head; a ; a = a->next)
{
if ( !a->isRemoved() && (a->getTaskId() == id) && (!amx ||
(a->getPlugin()->getAMX() == amx)) )
return a;
}
return 0;
}
void CTaskMngr::unlink(CTask* a){
if ( a->prev ) a->prev->next = a->next;
else head = a->next;
if ( a->next ) a->next->prev = a->prev;
else tail = a->prev;
}
int CTaskMngr::removeTasks( int id , AMX* amx )
{
CTask* a;
int i = 0;
while ( (a = findTask(id, amx )) != 0 ) {
a->setToRemove();
++i;
}
return i;
}

128
amxmodx/CTask.h Executable file
View File

@ -0,0 +1,128 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef CTASK_H
#define CTASK_H
// *****************************************************
// class CTaskMngr
// *****************************************************
class CTaskMngr
{
public:
class iterator;
class CTask
{
friend class iterator;
friend class CTaskMngr;
CPluginMngr::CPlugin* plugin;
int id;
int func;
int repeat;
bool loop;
bool afterstart;
bool beforeend;
float base_time;
float exec_time;
int param_len;
cell* param;
CTask* next;
CTask* prev;
inline void setToRemove() { exec_time = -1.0f; }
inline bool isToReply() { return (repeat-- > 0); }
inline bool isRemoved() { return (exec_time == -1.0f); }
CTask( CPluginMngr::CPlugin* p, int f, int flags, int i,
float base, float exec, int parlen , const cell* par, int r );
~CTask() { if ( param_len ) delete[] param; }
public:
inline int getParamLen() { return param_len; }
inline int getTaskId() { return id; }
inline int getFunction() { return func; }
cell* getParam() { return param; }
CPluginMngr::CPlugin* getPlugin() { return plugin; }
};
private:
friend class iterator;
CTask *head;
CTask *tail;
float* m_timer;
float* m_timelimit;
float* m_timeleft;
CTask* getFirstValidTask(CTask* a);
CTask* getNextTask(CTask* a);
CTask* findTask( int id , AMX* amx );
void unlink(CTask* a);
public:
CTaskMngr();
~CTaskMngr();
// Interface
void registerTimers( float* timer , float* timelimit, float* timeleft );
void registerTask( CPluginMngr::CPlugin* plugin, int func, int flags, int i, float base, float exec, int parlen , const cell* par, int repeat );
inline int taskExists( int id ,AMX* amx) { return findTask(id,amx ) ? 1 : 0; }
int removeTasks( int id , AMX* amx );
void clear();
class iterator {
CTaskMngr* b;
CTask* a;
public:
iterator(CTask*aa,CTaskMngr* bb) : a(aa), b(bb) {}
iterator& operator++() {
a = b->getNextTask( a );
a = b->getFirstValidTask( a );
return *this;
}
CTask& operator*() { return *a; }
operator bool ( ) const { return a ? true : false; }
};
inline iterator begin() { return iterator(getFirstValidTask(head),this); }
};
#endif

177
amxmodx/CVault.cpp Executable file
View File

@ -0,0 +1,177 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "CVault.h"
#include "CFile.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
// *****************************************************
// class Vault
// *****************************************************
bool Vault::exists( const char* k )
{
if ( *k == 0 ) return false;
return *find( k ) != 0;
}
void Vault::put( const char* k, const char* v )
{
if ( *k == 0 ) return;
if ( *v == 0 )
{
remove( k );
return;
}
Obj** a = find( k );
if ( *a )
{
(*a)->value.set(v);
(*a)->number = atoi( v );
}
else
*a = new Obj( k , v );
}
Vault::Obj::Obj( const char* k, const char* v): key(k) , value(v) , next(0) {
number = atoi(v);
}
Vault::Obj** Vault::find( const char* n )
{
Obj** a = &head;
while( *a )
{
if ( strcmp((*a)->key.str(), n) == 0 )
return a;
a = &(*a)->next;
}
return a;
}
int Vault::get_number( const char* n )
{
if ( *n == 0 ) return 0;
Obj* b = *find( n );
if ( b == 0 ) return 0;
return b->number;
}
const char* Vault::get( const char* n )
{
if ( *n == 0 ) return "";
Obj* b = *find( n );
if ( b == 0 ) return "";
return b->value.str();
}
void Vault::clear()
{
while ( head )
{
Obj* a = head->next;
delete head;
head = a;
}
}
void Vault::remove( const char* n )
{
Obj** b = find( n );
if ( *b == 0 ) return;
Obj* a = (*b)->next;
delete *b;
*b = a;
}
void Vault::setSource( const char* n )
{
path.set(n);
}
bool Vault::loadVault( )
{
if ( path.empty() ) return false;
clear();
File a( path.str() , "r" );
if ( !a ) return false;
const int sz = 512;
char value[sz+1];
char key[sz+1];
while ( a >> key && a.skipWs() && a.getline( value , sz ) )
{
if ( isalpha ( *key ) )
put( key, value );
}
return true;
}
bool Vault::saveVault( )
{
if ( path.empty() ) return false;
File a( path.str() , "w" );
if ( !a ) return false;
a << "; Don't modify!" << '\n';
for (Obj* b = head; b ;b = b->next)
a << b->key << '\t' << b->value << '\n';
return true;
}

93
amxmodx/CVault.h Executable file
View File

@ -0,0 +1,93 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef VAULT_CUSTOM_H
#define VAULT_CUSTOM_H
#include "CString.h"
#include "CList.h"
// *****************************************************
// class Vault
// *****************************************************
class Vault
{
struct Obj
{
String key;
String value;
int number;
Obj *next;
Obj( const char* k, const char* v);
} *head;
String path;
Obj** find( const char* n );
public:
Vault() {head=0;}
~Vault() { clear();}
// Interface
bool exists( const char* k );
void put(const char* k, const char* v);
void remove( const char* k );
const char* get( const char* n );
int get_number( const char* n );
void setSource( const char* n );
bool loadVault( );
bool saveVault( );
void clear();
class iterator {
Obj * a;
public:
iterator(Obj*aa) : a(aa) {}
iterator& operator++() { if ( a ) a = a->next; return *this; }
bool operator==(const iterator& b) const { return a == b.a; }
bool operator!=(const iterator& b) const { return !operator==(b); }
String& key() const { return a->key; }
String& value() const { return a->value; }
};
inline iterator begin() const { return iterator(head); }
inline iterator end() const { return iterator(0); }
};
#endif

116
amxmodx/Makefile Executable file
View File

@ -0,0 +1,116 @@
MODNAME = amx_mm
SRCFILES = meta_api.cpp CFile.cpp CString.cpp CVault.cpp vault.cpp\
float.cpp file.cpp modules.cpp CMisc.cpp CTask.cpp string.cpp\
amxmod.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp srvcmd.cpp strptime.cpp\
CForward.cpp CPlugin.cpp CModule.cpp CMenu.cpp emsg.cpp util.cpp
CSRCFILES = amx.c amxcore.c amxtime.c power.c
EXTRA_LIBS_LINUX =
EXTRA_LIBS_WIN32 =
EXTRA_LIBDIRS_LINUX = -Lextra/lib_linux
EXTRA_LIBDIRS_WIN32 = -Lextra/lib_win32
EXTRA_INCLUDEDIRS = -Iextra/include
EXTRA_FLAGS = -Dstrcmpi=strcasecmp
SDKTOP=../hlsdk
METADIR=../metamod/metamod
SDKSRC=$(SDKTOP)/SourceCode
OBJDIR_LINUX=obj.linux
OBJDIR_WIN32=obj.win32
SRCDIR=.
ifdef windir
OS=WIN32
else
OS=LINUX
endif
CC_LINUX=gcc
ifeq "$(OS)" "WIN32"
CC_WIN32=gcc
LD_WINDLL=dllwrap
DEFAULT=win32
CLEAN=clean_win32
else
CC_WIN32=/usr/local/cross-tools/i386-mingw32msvc/bin/gcc
LD_WINDLL=/usr/local/cross-tools/bin/i386-mingw32msvc-dllwrap
DEFAULT=linux win32
CLEAN=clean_both
endif
LIBFILE_LINUX = $(MODNAME)_i386.so
LIBFILE_WIN32 = $(MODNAME).dll
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
FILES_ALL = *.cpp *.h [A-Z]* *.rc
ifeq "$(OS)" "LINUX"
ASRCFILES := $(shell ls -t $(SRCFILES))
else
ASRCFILES := $(shell dir /b)
endif
OBJ_LINUX := $(SRCFILES:%.cpp=$(OBJDIR_LINUX)/%.o)
OBJC_LINUX := $(CSRCFILES:%.c=$(OBJDIR_LINUX)/%.o)
OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o)
OBJC_WIN32 := $(CSRCFILES:%.c=$(OBJDIR_WIN32)/%.o)
CCOPT = -march=i586 -O6 -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
-malign-jumps=2 -malign-functions=2 -s -DNDEBUG
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/pm_shared -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS)
CFLAGS=-Wall -Wno-unknown-pragmas
ODEF = -DOPT_TYPE=\"optimized\"
CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $<
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(OBJC_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@
LINK_WIN32=$(LD_WINDLL) -mwindows --def $(MODNAME).def --add-stdcall-alias $(OBJ_WIN32) $(OBJC_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.c
$(DO_CC_LINUX)
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_LINUX)
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.c
$(DO_CC_WIN32)
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_WIN32)
default: $(DEFAULT)
$(TARGET_LINUX): $(OBJDIR_LINUX) $(OBJ_LINUX) $(OBJC_LINUX)
$(LINK_LINUX)
$(TARGET_WIN32): $(OBJDIR_WIN32) $(OBJ_WIN32) $(OBJC_WIN32)
$(LINK_WIN32)
$(OBJDIR_LINUX):
mkdir $@
$(OBJDIR_WIN32):
mkdir $@
win32: $(TARGET_WIN32)
linux: $(TARGET_LINUX)
clean: $(CLEAN)
clean_both:
-rm -f $(OBJDIR_LINUX)/*
-rm -f $(OBJDIR_WIN32)/*
clean_win32:
del /q $(OBJDIR_WIN32)

3208
amxmodx/amx.c Executable file

File diff suppressed because it is too large Load Diff

271
amxmodx/amx.h Executable file
View File

@ -0,0 +1,271 @@
/* Abstract Machine for the Small compiler
*
* Copyright (c) ITB CompuPhase, 1997-2002
* This file may be freely used. No warranties of any kind.
*
* Version: $Id$
*/
#if defined __linux__
#include <sclinux.h>
#endif
#ifndef __AMX_H
#define __AMX_H
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
/* The ISO C99 defines the int16_t and int_32t types. If the compiler got
* here, these types are probably undefined.
*/
#if defined __LCC__ || defined __linux__
#include <stdint.h>
#else
typedef short int int16_t;
typedef unsigned short int uint16_t;
#if defined SN_TARGET_PS2
typedef int int32_t;
typedef unsigned int uint32_t;
#else
typedef long int int32_t;
typedef unsigned long int uint32_t;
#endif
#endif
#endif
/* Some compilers do not support the #pragma align, which should be fine. Some
* compilers give a warning on unknown #pragmas, which is not so fine...
*/
#if defined SN_TARGET_PS2
#define AMX_NO_ALIGN
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* calling convention for native functions */
#if !defined AMX_NATIVE_CALL
#define AMX_NATIVE_CALL
#endif
/* calling convention for all interface functions and callback functions */
#if !defined AMXAPI
#define AMXAPI
#endif
/* File format version Required AMX version
* 0 (original version) 0
* 1 (opcodes JUMP.pri, SWITCH and CASETBL) 1
* 2 (compressed files) 2
* 3 (public variables) 2
* 4 (opcodes SWAP.pri/alt and PUSHADDR) 4
* 5 (tagnames table) 4
* 6 (reformatted header) 6
*/
#define MIN_FILE_VERSION 6 /* lowest file format version */
#define CUR_FILE_VERSION 6 /* current AMX version (parallel with file version) */
#if !defined CELL_TYPE
#define CELL_TYPE
#if defined(BIT16)
typedef uint16_t ucell; /* only for type casting */
typedef int16_t cell;
#else
typedef uint32_t ucell;
typedef int32_t cell;
#endif
#endif
struct __amx;
typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct __amx *amx, cell *params);
typedef int (AMXAPI *AMX_CALLBACK)(struct __amx *amx, cell index,
cell *result, cell *params);
typedef int (AMXAPI *AMX_DEBUG)(struct __amx *amx);
#if !defined FAR
#define FAR
#endif
#if defined _MSC_VER
#pragma warning(disable:4103) /* disable warning message 4103 that complains
* about pragma pack in a header file */
#endif
#if !defined AMX_NO_ALIGN
#if defined __linux__
#pragma pack(1) /* structures must be packed (byte-aligned) */
#else
#pragma pack(push)
#pragma pack(1) /* structures must be packed (byte-aligned) */
#if defined __TURBOC__
#pragma option -a- /* "pack" pragma for older Borland compilers */
#endif
#endif
#endif
typedef struct {
char FAR *name;
AMX_NATIVE func;
} AMX_NATIVE_INFO;
#define AMX_USERNUM 4
#define sEXPMAX 19
typedef struct {
uint32_t address;
char name[sEXPMAX+1];
} AMX_FUNCSTUB;
/* The AMX structure is the internal structure for many functions. Not all
* fields are valid at all times; many fields are cached in local variables.
*/
typedef struct __amx {
unsigned char FAR *base; /* points to the AMX header ("amxhdr") plus the code, optionally also the data */
unsigned char FAR *data; /* points to separate data+stack+heap, may be NULL */
AMX_CALLBACK callback;
AMX_DEBUG debug;
/* for external functions a few registers must be accessible from the outside */
cell cip; /* relative to base + amxhdr->cod */
cell frm; /* relative to base + amxhdr->dat */
cell hea, hlw, stk, stp; /* all four are relative to base + amxhdr->dat */
int flags; /* current status, see amx_Flags() */
/* for assertions and debug hook */
cell curline, curfile;
int dbgcode;
cell dbgaddr, dbgparam;
char FAR *dbgname;
/* user data */
long usertags[AMX_USERNUM];
void FAR *userdata[AMX_USERNUM];
/* native functions can raise an error */
int error;
/* the sleep opcode needs to store the full AMX status */
cell pri, alt, reset_stk, reset_hea;
#if defined JIT
/* support variables for the JIT */
int reloc_size; /* required temporary buffer for relocations */
long code_size; /* estimated memory footprint of the native code */
#endif
} AMX;
/* The AMX_HEADER structure is both the memory format as the file format. The
* structure is used internaly.
*/
typedef struct __amx_header {
int32_t size; /* size of the "file" */
uint16_t magic; /* signature */
char file_version; /* file format version */
char amx_version; /* required version of the AMX */
int16_t flags;
int16_t defsize;
int32_t cod; /* initial value of COD - code block */
int32_t dat; /* initial value of DAT - data block */
int32_t hea; /* initial value of HEA - start of the heap */
int32_t stp; /* initial value of STP - stack top */
int32_t cip; /* initial value of CIP - the instruction pointer */
int32_t publics; /* offset to the "public functions" table */
int32_t natives; /* offset to the "native functions" table */
int32_t libraries; /* offset to the table of libraries */
int32_t pubvars; /* the "public variables" table */
int32_t tags; /* the "public tagnames" table */
} AMX_HEADER;
#define AMX_MAGIC 0xf1e0
enum {
AMX_ERR_NONE,
/* reserve the first 15 error codes for exit codes of the abstract machine */
AMX_ERR_EXIT, /* forced exit */
AMX_ERR_ASSERT, /* assertion failed */
AMX_ERR_STACKERR, /* stack/heap collision */
AMX_ERR_BOUNDS, /* index out of bounds */
AMX_ERR_MEMACCESS, /* invalid memory access */
AMX_ERR_INVINSTR, /* invalid instruction */
AMX_ERR_STACKLOW, /* stack underflow */
AMX_ERR_HEAPLOW, /* heap underflow */
AMX_ERR_CALLBACK, /* no callback, or invalid callback */
AMX_ERR_NATIVE, /* native function failed */
AMX_ERR_DIVIDE, /* divide by zero */
AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */
AMX_ERR_MEMORY = 16, /* out of memory */
AMX_ERR_FORMAT, /* invalid file format */
AMX_ERR_VERSION, /* file is for a newer version of the AMX */
AMX_ERR_NOTFOUND, /* function not found */
AMX_ERR_INDEX, /* invalid index parameter (bad entry point) */
AMX_ERR_DEBUG, /* debugger cannot run */
AMX_ERR_INIT, /* AMX not initialized (or doubly initialized) */
AMX_ERR_USERDATA, /* unable to set user data field (table full) */
AMX_ERR_INIT_JIT, /* cannot initialize the JIT */
AMX_ERR_PARAMS, /* parameter error */
};
enum {
DBG_INIT, /* query/initialize */
DBG_FILE, /* file number in curfile, filename in name */
DBG_LINE, /* line number in curline, file number in curfile */
DBG_SYMBOL, /* address in dbgaddr, class/type in dbgparam */
DBG_CLRSYM, /* stack address below which locals should be removed. stack address in stk */
DBG_CALL, /* function call, address jumped to in dbgaddr */
DBG_RETURN, /* function returns */
DBG_TERMINATE, /* program ends, code address in dbgaddr, reason in dbgparam */
DBG_SRANGE, /* symbol size and dimensions (arrays); level in dbgaddr (!); length in dbgparam */
};
#define AMX_FLAG_CHAR16 0x01 /* characters are 16-bit */
#define AMX_FLAG_DEBUG 0x02 /* symbolic info. available */
#define AMX_FLAG_COMPACT 0x04 /* compact encoding */
#define AMX_FLAG_BIGENDIAN 0x08 /* big endian encoding */
#define AMX_FLAG_BROWSE 0x4000
#define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */
#define AMX_EXEC_MAIN -1 /* start at program entry point */
#define AMX_EXEC_CONT -2 /* continue from last address */
#define AMX_USERTAG(a,b,c,d) ((a) | ((b)<<8) | ((long)(c)<<16) | ((long)(d)<<24))
uint16_t * AMXAPI amx_Align16(uint16_t *v);
uint32_t * AMXAPI amx_Align32(uint32_t *v);
int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data);
int AMXAPI amx_Debug(AMX *amx); /* default debug procedure, does nothing */
int AMXAPI amx_Exec(AMX *amx, cell *retval, int index, int numparams, ...);
int AMXAPI amx_Execv(AMX *amx, cell *retval, int index, int numparams, cell params[]);
int AMXAPI amx_FindPublic(AMX *amx, char *funcname, int *index);
int AMXAPI amx_FindPubVar(AMX *amx, char *varname, cell *amx_addr);
int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname);
int AMXAPI amx_Flags(AMX *amx,uint16_t *flags);
int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr);
int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname);
int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr);
int AMXAPI amx_GetString(char *dest,cell *source);
int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id);
int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr);
int AMXAPI amx_Init(AMX *amx, void *program);
int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code);
int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap);
int AMXAPI amx_NameLength(AMX *amx, int *length);
AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(char *name,AMX_NATIVE func);
int AMXAPI amx_NumPublics(AMX *amx, int *number);
int AMXAPI amx_NumPubVars(AMX *amx, int *number);
int AMXAPI amx_NumTags(AMX *amx, int *number);
int AMXAPI amx_RaiseError(AMX *amx, int error);
int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *nativelist, int number);
int AMXAPI amx_Release(AMX *amx, cell amx_addr);
int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug);
int AMXAPI amx_SetString(cell *dest, char *source, int pack);
int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr);
int AMXAPI amx_StrLen(cell *cstring, int *length);
#if !defined AMX_NO_ALIGN
#if defined __linux__
#pragma pack() /* reset default packing */
#else
#pragma pack(pop) /* reset previous packing */
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* __AMX_H */

11
amxmodx/amx_mm.def Executable file
View File

@ -0,0 +1,11 @@
; /usr/local/cross-tools/bin/i386-mingw32msvc-dlltool --base-file /tmp/cc4kB6s0.base --output-exp amx_mm.exp --dllname amx_mm.dll --output-def amx_mm.def --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def /tmp/ccyI7I7K.def
EXPORTS
GetEngineFunctions @ 1 ;
GetEngineFunctions_Post @ 2 ;
GetEntityAPI2 @ 3 ;
GetEntityAPI2_Post @ 4 ;
GiveFnptrsToDll = GiveFnptrsToDll@8 @ 5 ;
GiveFnptrsToDll@8 @ 6 ;
Meta_Attach @ 7 ;
Meta_Detach @ 8 ;
Meta_Query @ 9 ;

548
amxmodx/amxcore.c Executable file
View File

@ -0,0 +1,548 @@
/* Core module for the Small AMX
*
* Copyright (c) ITB CompuPhase, 1997-2002
* This file may be freely used. No warranties of any kind.
*
* Version: $Id$
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <assert.h>
#include "amx.h"
#define NOPROPLIST
/* A few compilers do not provide the ANSI C standard "time" functions */
#if !defined SN_TARGET_PS2 && !defined _WIN32_WCE
#include <time.h>
#endif
#define CHARBITS (8*sizeof(char))
typedef unsigned char uchar;
#if !defined NOPROPLIST
typedef struct _property_list {
struct _property_list *next;
cell id;
char *name;
cell value;
} proplist;
static proplist proproot = { NULL };
static proplist *list_additem(proplist *root)
{
proplist *item;
assert(root!=NULL);
if ((item=(proplist *)malloc(sizeof(proplist)))==NULL)
return NULL;
item->name=NULL;
item->id=0;
item->value=0;
item->next=root->next;
root->next=item;
return item;
}
static void list_delete(proplist *pred,proplist *item)
{
assert(pred!=NULL);
assert(item!=NULL);
pred->next=item->next;
assert(item->name!=NULL);
free(item->name);
free(item);
}
static void list_setitem(proplist *item,cell id,char *name,cell value)
{
char *ptr;
assert(item!=NULL);
if ((ptr=(char *)malloc(strlen(name)+1))==NULL)
return;
if (item->name!=NULL)
free(item->name);
strcpy(ptr,name);
item->name=ptr;
item->id=id;
item->value=value;
}
static proplist *list_finditem(proplist *root,cell id,char *name,cell value,
proplist **pred)
{
proplist *item=root->next;
proplist *prev=root;
/* check whether to find by name or by value */
assert(name!=NULL);
if (strlen(name)>0) {
/* find by name */
while (item!=NULL && (item->id!=id || stricmp(item->name,name)!=0)) {
prev=item;
item=item->next;
} /* while */
} else {
/* find by value */
while (item!=NULL && (item->id!=id || item->value!=value)) {
prev=item;
item=item->next;
} /* while */
} /* if */
if (pred!=NULL)
*pred=prev;
return item;
}
#endif
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL numargs(AMX *amx, cell *params)
{
AMX_HEADER *hdr;
uchar *data;
cell bytes;
hdr=(AMX_HEADER *)amx->base;
data=amx->base+(int)hdr->dat;
/* the number of bytes is on the stack, at "frm + 2*cell" */
bytes= * (cell *)(data+(int)amx->frm+2*sizeof(cell));
/* the number of arguments is the number of bytes divided
* by the size of a cell */
return bytes/sizeof(cell);
}
static cell AMX_NATIVE_CALL getarg(AMX *amx, cell *params)
{
AMX_HEADER *hdr;
uchar *data;
cell value;
hdr=(AMX_HEADER *)amx->base;
data=amx->base+(int)hdr->dat;
/* get the base value */
value= * (cell *)(data+(int)amx->frm+((int)params[1]+3)*sizeof(cell));
/* adjust the address in "value" in case of an array access */
value+=params[2]*sizeof(cell);
/* get the value indirectly */
value= * (cell *)(data+(int)value);
return value;
}
static cell AMX_NATIVE_CALL setarg(AMX *amx, cell *params)
{
AMX_HEADER *hdr;
uchar *data;
cell value;
hdr=(AMX_HEADER *)amx->base;
data=amx->base+(int)hdr->dat;
/* get the base value */
value= * (cell *)(data+(int)amx->frm+((int)params[1]+3)*sizeof(cell));
/* adjust the address in "value" in case of an array access */
value+=params[2]*sizeof(cell);
/* verify the address */
if (value<0 || value>=amx->hea && value<amx->stk)
return 0;
/* set the value indirectly */
* (cell *)(data+(int)value) = params[3];
return 1;
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL heapspace(AMX *amx,cell *params)
{
return amx->stk - amx->hea;
}
static cell AMX_NATIVE_CALL funcidx(AMX *amx,cell *params)
{
char name[64];
cell *cstr;
int index,err,len;
amx_GetAddr(amx,params[1],&cstr);
/* verify string length */
amx_StrLen(cstr,&len);
if (len>=64) {
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
} /* if */
amx_GetString(name,cstr);
err=amx_FindPublic(amx,name,&index);
if (err!=AMX_ERR_NONE)
index=-1; /* this is not considered a fatal error */
return index;
}
int amx_StrPack(cell *dest,cell *source)
{
int len;
amx_StrLen(source,&len);
if ((ucell)*source>UCHAR_MAX) {
/* source string is already packed */
while (len >= 0) {
*dest++ = *source++;
len-=sizeof(cell);
} /* while */
} else {
/* pack string, from bottom up */
cell c;
int i;
for (c=0,i=0; i<len; i++) {
assert((*source & ~0xffL)==0);
c=(c<<CHARBITS) | *source++;
if (i%sizeof(cell) == sizeof(cell)-1) {
*dest++=c;
c=0;
} /* if */
} /* for */
if (i%sizeof(cell) != 0) /* store remaining packed characters */
*dest=c << (sizeof(cell)-i%sizeof(cell))*CHARBITS;
else
*dest=0; /* store full cell of zeros */
} /* if */
return AMX_ERR_NONE;
}
int amx_StrUnpack(cell *dest,cell *source)
{
if ((ucell)*source>UCHAR_MAX) {
/* unpack string, from top down (so string can be unpacked in place) */
cell c;
int i,len;
amx_StrLen(source,&len);
dest[len]=0;
for (i=len-1; i>=0; i--) {
c=source[i/sizeof(cell)] >> (sizeof(cell)-i%sizeof(cell)-1)*CHARBITS;
dest[i]=c & UCHAR_MAX;
} /* for */
} else {
/* source string is already unpacked */
while ((*dest++ = *source++) != 0)
/* nothing */;
} /* if */
return AMX_ERR_NONE;
}
static int verify_addr(AMX *amx,cell addr)
{
int err;
cell *cdest;
err=amx_GetAddr(amx,addr,&cdest);
if (err!=AMX_ERR_NONE)
amx_RaiseError(amx,err);
return err;
}
static cell AMX_NATIVE_CALL core_strlen(AMX *amx,cell *params)
{
cell *cptr;
int len = 0;
if (amx_GetAddr(amx,params[1],&cptr)==AMX_ERR_NONE)
amx_StrLen(cptr,&len);
return len;
}
static cell AMX_NATIVE_CALL strpack(AMX *amx,cell *params)
{
cell *cdest,*csrc;
int len,needed,lastaddr,err;
/* calculate number of cells needed for (packed) destination */
amx_GetAddr(amx,params[2],&csrc);
amx_StrLen(csrc,&len);
needed=(len+sizeof(cell))/sizeof(cell); /* # of cells needed */
assert(needed>0);
lastaddr=params[1]+sizeof(cell)*needed-1;
if (verify_addr(amx,(cell)lastaddr)!=AMX_ERR_NONE)
return 0;
amx_GetAddr(amx,params[1],&cdest);
err=amx_StrPack(cdest,csrc);
if (err!=AMX_ERR_NONE)
return amx_RaiseError(amx,err);
return len;
}
static cell AMX_NATIVE_CALL strunpack(AMX *amx,cell *params)
{
cell *cdest,*csrc;
int len,err,lastaddr;
/* calculate number of cells needed for (packed) destination */
amx_GetAddr(amx,params[2],&csrc);
amx_StrLen(csrc,&len);
assert(len>=0);
lastaddr=params[1]+sizeof(cell)*(len+1)-1;
if (verify_addr(amx,(cell)lastaddr)!=AMX_ERR_NONE)
return 0;
amx_GetAddr(amx,params[1],&cdest);
err=amx_StrUnpack(cdest,csrc);
if (err!=AMX_ERR_NONE)
return amx_RaiseError(amx,err);
return len;
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL swapchars(AMX *amx,cell *params)
{
union {
cell c;
#if defined BIT16
uchar b[2];
#else
uchar b[4];
#endif
} value;
uchar t;
assert((size_t)params[0]==sizeof(cell));
value.c = params[1];
#if defined BIT16
t = value.b[0];
value.b[0] = value.b[1];
value.b[1] = t;
#else
t = value.b[0];
value.b[0] = value.b[3];
value.b[3] = t;
t = value.b[1];
value.b[1] = value.b[2];
value.b[2] = t;
#endif
return value.c;
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL core_tolower(AMX *amx,cell *params)
{
assert((size_t)params[0]==sizeof(cell));
return tolower((int)params[1]);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL core_toupper(AMX *amx,cell *params)
{
assert((size_t)params[0]==sizeof(cell));
return toupper((int)params[1]);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL core_min(AMX *amx,cell *params)
{
return params[1] <= params[2] ? params[1] : params[2];
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL core_max(AMX *amx,cell *params)
{
return params[1] >= params[2] ? params[1] : params[2];
}
static cell AMX_NATIVE_CALL core_clamp(AMX *amx,cell *params)
{
cell value = params[1];
if (params[2] > params[3]) /* minimum value > maximum value ! */
amx_RaiseError(amx,AMX_ERR_NATIVE);
if (value < params[2])
value = params[2];
else if (value > params[3])
value = params[3];
return value;
}
#if !defined NOPROPLIST
static char *MakePackedString(cell *cptr)
{
int len;
char *dest;
amx_StrLen(cptr,&len);
dest=(char *)malloc(len+sizeof(cell));
amx_GetString(dest,cptr);
return dest;
}
static cell AMX_NATIVE_CALL getproperty(AMX *amx,cell *params)
{
cell *cstr;
char *name;
proplist *item;
amx_GetAddr(amx,params[2],&cstr);
name=MakePackedString(cstr);
item=list_finditem(&proproot,params[1],name,params[3],NULL);
/* if list_finditem() found the value, store the name */
if (item!=NULL && item->value==params[3] && strlen(name)==0) {
int needed=(strlen(item->name)+sizeof(cell)-1)/sizeof(cell); /* # of cells needed */
if (verify_addr(amx,(cell)(params[4]+needed))!=AMX_ERR_NONE) {
free(name);
return 0;
} /* if */
amx_GetAddr(amx,params[4],&cstr);
amx_SetString(cstr,item->name,1);
} /* if */
free(name);
return (item!=NULL) ? item->value : 0;
}
static cell AMX_NATIVE_CALL setproperty(AMX *amx,cell *params)
{
cell prev=0;
cell *cstr;
char *name;
proplist *item;
amx_GetAddr(amx,params[2],&cstr);
name=MakePackedString(cstr);
item=list_finditem(&proproot,params[1],name,params[3],NULL);
if (item==NULL)
item=list_additem(&proproot);
if (item==NULL) {
amx_RaiseError(amx,AMX_ERR_MEMORY);
} else {
prev=item->value;
if (strlen(name)==0) {
free(name);
amx_GetAddr(amx,params[4],&cstr);
name=MakePackedString(cstr);
} /* if */
list_setitem(item,params[1],name,params[3]);
} /* if */
free(name);
return prev;
}
static cell AMX_NATIVE_CALL delproperty(AMX *amx,cell *params)
{
cell prev=0;
cell *cstr;
char *name;
proplist *item,*pred;
amx_GetAddr(amx,params[2],&cstr);
name=MakePackedString(cstr);
item=list_finditem(&proproot,params[1],name,params[3],&pred);
if (item!=NULL) {
prev=item->value;
list_delete(pred,item);
} /* if */
free(name);
return prev;
}
static cell AMX_NATIVE_CALL existproperty(AMX *amx,cell *params)
{
cell *cstr;
char *name;
proplist *item;
amx_GetAddr(amx,params[2],&cstr);
name=MakePackedString(cstr);
item=list_finditem(&proproot,params[1],name,params[3],NULL);
free(name);
return (item!=NULL);
}
#endif
/* This routine comes from the book "Inner Loops" by Rick Booth, Addison-Wesley
* (ISBN 0-201-47960-5). This is a "multiplicative congruential random number
* generator" that has been extended to 31-bits (the standard C version returns
* only 15-bits).
*/
static unsigned long IL_StandardRandom_seed = 0L;
#define IL_RMULT 1103515245L
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL core_random(AMX *amx,cell *params)
{
unsigned long lo, hi, ll, lh, hh, hl;
unsigned long result;
/* one-time initialization (or, mostly one-time) */
#if !defined SN_TARGET_PS2 && !defined _WIN32_WCE
if (IL_StandardRandom_seed == 0L)
IL_StandardRandom_seed=(unsigned long)time(NULL);
#endif
lo = IL_StandardRandom_seed & 0xffff;
hi = IL_StandardRandom_seed >> 16;
IL_StandardRandom_seed = IL_StandardRandom_seed * IL_RMULT + 12345;
ll = lo * (IL_RMULT & 0xffff);
lh = lo * (IL_RMULT >> 16 );
hl = hi * (IL_RMULT & 0xffff);
hh = hi * (IL_RMULT >> 16 );
result = ((ll + 12345) >> 16) + lh + hl + (hh << 16);
result &= ~LONG_MIN; /* remove sign bit */
if (params[1]!=0)
result %= params[1];
return (cell)result;
}
#if 0
void core_Init(void)
{
/* reduced to a do-nothing routine */
}
void core_Exit(void)
{
#if !defined NOPROPLIST
while (proproot.next!=NULL)
list_delete(&proproot,proproot.next);
#endif
}
#endif
AMX_NATIVE_INFO core_Natives[] = {
{ "numargs", numargs },
{ "getarg", getarg },
{ "setarg", setarg },
{ "heapspace", heapspace },
{ "funcidx", funcidx },
{ "strlen", core_strlen },
{ "strpack", strpack },
{ "strunpack", strunpack },
{ "swapchars", swapchars },
{ "tolower", core_tolower },
{ "toupper", core_toupper },
{ "random", core_random },
{ "min", core_min },
{ "max", core_max },
{ "clamp", core_clamp },
#if !defined NOPROPLIST
{ "getproperty", getproperty },
{ "setproperty", setproperty },
{ "deleteproperty",delproperty },
{ "existproperty", existproperty },
#endif
{ NULL, NULL } /* terminator */
};

2202
amxmodx/amxmod.cpp Executable file

File diff suppressed because it is too large Load Diff

237
amxmodx/amxmod.h Executable file
View File

@ -0,0 +1,237 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef AMXMOD_H
#define AMXMOD_H
#include "modules.h"
#include "CString.h"
#include "CList.h"
#include "CPlugin.h"
#include "CMisc.h"
#include "CVault.h"
#include "CModule.h"
#include "CTask.h"
#include "CLogEvent.h"
#include "CForward.h"
#include "CCmd.h"
#include "CMenu.h"
#include "CEvent.h"
#define AMX_VERSION "0.9.7"
#ifdef __cplusplus
extern "C" {
#endif
extern AMX_NATIVE_INFO core_Natives[];
extern AMX_NATIVE_INFO time_Natives[];
extern AMX_NATIVE_INFO power_Natives[];
#ifdef __cplusplus
}
#endif
extern AMX_NATIVE_INFO amxmod_Natives[];
extern AMX_NATIVE_INFO file_Natives[];
extern AMX_NATIVE_INFO float_Natives[];
extern AMX_NATIVE_INFO string_Natives[];
extern AMX_NATIVE_INFO vault_Natives[];
#ifndef __linux__
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path);
#define DLPROC(m,func) GetProcAddress(m,func);
#define DLFREE(m) FreeLibrary(m);
#else
#define DLLOAD(path) (DLHANDLE)dlopen(path, RTLD_NOW);
#define DLPROC(m,func) dlsym(m,func);
#define DLFREE(m) dlclose(m);
#endif
#ifndef __linux__
typedef HINSTANCE DLHANDLE;
#else
typedef void* DLHANDLE;
#endif
#ifndef GETPLAYERAUTHID
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
#endif
#define ANGLEVECTORS (*g_engfuncs.pfnAngleVectors)
#define CLIENT_PRINT (*g_engfuncs.pfnClientPrintf)
#define CVAR_DIRECTSET (*g_engfuncs.pfnCvar_DirectSet)
#define GETCLIENTLISTENING (*g_engfuncs.pfnVoice_GetClientListening)
#define RUNPLAYERMOVE (*g_engfuncs.pfnRunPlayerMove)
#define SETCLIENTLISTENING (*g_engfuncs.pfnVoice_SetClientListening)
#define SETCLIENTMAXSPEED (*g_engfuncs.pfnSetClientMaxspeed)
char* UTIL_SplitHudMessage(register const char *src);
int UTIL_ReadFlags(const char* c);
void UTIL_ClientPrint( edict_t *pEntity, int msg_dest, char *msg );
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL);
void UTIL_GetFlags(char* flags,int flag);
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pMessage);
void UTIL_IntToString(int value, char *output);
void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name);
void UTIL_ShowMenu( edict_t* pEntity, int slots, int time, char *menu, int mlen );
#define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)])
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t ))])
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
struct WeaponsVault {
String fullName;
short int iId;
short int ammoSlot;
};
struct fakecmd_t {
char args[256];
const char *argv[3];
//char argv[3][128];
int argc;
bool fake;
};
extern CPluginMngr g_plugins;
extern CTaskMngr g_tasksMngr;
extern CPlayer g_players[33];
extern CPlayer* mPlayer;
extern CmdMngr g_commands;
extern CList<CCVar> g_cvars;
extern CList<ForceObject> g_forcemodels;
extern CList<ForceObject> g_forcesounds;
extern CList<ForceObject> g_forcegeneric;
extern CList<CModule> g_modules;
extern CList<CPlayer*> g_auth;
extern EventsMngr g_events;
extern Grenades g_grenades;
extern LogEventsMngr g_logevents;
extern MenuMngr g_menucmds;
extern String g_log_dir;
extern String g_mod_name;
extern TeamIds g_teamsIds;
extern Vault g_vault;
extern CForwardMngr g_forwards;
extern WeaponsVault g_weaponsData[MAX_WEAPONS];
extern XVars g_xvars;
extern bool g_bmod_cstrike;
extern bool g_bmod_dod;
extern bool g_dontprecache;
extern bool g_initialized;
extern int g_srvindex;
extern cvar_t* amx_version;
extern cvar_t* hostname;
extern cvar_t* mp_timelimit;
extern fakecmd_t g_fakecmd;
extern float g_game_restarting;
extern float g_game_timeleft;
extern float g_task_time;
extern float g_auth_time;
extern hudtextparms_t g_hudset;
//extern int g_edict_point;
extern int g_players_num;
extern int mPlayerIndex;
extern int mState;
extern void (*endfunction)(void*);
extern void (*function)(void*);
typedef void (*funEventCall)(void*);
extern funEventCall modMsgsEnd[MAX_REG_MSGS];
extern funEventCall modMsgs[MAX_REG_MSGS];
extern int gmsgAmmoPickup;
extern int gmsgAmmoX;
extern int gmsgBattery;
extern int gmsgCurWeapon;
extern int gmsgDamage;
extern int gmsgDeathMsg;
extern int gmsgHealth;
extern int gmsgMOTD;
extern int gmsgScoreInfo;
extern int gmsgSendAudio;
extern int gmsgServerName;
extern int gmsgShowMenu;
extern int gmsgTeamInfo;
extern int gmsgTextMsg;
extern int gmsgVGUIMenu;
extern int gmsgWeapPickup;
extern int gmsgWeaponList;
extern int gmsgintermission;
extern int gmsgResetHUD;
extern int gmsgRoundTime;
void Client_AmmoPickup(void*);
void Client_AmmoX(void*);
void Client_CurWeapon(void*);
void Client_ScoreInfo(void*);
void Client_ShowMenu(void*);
void Client_TeamInfo(void*);
void Client_TextMsg(void*);
void Client_VGUIMenu(void*);
void Client_WeaponList(void*);
void Client_DamageEnd(void*);
void Client_DeathMsg(void*);
void amx_command();
void plugin_srvcmd();
const char* stristr(const char* a,const char* b);
char *strptime(const char *buf, const char *fmt, struct tm *tm, short addthem);
int loadModules(const char* filename);
void dettachModules();
void dettachReloadModules();
void attachModules();
void attachMetaModModules( const char* filename );
void dettachMetaModModules( const char* filename );
int add_amxnatives(module_info_s* info,AMX_NATIVE_INFO*natives);
cell* get_amxaddr(AMX *amx,cell amx_addr);
char* build_pathname(char *fmt, ... );
char* format_amxstring(AMX *amx, cell *params, int parm,int& len);
AMX* get_amxscript(int, void**,const char**);
const char* get_amxscriptname(AMX* amx);
char* get_amxstring(AMX *amx,cell amx_addr,int id,int& len);
int amxstring_len(cell* cstr);
int load_amxscript(AMX* amx, void** program, const char* path, char error[64]);
int set_amxnatives(AMX* amx,char error[64]);
int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max);
int unload_amxscript(AMX* amx,void** program);
void copy_amxmemory(cell* dest,cell* src,int len);
void get_modname(char*);
void print_srvconsole( char *fmt, ... );
void report_error( int code, char* fmt, ... );
void* alloc_amxmemory(void**, int size);
void free_amxmemory(void **ptr);
#endif // AMXMOD_H

104
amxmodx/amxtime.c Executable file
View File

@ -0,0 +1,104 @@
/* Date/time module for the Small AMX
*
* Copyright (c) ITB CompuPhase, 2001-2002
* This file may be freely used. No warranties of any kind.
*
* Version: $Id$
*/
#include <time.h>
#include <assert.h>
#if defined __WIN32__ || defined _WIN32
#include <windows.h>
#include <mmsystem.h>
#endif
#include "amx.h"
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL _time(AMX *amx, cell *params)
{
time_t sec1970;
struct tm gtm;
cell *cptr;
assert(params[0]==3*sizeof(cell));
time(&sec1970);
/* on DOS/Windows, the timezone is usually not set for the C run-time
* library; in that case gmtime() and localtime() return the same value
*/
gtm=*localtime(&sec1970);
if (amx_GetAddr(amx,params[1],&cptr)==AMX_ERR_NONE)
*cptr=gtm.tm_hour;
if (amx_GetAddr(amx,params[2],&cptr)==AMX_ERR_NONE)
*cptr=gtm.tm_min;
if (amx_GetAddr(amx,params[3],&cptr)==AMX_ERR_NONE)
*cptr=gtm.tm_sec;
/* the time() function returns the number of seconds since January 1 1970
* in Universal Coordinated Time (the successor to Greenwich Mean Time)
*/
return sec1970;
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL _date(AMX *amx, cell *params)
{
time_t sec1970;
struct tm gtm;
cell *cptr;
assert(params[0]==3*sizeof(cell));
time(&sec1970);
gtm=*localtime(&sec1970);
if (amx_GetAddr(amx,params[1],&cptr)==AMX_ERR_NONE)
*cptr=gtm.tm_year+1900;
if (amx_GetAddr(amx,params[2],&cptr)==AMX_ERR_NONE)
*cptr=gtm.tm_mon+1;
if (amx_GetAddr(amx,params[3],&cptr)==AMX_ERR_NONE)
*cptr=gtm.tm_mday;
return 0;
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
static cell AMX_NATIVE_CALL _tickcount(AMX *amx, cell *params)
{
// #if defined __WIN32__ || defined _WIN32
// static int timerset = 0;
// #endif
cell value;
assert(params[0]==sizeof(cell));
//#if defined __WIN32__ || defined _WIN32
// if (!timerset) {
// timeBeginPeriod(1); /* timeGetTime() is more accurate on WindowsNT
// * if timeBeginPeriod(1) is set */
// timerset=1;
// } /* if */
// value=timeGetTime(); /* this value is already in milliseconds */
// #else
value=(cell)clock();
/* convert to milliseconds */
value=(cell)((1000L * (value+CLK_TCK/2)) / CLK_TCK);
//#endif
return value;
}
AMX_NATIVE_INFO time_Natives[] = {
{ "time", _time },
{ "date", _date },
{ "tickcount", _tickcount },
{ NULL, NULL } /* terminator */
};

328
amxmodx/emsg.cpp Executable file
View File

@ -0,0 +1,328 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
int gmsgAmmoPickup;
int gmsgAmmoX;
int gmsgBattery;
int gmsgCurWeapon;
int gmsgDamage;
int gmsgDeathMsg;
int gmsgHealth;
int gmsgMOTD;
int gmsgScoreInfo;
int gmsgSendAudio;
int gmsgServerName;
int gmsgShowMenu;
int gmsgTeamInfo;
int gmsgTextMsg;
int gmsgVGUIMenu;
int gmsgWeapPickup;
int gmsgWeaponList;
int gmsgintermission;
int gmsgResetHUD;
int gmsgRoundTime;
TeamIds g_teamsIds;
WeaponsVault g_weaponsData[MAX_WEAPONS];
void Client_VGUIMenu(void* mValue)
{
if (!mPlayer) return;
switch (mState++){
case 0:
mPlayer->menu = -(*(int*)mValue);
break;
case 1:
mPlayer->keys = *(int*)mValue;
}
}
void Client_ShowMenu(void* mValue)
{
if (!mPlayer) return;
switch (mState++){
case 0:
mPlayer->keys = *(int*)mValue;
break;
case 3:
mPlayer->menu = g_menucmds.findMenuId( (char*)mValue );
}
}
void Client_TeamInfo(void* mValue)
{
if (mPlayer) return;
static int index;
switch (mState++) {
case 0:
index = *(int*)mValue;
break;
case 1:
if ( index < 1 || index > gpGlobals->maxClients ) break;
char* msg = (char*)mValue;
g_players[ index ].team.set( msg );
g_teamsIds.registerTeam( msg , -1 );
}
}
void Client_TextMsg(void* mValue)
{
if ( mPlayer ) return;
switch (mState++) {
case 1:{
char * msg = (char*)mValue;
if (!msg) break;
if ( !strncmp("#Game_C", msg , 7) ) {
g_game_timeleft = g_game_restarting = gpGlobals->time + 3;
// g_endround_time = gpGlobals->time;
// g_newround_time = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime") + 3;
}
else if (!strncmp("#Game_w", msg , 7) ) {
g_game_timeleft = -2;
}
else if ( !strncmp("#game_clan_s", msg , 12) ){
g_game_timeleft = -3;
}
break;
}
case 2:{
char * msg = (char*)mValue;
if (!msg) break;
if (g_game_timeleft == -2 ){
g_game_timeleft = g_game_restarting = gpGlobals->time + atoi( msg );
// g_newround_time = g_game_timeleft + CVAR_GET_FLOAT("mp_freezetime");
}
else if ( g_game_timeleft == -3 )
g_game_restarting = atoi( msg ) * 60;
break;
}
case 3:{
char * msg = (char*)mValue;
if (!msg) break;
if ( g_game_timeleft != -3 ) break;
g_game_restarting += atoi( msg );
g_game_timeleft = g_game_restarting = gpGlobals->time + g_game_restarting;
break;
}
}
}
void Client_WeaponList(void* mValue)
{
static int wpnList = 0;
//static int wpnList2;
static int iSlot;
static const char* wpnName;
switch (mState++) {
case 0:
wpnName = (char*)mValue;
break;
case 1:
iSlot = *(int*)mValue;
break;
case 7:
int iId = *(int*)mValue;
/*int* blocker;
int iwpn = iId;
if (iId > 31) {
iwpn -= 31;
blocker = &wpnList2;
}
else
blocker = &wpnList;*/
if ( (iId < 0 || iId >= MAX_WEAPONS ) || (wpnList & (1<<iId)) )
break;
wpnList |= (1<<iId);
g_weaponsData[iId].iId = iId;
g_weaponsData[iId].ammoSlot = iSlot;
g_weaponsData[iId].fullName.set(wpnName);
}
}
void Client_CurWeapon(void* mValue)
{
static int iState;
static int iId;
switch (mState++){
case 0:
iState = *(int*)mValue;
break;
case 1:
if (!iState) break;
iId = *(int*)mValue;
break;
case 2:
if (!mPlayer) return;
if (!iState || (iId < 1 || iId >= MAX_WEAPONS ) ) break;
mPlayer->weapons[iId].clip = *(int*)mValue;
mPlayer->current = iId;
mPlayer->lastHit = mPlayer->lastTrace;
}
}
void Client_AmmoX(void* mValue)
{
static int iAmmo;
switch (mState++){
case 0:
iAmmo = *(int*)mValue;
break;
case 1:
if (!mPlayer) return;
for(int i=1;i<MAX_WEAPONS;++i)
if (iAmmo == g_weaponsData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue;
}
}
void Client_AmmoPickup(void* mValue)
{
static int iSlot;
switch (mState++){
case 0:
iSlot = *(int*)mValue;
break;
case 1:
if (!mPlayer) return;
for(int i=1;i<MAX_WEAPONS;++i)
if (g_weaponsData[i].ammoSlot==iSlot)
mPlayer->weapons[i].ammo += *(int*)mValue;
}
}
void Client_ScoreInfo(void* mValue)
{
static int index;
static int deaths;
switch (mState++){
case 0:
index = *(int*)mValue;
break;
case 2:
deaths = *(int*)mValue;
break;
case 4:
if ( index < 1 || index > gpGlobals->maxClients ) break;
CPlayer*pPlayer = GET_PLAYER_POINTER_I( index );
pPlayer->deaths = deaths;
pPlayer->teamId = *(int*)mValue;
if ( g_teamsIds.isNewTeam() )
g_teamsIds.registerTeam( pPlayer->team.str() , pPlayer->teamId );
}
}
void Client_DamageEnd(void* mValue)
{
CPlayer* dead = mPlayer;
if ( dead && dead->death_killer )
{
g_events.parserInit( CS_DEATHMSG , &gpGlobals->time , mPlayer = 0, mPlayerIndex = 0 );
g_events.parseValue( dead->death_killer );
g_events.parseValue( dead->index );
g_events.parseValue( dead->death_headshot );
g_events.parseValue( dead->death_weapon.str() );
g_events.parseValue( dead->death_tk ? 1 : 0 );
g_events.executeEvents();
dead->death_killer = 0;
}
}
void Client_DeathMsg(void* mValue)
{
static CPlayer *killer;
static CPlayer *victim;
static int killer_id;
static int victim_id;
static int hs;
switch (mState++){
case 0:
killer_id = *(int*)mValue;
killer = (killer_id > 0 && killer_id < 33) ?
GET_PLAYER_POINTER_I(killer_id) : 0;
break;
case 1:
victim_id = *(int*)mValue;
victim = (victim_id > 0 && victim_id < 33) ?
GET_PLAYER_POINTER_I(victim_id) : 0;
break;
case 2:
hs = *(int*)mValue;
break;
case 3:
if ( !killer || !victim ) break;
victim->death_killer = killer_id;
victim->death_weapon.set((char*)mValue);
victim->death_headshot = hs;
victim->death_tk = (killer->teamId == victim->teamId);
}
}
/*
void Client_SendAudio(void* mValue)
{
}
void Client_SendAudioEnd(void* mValue)
{
}
void Client_RoundTimeEnd(void* mValue)
{
}
void Client_RoundTime(void* mValue)
{
}
void Client_ResetHUD(void* mValue)
{
}
*/

246
amxmodx/file.cpp Executable file
View File

@ -0,0 +1,246 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
// header file for unlink()
#ifdef __linux__
#include <unistd.h>
#else
#include <io.h>
#endif
#ifdef __GNUC__
//#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#endif
static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
{
#ifdef __GNUC__
int a;
struct dirent *ep;
DIR *dp;
char* dirname = build_pathname("%s",get_amxstring(amx,params[1],0,a) );
a = params[2];
if ( (dp = opendir (dirname)) == NULL )
return 0;
seekdir( dp , a );
if ( (ep = readdir (dp)) != NULL ) {
cell *length = get_amxaddr(amx,params[5]);
*length = set_amxstring(amx,params[3], ep->d_name ,params[4]);
a = telldir( dp );
}
else
a = 0;
closedir (dp);
return a;
#else
return 0;
#endif
}
static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */
{
int iLen;
char* szFile = get_amxstring(amx,params[1],0,iLen);
FILE*fp;
if ( (fp =fopen(build_pathname("%s",szFile),"r")) == NULL) {
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
char buffor[1024];
int i = 0, iLine = params[2];
while((i <= iLine) && fgets(buffor,1023,fp) )
i++;
fclose(fp);
if (i > iLine){
int len = strlen(buffor);
if (buffor[len-1]=='\n')
buffor[--len]=0;
if (buffor[len-1]=='\r')
buffor[--len]=0;
cell *length = get_amxaddr(amx,params[5]);
*length = set_amxstring(amx,params[3],buffor,params[4]);
return i;
}
return 0;
}
static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
{
int i;
char* sFile = build_pathname("%s", get_amxstring(amx,params[1],0,i) );
char* sText = get_amxstring(amx,params[2],0,i);
FILE* pFile;
int iLine = params[3];
// apending to the end
if (iLine < 0) {
if ( (pFile = fopen( sFile ,"a")) == NULL ){
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
fputs( sText , pFile );
fputc( '\n', pFile );
fclose( pFile );
return 1;
}
// creating a new file with a line in a middle
if ( (pFile = fopen(sFile,"r")) == NULL ) {
if ( (pFile = fopen(sFile,"w")) == NULL ){
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
for(i=0;i < iLine;++i)
fputc('\n',pFile);
fputs( sText , pFile );
fputc( '\n', pFile );
fclose(pFile);
return 1;
}
// adding a new line in a middle of already existing file
FILE* pTemp;
char buffor[1024];
if ( (pTemp = tmpfile()) == NULL ){
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
for(i=0;;++i){
if ( i == iLine ){
fgets(buffor,1023,pFile);
fputs( sText , pTemp );
fputc( '\n', pTemp );
}
else if ( fgets(buffor,1023,pFile) ){
fputs(buffor , pTemp );
}
else if ( i < iLine ) {
fputc( '\n', pTemp );
}
else break;
}
fclose(pFile);
rewind(pTemp);
// now rewrite because file can be now smaller...
if ( (pFile = fopen(sFile,"w")) == NULL ){
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
while(fgets(buffor,1023,pTemp))
fputs(buffor,pFile );
fclose(pTemp);
fclose(pFile);
return 1;
}
static cell AMX_NATIVE_CALL delete_file(AMX *amx, cell *params) /* 1 param */
{
int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen);
return (unlink( build_pathname("%s",sFile) )?0:1);
}
static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
{
int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen);
FILE* fp = fopen(build_pathname("%s",sFile),"r");
if ( fp != NULL) {
fclose(fp);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
{
int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen);
FILE* fp = fopen(build_pathname("%s",sFile),"r");
if ( fp != NULL) {
if ( params[0] < 2 || params[2] == 0 ){
fseek(fp,0,SEEK_END);
int size = ftell(fp);
fclose(fp);
return size;
}
else if ( params[2] == 1 ){
int a = 0,lines = 0;
while( a != EOF ){
++lines;
while ( (a = fgetc(fp)) != '\n' && a != EOF )
;
}
//int a, b = '\n';
//while( (a = fgetc(fp)) != EOF ){
// if ( a == '\n')
// ++lines;
// b = a;
//}
//if ( b != '\n' )
// ++lines;
return lines;
}
else if ( params[2] == 2 ){
fseek(fp,-1,SEEK_END);
if ( fgetc(fp) == '\n' )
return 1;
return 0;
}
}
return -1;
}
AMX_NATIVE_INFO file_Natives[] = {
{ "delete_file", delete_file },
{ "file_exists", file_exists },
{ "file_size", file_size },
{ "read_dir", read_dir },
{ "read_file", read_file },
{ "write_file", write_file },
{ NULL, NULL }
};

96
amxmodx/float.cpp Executable file
View File

@ -0,0 +1,96 @@
/* Float arithmetic for the Small AMX engine
*
* Copyright (c) Artran, Inc. 1999
* Written by Greg Garner (gmg@artran.com)
* This file may be freely used. No warranties of any kind.
*
*/
#include <math.h>
#include <stdlib.h>
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
inline cell FloatToCell(float fValue) {
return *(cell *)((void *)&fValue);
}
inline float CellToFloat(cell cellValue){
return *(float *)((void *)&cellValue);
}
static cell _float(AMX *,cell *params){
return FloatToCell((float)params[1]);
}
static cell _floatstr(AMX *amx,cell *params){
int len;
return FloatToCell((float)atof(get_amxstring(amx,params[1],0,len)));
}
static cell _floatmul(AMX *,cell *params){
return FloatToCell(CellToFloat(params[1]) * CellToFloat(params[2]));
}
static cell _floatdiv(AMX *,cell *params){
return FloatToCell(CellToFloat(params[1]) / CellToFloat(params[2]));
}
static cell _floatadd(AMX *,cell *params){
return FloatToCell(CellToFloat(params[1]) + CellToFloat(params[2]));
}
static cell _floatsub(AMX *,cell *params){
return FloatToCell(CellToFloat(params[1]) - CellToFloat(params[2]));
}
static cell _floatfract(AMX *,cell *params){
float fA = CellToFloat(params[1]);
fA -= (float)(floor((double)fA));
return FloatToCell(fA);
}
static cell _floatround(AMX *,cell *params){
float fA = CellToFloat(params[1]);
switch (params[2]) {
case 1:
fA = (float)(floor((double)fA));
break;
case 2:
float fValue;
fValue = (float)(floor((double)fA));
if ( (fA>=0) && ((fA-fValue)!=0) )
fValue++;
fA = fValue;
break;
default:
fA = (float)(floor((double)fA+.5));
break;
}
return (long)fA;
}
static cell _floatcmp(AMX *,cell *params){
float fA = CellToFloat(params[1]);
float fB = CellToFloat(params[2]);
if (fA == fB)
return 0;
else if (fA > fB)
return 1;
else
return -1;
}
AMX_NATIVE_INFO float_Natives[] = {
{ "float", _float },
{ "floatstr", _floatstr },
{ "floatmul", _floatmul },
{ "floatdiv", _floatdiv },
{ "floatadd", _floatadd },
{ "floatsub", _floatsub },
{ "floatfract", _floatfract},
{ "floatround", _floatround},
{ "floatcmp", _floatcmp},
{ NULL, NULL }
};

1096
amxmodx/meta_api.cpp Executable file

File diff suppressed because it is too large Load Diff

526
amxmodx/modules.cpp Executable file
View File

@ -0,0 +1,526 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
#include "osdep.h" // sleep, etc
#include "CFile.h"
CList<CModule> g_modules;
CList<CScript,AMX*> g_loadedscripts;
#ifdef __cplusplus
extern "C" {
#endif
extern const char* no_function; // stupid work around
#ifdef __cplusplus
}
#endif
void report_error( int code, char* fmt, ... )
{
va_list argptr;
char string[256];
*string = 0;
va_start (argptr, fmt);
vsnprintf (string, 255, fmt,argptr);
string[255] = 0;
va_end (argptr);
if ( *string ) {
//File fp( "error_amx.log","a" );
//fp << string;
print_srvconsole( string );
print_srvconsole("[AMX] Make sure that modules are compatible with AMX %s\n" , AMX_VERSION );
print_srvconsole("[AMX] Please fix the problem then start the server again\n" );
}
sleep( 5 );
exit( code );
}
void print_srvconsole( char *fmt, ... )
{
va_list argptr;
char string[256];
va_start (argptr, fmt);
vsnprintf (string, 255, fmt,argptr);
string[255] = 0;
va_end (argptr);
SERVER_PRINT(string);
}
void* alloc_amxmemory(void** p, int size)
{
*p = new unsigned char[ size ];
return *p;
}
void free_amxmemory(void **ptr)
{
delete[] *ptr;
*ptr = 0;
}
int load_amxscript(AMX *amx, void **program, const char *filename, char error[64]){
AMX_HEADER hdr;
int err;
FILE *fp;
memset(amx, 0, sizeof(*amx));
*program = 0;
*error = 0;
if ( (fp = fopen( filename, "rb" )) == NULL)
{
strcpy(error,"Plugin file open error");
return (amx->error = AMX_ERR_NOTFOUND);
}
fread(&hdr, sizeof(hdr), 1, fp);
amx_Align16(&hdr.magic);
if (hdr.magic!=AMX_MAGIC)
{
strcpy(error,"Invalid plugin");
return (amx->error = AMX_ERR_FORMAT);
}
amx_Align32((uint32_t *)&hdr.stp);
amx_Align32((uint32_t *)&hdr.size);
if ( (*program = new unsigned char[ (int)hdr.stp ]) == 0 )
//if ( (*program = malloc( (int)hdr.stp )) == 0 )
{
strcpy(error,"Failed to allocate memory");
return (amx->error = AMX_ERR_MEMORY);
}
rewind(fp);
fread(*program, 1, (size_t)hdr.size, fp);
fclose(fp);
if ((err = amx_Init( amx, *program )) != AMX_ERR_NONE)
{
sprintf(error,"Load error %d (invalid file format or version)", err);
return (amx->error = AMX_ERR_INIT);
}
#ifdef JIT
void *np = new unsigned char[ amx->code_size ];
void *rt = new unsigned char[ amx->reloc_size ];
if ( !np || (!rt && amx->reloc_size > 0) )
{
delete[] np;
delete[] rt;
strcpy(error,"Failed to initialize plugin");
return (amx->error = AMX_ERR_INIT);
}
if (amx_InitJIT(amx, rt, np) == AMX_ERR_NONE)
{
//amx->base = (unsigned char FAR *)realloc( np, amx->code_size );
amx->base = new unsigned char FAR[ amx->code_size ];
if ( amx->base )
memcpy( amx->base , np , amx->code_size );
delete[] np;
delete[] rt;
delete[] *program;
(*program) = amx->base;
if ( *program == 0 ){
strcpy(error,"Failed to allocate memory");
return (amx->error = AMX_ERR_MEMORY);
}
}
else
{
delete[] np;
delete[] rt;
strcpy(error,"Failed to initialize plugin");
return (amx->error = AMX_ERR_INIT_JIT);
}
#endif
CScript* aa = new CScript(amx,*program,filename);
if ( aa == 0 )
{
strcpy(error,"Failed to allocate memory");
return (amx->error = AMX_ERR_MEMORY);
}
g_loadedscripts.put( aa );
return set_amxnatives(amx,error);
}
int set_amxnatives(AMX* amx,char error[64])
{
for ( CList<CModule>::iterator a = g_modules.begin(); a ; ++a )
{
for( CList<AMX_NATIVE_INFO*>::iterator cc =
(*a).natives.begin(); cc; ++cc )
amx_Register(amx, *cc , -1);
}
amx_Register(amx, string_Natives, -1);
amx_Register(amx, float_Natives, -1);
amx_Register(amx, file_Natives, -1);
amx_Register(amx, amxmod_Natives, -1);
amx_Register(amx, power_Natives, -1);
amx_Register(amx, time_Natives, -1);
amx_Register(amx, vault_Natives, -1);
if ( amx_Register(amx, core_Natives, -1) != AMX_ERR_NONE )
{
sprintf(error,"Function not found (name \"%s\")",no_function);
return (amx->error = AMX_ERR_NATIVE);
}
return AMX_ERR_NONE;
}
int unload_amxscript(AMX* amx, void** program)
{
CList<CScript,AMX*>::iterator a = g_loadedscripts.find( amx );
if ( a ) a.remove();
delete[] *program;
//free( *program );
*program = 0;
return AMX_ERR_NONE;
}
AMX* get_amxscript(int id , void** code, const char** filename)
{
CList<CScript,AMX*>::iterator a = g_loadedscripts.begin();
while ( a && id-- )
++a;
if ( a ){
*filename = (*a).getName();
*code = (*a).getCode();
return (*a).getAMX();
}
return 0;
}
const char* get_amxscriptname(AMX* amx)
{
CList<CScript,AMX*>::iterator a = g_loadedscripts.find( amx );
return a ? (*a).getName() : "";
}
void get_modname(char* buffer )
{
strcpy( buffer , g_mod_name.str() );
}
char* build_pathname(char *fmt, ... )
{
static char string[256];
int b;
int a = b = snprintf(string , 255 ,
#ifndef __linux__
"%s\\",
#else
"%s/",
#endif
g_mod_name.str());
va_list argptr;
va_start (argptr, fmt);
a += vsnprintf (&string[a], 255 - a , fmt,argptr);
string[ a ] = 0;
va_end (argptr);
char* path = &string[b];
while (*path)
{
#ifndef __linux__
if (*path == '/') *path = '\\';
#else
if (*path == '\\') *path = '/';
#endif
++path;
}
return string;
}
int add_amxnatives(module_info_s* info,AMX_NATIVE_INFO*natives)
{
CList<CModule>::iterator a = g_modules.begin();
while ( a )
{
if ( (*a).getInfo() == info )
{
AMX_NATIVE_INFO** aa = new AMX_NATIVE_INFO*(natives);
if ( aa == 0 ) return AMX_ERR_NATIVE;
(*a).natives.put( aa );
return AMX_ERR_NONE;
}
++a;
}
return AMX_ERR_NATIVE;
}
bool validFile(const char* file)
{
const char* a = 0;
while(*file)
if (*file++=='.')
a = file;
#ifndef __linux__
return (a && !strcmp(a,"dll"));
#else
return (a && !strcmp(a,"so"));
#endif
}
int loadModules(const char* filename)
{
File fp( build_pathname("%s",filename), "r" );
if ( !fp )
{
print_srvconsole( "[AMX] Modules list not found (file \"%s\")\n",filename);
return 0;
}
char line[256], moduleName[256];
int loaded = 0;
while ( fp.getline( line , 255 ) )
{
*moduleName = 0;
sscanf(line,"%s",moduleName);
if (!isalnum(*moduleName) || !validFile(moduleName) )
continue;
char* pathname = build_pathname("%s",moduleName);
CList<CModule>::iterator a = g_modules.find( pathname );
if ( a ) continue; // already loaded
CModule* cc = new CModule( pathname );
if ( cc == 0 ) return loaded;
cc->queryModule();
switch( cc->getStatusValue() ) {
case MODULE_BADLOAD:
report_error( 1 , "[AMX] Module is not a valid library (file \"%s\")\n",pathname );
break;
case MODULE_NOINFO:
report_error( 1 ,"[AMX] Couldn't find info. about module (file \"%s\")\n",pathname );
break;
case MODULE_NOQUERY:
report_error( 1 , "[AMX] Couldn't find \"AMX_Query\" (file \"%s\")\n", pathname );
break;
case MODULE_NOATTACH:
report_error( 1 , "[AMX] Couldn't find \"AMX_Attach\" (file \"%s\")\n", pathname );
break;
case MODULE_OLD:
report_error( 1 , "[AMX] Module has a different interface version (file \"%s\")\n",pathname );
break;
default:
++loaded;
}
g_modules.put( cc );
}
return loaded;
}
void dettachModules()
{
CList<CModule>::iterator a = g_modules.begin();
while ( a )
{
(*a).detachModule();
a.remove();
}
}
void dettachReloadModules()
{
CList<CModule>::iterator a = g_modules.begin();
while ( a )
{
if ( (*a).isReloadable() )
{
(*a).detachModule();
a.remove();
continue;
}
++a;
}
}
void attachModules()
{
CList<CModule>::iterator a = g_modules.begin();
while ( a )
{
(*a).attachModule();
++a;
}
}
const char* strip_name( const char* a )
{
const char* ret = a;
while(*a){
if ( *a== '/' || *a=='\\' ){
ret = ++a;
continue;
}
++a;
}
return ret;
}
void dettachMetaModModules( const char* filename )
{
File fp( build_pathname("%s",filename), "r" );
if ( !fp )
{
print_srvconsole( "[AMX] Modules list not found (file \"%s\")\n",filename);
return;
}
char line[256], moduleName[256], cmdline[256];
DLHANDLE module;
while ( fp.getline( line , 255 ) )
{
*moduleName = 0;
sscanf(line,"%s",moduleName);
if (!isalnum(*moduleName) || !validFile(moduleName) )
continue;
char* pathname = build_pathname("%s",moduleName);
module = DLLOAD( pathname ); // link dll
if ( module )
{
int a = (int)DLPROC(module,"Meta_Attach");
if ( a )
{
snprintf(cmdline,255, "meta unload %s\n", strip_name(moduleName) );
cmdline[255] = 0;
SERVER_COMMAND( cmdline );
}
DLFREE(module);
}
}
}
void attachMetaModModules( const char* filename )
{
File fp( build_pathname("%s",filename), "r" );
if ( !fp )
{
print_srvconsole( "[AMX] Modules list not found (file \"%s\")\n",filename);
return;
}
char line[256], moduleName[256], cmdline[256];
DLHANDLE module;
int loaded = 0;
while ( fp.getline( line , 255 ) )
{
*moduleName = 0;
sscanf(line,"%s",moduleName);
if (!isalnum(*moduleName) || !validFile(moduleName) )
continue;
char* pathname = build_pathname("%s",moduleName);
module = DLLOAD( pathname ); // link dll
if ( module )
{
int a = (int)DLPROC(module,"Meta_Attach");
if ( a )
{
snprintf(cmdline,255, "meta load %s\n", moduleName );
cmdline[255] = 0;
SERVER_COMMAND( cmdline );
++loaded;
}
DLFREE(module);
}
}
if ( loaded )
{
SERVER_COMMAND( "restart\n" );
/* must be or modules can cause crash
since they were not initialized with all routines (spawn, server active
players think, etc.) and metamod calls other routines
like nothing has never happened. */
}
}

179
amxmodx/modules.h Executable file
View File

@ -0,0 +1,179 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#ifndef __MODULES_H__
#define __MODULES_H__
#include "amx.h"
#undef DLLEXPORT
#ifndef __linux__
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#define WINAPI
#endif
#undef C_DLLEXPORT
#define C_DLLEXPORT extern "C" DLLEXPORT
#define AMX_INTERFACE_VERSION 6
#define RELOAD_MODULE 0
#define STATIC_MODULE 1
struct module_info_s {
const char* name;
const char* author;
const char* version;
int ivers;
int type;
long int serial;
};
// Small scripting language
struct pfnamx_engine_g {
uint16_t* (*pfnamx_Align16)(uint16_t *); // value
uint32_t* (*pfnamx_Align32)(uint32_t *); // value
int (*pfnamx_Allot)(AMX*, int, cell*, cell**); // amx, length, amx_addr, phys_addr
int (*pfnamx_Callback)(AMX*, cell , cell*, cell*); // amx, index,result,params
int (*pfnamx_Clone)(AMX*, AMX*, void*); // amxClone, amxSrc, data
int (*pfnamx_Debug)(AMX*); // default debug procedure, does nothing // amx
int (*pfnamx_Exec)(AMX*, cell*, int , int , ...); // amx, return val, index, num_params, ...
int (*pfnamx_Execv)(AMX*, cell*, int , int, cell[]); // amx, return val, index, num_params, param[]
int (*pfnamx_FindPublic)(AMX*, char*, int*); // amx, func name, index
int (*pfnamx_FindPubVar)(AMX*, char*, cell*); // anx, var name, amx_addr
int (*pfnamx_FindTagId)(AMX*, cell , char*); // amx. tag_id, tagname
int (*pfnamx_Flags)(AMX*,uint16_t *); // amx, flags
int (*pfnamx_GetAddr)(AMX*,cell ,cell**); // amx, amx_addr, phys_addr
int (*pfnamx_GetPublic)(AMX*, int , char*); // amx, index, funcname
int (*pfnamx_GetPubVar)(AMX*, int , char*, cell*); // amx, index, varname, amx_addr
int (*pfnamx_GetString)(char*dest,cell*); // dest, source
int (*pfnamx_GetTag)(AMX*, int , char*, cell*); // amx, index, tagname, tag_id
int (*pfnamx_GetUserData)(AMX*, long , void **); // amx, tag, ptr
int (*pfnamx_Init)(AMX*, void *); // amx, program
int (*pfnamx_InitJIT)(AMX*, void *, void *); // amx, reloc_table, native_code
int (*pfnamx_MemInfo)(AMX*, long*, long*, long*); // amx, codesize, datasize, stackheap
int (*pfnamx_NameLength)(AMX*, int*); // amx, length
AMX_NATIVE_INFO * (*pfnamx_NativeInfo)(char*,AMX_NATIVE ); // name, func
int (*pfnamx_NumPublics)(AMX*, int*); // amx, number
int (*pfnamx_NumPubVars)(AMX*, int*); // amx, number
int (*pfnamx_NumTags)(AMX*, int*); // amx, number
int (*pfnamx_RaiseError)(AMX*, int ); // amx, error
int (*pfnamx_Register)(AMX*, AMX_NATIVE_INFO*, int ); // amx, nativelist, number
int (*pfnamx_Release)(AMX*, cell ); // amx, amx_addr
int (*pfnamx_SetCallback)(AMX*, AMX_CALLBACK ); // amx, callback
int (*pfnamx_SetDebugHook)(AMX*, AMX_DEBUG ); // amx, debug
int (*pfnamx_SetString)(cell*, char*, int ); // dest, source, pack
int (*pfnamx_SetUserData)(AMX*, long , void*); // amx, tag, prt
int (*pfnamx_StrLen)(cell*, int*); // amx, cstring, length
};
extern pfnamx_engine_g* g_engAmxFunc;
#define AMX_ALIGN16 (*g_engAmxFunc->pfnamx_Align16)
#define AMX_ALIGN32 (*g_engAmxFunc->pfnamx_Align32)
#define AMX_ALLOT (*g_engAmxFunc->pfnamx_Allot)
#define AMX_CALLBACK (*g_engAmxFunc->pfnamx_Callback)
#define AMX_CLONE (*g_engAmxFunc->pfnamx_Clone)
#define AMX_DEBUG (*g_engAmxFunc->pfnamx_Debug)
#define AMX_EXEC (*g_engAmxFunc->pfnamx_Exec)
#define AMX_EXECV (*g_engAmxFunc->pfnamx_Execv)
#define AMX_FINDPUBLIC (*g_engAmxFunc->pfnamx_FindPublic)
#define AMX_FINDPUBVAR (*g_engAmxFunc->pfnamx_FindPubVar)
#define AMX_FINDTAGID (*g_engAmxFunc->pfnamx_FindTagId)
#define AMX_FLAGS (*g_engAmxFunc->pfnamx_Flags)
#define AMX_GETADDR (*g_engAmxFunc->pfnamx_GetAddr)
#define AMX_GETPUBLIC (*g_engAmxFunc->pfnamx_GetPublic)
#define AMX_GETPUBVAR (*g_engAmxFunc->pfnamx_GetPubVar)
#define AMX_GETSTRING (*g_engAmxFunc->pfnamx_GetString)
#define AMX_GETTAG (*g_engAmxFunc->pfnamx_GetTag)
#define AMX_GETUSERDATA (*g_engAmxFunc->pfnamx_GetUserData)
#define AMX_INIT (*g_engAmxFunc->pfnamx_Init)
#define AMX_INITJIT (*g_engAmxFunc->pfnamx_InitJIT)
#define AMX_MEMINFO (*g_engAmxFunc->pfnamx_MemInfo)
#define AMX_NAMELENGTH (*g_engAmxFunc->pfnamx_NameLength)
#define AMX_NATIVEINFO (*g_engAmxFunc->pfnamx_NativeInfo)
#define AMX_NUMPUBLICS (*g_engAmxFunc->pfnamx_NumPublics)
#define AMX_NUMPUBVARS (*g_engAmxFunc->pfnamx_NumPubVars)
#define AMX_NUMTAGS (*g_engAmxFunc->pfnamx_NumTags)
#define AMX_RAISEERROR (*g_engAmxFunc->pfnamx_RaiseError)
#define AMX_REGISTER (*g_engAmxFunc->pfnamx_Register)
#define AMX_RELEASE (*g_engAmxFunc->pfnamx_Release)
#define AMX_SETCALLBACK (*g_engAmxFunc->pfnamx_SetCallback)
#define AMX_SETDEBUGHOOK (*g_engAmxFunc->pfnamx_SetDebugHook)
#define AMX_SETSTRING (*g_engAmxFunc->pfnamx_SetString)
#define AMX_SETUSERDATA (*g_engAmxFunc->pfnamx_SetUserData)
#define AMX_STRLEN (*g_engAmxFunc->pfnamx_StrLen)
// Modules API
struct pfnmodule_engine_g {
int (*pfnadd_amxnatives)(module_info_s*,AMX_NATIVE_INFO*); // list
char* (*pfnbuild_pathname)(char*, ...); // format, ....
void (*pfncopy_amxmemory)(cell*,cell*,int); // dest, src, len
char* (*pfnformat_amxstring)(AMX*, cell*, int ,int& ); // amx, format, start pos, len
cell* (*pfnget_amxaddr)(AMX*,cell ); // amx, cell
AMX* (*pfnget_amxscript)(int, void**,const char**); // id, code, name
const char* (*pfnget_amxscriptname)(AMX* amx); // amx
char* (*pfnget_amxstring)(AMX*,cell,int, int&); // amx, src, buffer (0-3), len
void (*pfnget_modname)(char*); // modname
int (*pfnload_amxscript)(AMX*, void**, const char*, char[64]); // amx, code, path, error info
void (*pfnprint_console)(char*, ...); // format, ....
void (*pfnreport_error)(int code, char*, ... );
int (*pfnset_amxnatives)(AMX*,char[64]); // amx, error info
int (*pfnset_amxstring)(AMX*,cell ,const char*,int); // amx, dest, string, maxlen
int (*pfnamxstring_length)(cell*); // src
int (*pfnunload_amxscript)(AMX* amx,void**); // amx, code
void* (*pfnalloc_amxmemory)(void**,int size);
void (*pfnfree_amxmemory)(void**);
};
extern pfnmodule_engine_g* g_engModuleFunc;
#define ADD_AMXNATIVES (*g_engModuleFunc->pfnadd_amxnatives)
#define AMXSTRING_LENGTH (*g_engModuleFunc->pfnamxstring_length)
#define BUILD_PATHNAME (*g_engModuleFunc->pfnbuild_pathname)
#define COPY_AMXMEMORY (*g_engModuleFunc->pfncopy_amxmemory)
#define FORMAT_AMXSTRING (*g_engModuleFunc->pfnformat_amxstring)
#define GET_AMXADDR (*g_engModuleFunc->pfnget_amxaddr)
#define GET_AMXSCRIPT (*g_engModuleFunc->pfnget_amxscript)
#define GET_AMXSCRIPTNAME (*g_engModuleFunc->pfnget_amxscriptname)
#define GET_AMXSTRING (*g_engModuleFunc->pfnget_amxstring)
#define GET_MODNAME (*g_engModuleFunc->pfnget_modname)
#define LOAD_AMXSCRIPT (*g_engModuleFunc->pfnload_amxscript)
#define PRINT_CONSOLE (*g_engModuleFunc->pfnprint_console)
#define REPORT_ERROR (*g_engModuleFunc->pfnreport_error)
#define SET_AMXNATIVES (*g_engModuleFunc->pfnset_amxnatives)
#define SET_AMXSTRING (*g_engModuleFunc->pfnset_amxstring)
#define UNLOAD_AMXSCRIPT (*g_engModuleFunc->pfnunload_amxscript)
#define ALLOC_AMXMEMORY (*g_engModuleFunc->pfnalloc_amxmemory)
#define FREE_AMXMEMORY (*g_engModuleFunc->pfnfree_amxmemory)
#endif // __MODULES_H__

6
amxmodx/msvc/amxmod_mm.def Executable file
View File

@ -0,0 +1,6 @@
LIBRARY amx_mm
EXPORTS
GiveFnptrsToDll @1
SECTIONS
.data READ WRITE

288
amxmodx/msvc/amxmod_mm.dsp Executable file
View File

@ -0,0 +1,288 @@
# Microsoft Developer Studio Project File - Name="amxmod_mm" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=amxmod_mm - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "amxmod_mm.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "amxmod_mm.mak" CFG="amxmod_mm - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "amxmod_mm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "amxmod_mm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "amxmod_mm - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "release"
# PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "amxmod_mm_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\metamod\metamod" /I "..\..\hlsdk\sourcecode\common" /I "..\..\hlsdk\sourcecode\engine" /I "..\..\hlsdk\sourcecode\dlls" /I "..\..\hlsdk\sourcecode\pm_shared" /I "..\extra\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "amxmod_mm_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /def:".\amxmod_mm.def" /out:"release/amx_mm.dll" /libpath:"..\extra\lib_win32"
# Begin Custom Build
TargetPath=.\release\amx_mm.dll
TargetName=amx_mm
InputPath=.\release\amx_mm.dll
SOURCE="$(InputPath)"
"$(TargetName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetPath) D:\SIERRA\Half-Life\cstrike\addons\amx\dlls
# End Custom Build
!ELSEIF "$(CFG)" == "amxmod_mm - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "debug"
# PROP Intermediate_Dir "debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "amxmod_mm_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /Zp4 /MTd /W3 /Gm /GX /ZI /Od /I "..\..\metamod\metamod" /I "..\...\hlsdk\sourcecode\common" /I "..\...\hlsdk\sourcecode\engine" /I "..\...\hlsdk\sourcecode\dlls" /I "..\...\hlsdk\sourcecode\pm_shared" /I "..\extra\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "amxmod_mm_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /def:".\amxmod_mm.def" /out:"debug/amx_mm.dll" /pdbtype:sept /libpath:"..\extra\lib_win32"
# SUBTRACT LINK32 /incremental:no /nodefaultlib
# Begin Custom Build
TargetPath=.\debug\amx_mm.dll
TargetName=amx_mm
InputPath=.\debug\amx_mm.dll
SOURCE="$(InputPath)"
"$(TargetName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetPath) D:\SIERRA\Half-Life\cstrike\addons\amx\dlls
# End Custom Build
!ENDIF
# Begin Target
# Name "amxmod_mm - Win32 Release"
# Name "amxmod_mm - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\amx.c
# End Source File
# Begin Source File
SOURCE=..\amxcore.c
# End Source File
# Begin Source File
SOURCE=..\amxmod.cpp
# End Source File
# Begin Source File
SOURCE=..\amxtime.c
# End Source File
# Begin Source File
SOURCE=..\CCmd.cpp
# End Source File
# Begin Source File
SOURCE=..\CEvent.cpp
# End Source File
# Begin Source File
SOURCE=..\CFile.cpp
# End Source File
# Begin Source File
SOURCE=..\CForward.cpp
# End Source File
# Begin Source File
SOURCE=..\CLogEvent.cpp
# End Source File
# Begin Source File
SOURCE=..\CMenu.cpp
# End Source File
# Begin Source File
SOURCE=..\CMisc.cpp
# End Source File
# Begin Source File
SOURCE=..\CModule.cpp
# End Source File
# Begin Source File
SOURCE=..\CPlugin.cpp
# End Source File
# Begin Source File
SOURCE=..\CString.cpp
# End Source File
# Begin Source File
SOURCE=..\CTask.cpp
# End Source File
# Begin Source File
SOURCE=..\CVault.cpp
# End Source File
# Begin Source File
SOURCE=..\emsg.cpp
# End Source File
# Begin Source File
SOURCE=..\file.cpp
# End Source File
# Begin Source File
SOURCE=..\float.cpp
# End Source File
# Begin Source File
SOURCE=..\meta_api.cpp
# End Source File
# Begin Source File
SOURCE=..\modules.cpp
# End Source File
# Begin Source File
SOURCE=..\power.c
# End Source File
# Begin Source File
SOURCE=..\srvcmd.cpp
# End Source File
# Begin Source File
SOURCE=..\string.cpp
# End Source File
# Begin Source File
SOURCE=..\strptime.cpp
# End Source File
# Begin Source File
SOURCE=..\util.cpp
# End Source File
# Begin Source File
SOURCE=..\vault.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\amxmod.h
# End Source File
# Begin Source File
SOURCE=..\CCmd.h
# End Source File
# Begin Source File
SOURCE=..\CEvent.h
# End Source File
# Begin Source File
SOURCE=..\CFile.h
# End Source File
# Begin Source File
SOURCE=..\CForward.h
# End Source File
# Begin Source File
SOURCE=..\CList.h
# End Source File
# Begin Source File
SOURCE=..\CLogEvent.h
# End Source File
# Begin Source File
SOURCE=..\CMenu.h
# End Source File
# Begin Source File
SOURCE=..\CMisc.h
# End Source File
# Begin Source File
SOURCE=..\CModule.h
# End Source File
# Begin Source File
SOURCE=..\CPlugin.h
# End Source File
# Begin Source File
SOURCE=..\CString.h
# End Source File
# Begin Source File
SOURCE=..\CTask.h
# End Source File
# Begin Source File
SOURCE=..\CVault.h
# End Source File
# Begin Source File
SOURCE=..\modules.h
# End Source File
# End Group
# End Target
# End Project

29
amxmodx/msvc/amxmod_mm.dsw Executable file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "amxmod_mm"=.\amxmod_mm.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

60
amxmodx/osdefs.h Executable file
View File

@ -0,0 +1,60 @@
/* __MSDOS__ set when compiling for DOS (not Windows)
* _Windows set when compiling for any version of Microsoft Windows
* __WIN32__ set when compiling for Windows95 or WindowsNT (32 bit mode)
* __32BIT__ set when compiling in 32-bit "flat" mode (DOS or Windows)
*
* Copyright 1998-2002, ITB CompuPhase, The Netherlands.
* info@compuphase.com.
*/
#ifndef _OSDEFS_H
#define _OSDEFS_H
/* Every compiler uses different "default" macros to indicate the mode
* it is in. Throughout the source, we use the Borland C++ macros, so
* the macros of Watcom C/C++ and Microsoft Visual C/C++ are mapped to
* those of Borland C++.
*/
#if defined(__WATCOMC__)
# if defined(__WINDOWS__) || defined(__NT__)
# define _Windows 1
# endif
# ifdef __386__
# define __32BIT__ 1
# endif
# if defined(_Windows) && defined(__32BIT__)
# define __WIN32__ 1
# endif
#elif defined(_MSC_VER)
# if defined(_WINDOWS) || defined(_WIN32)
# define _Windows 1
# endif
# ifdef _WIN32
# define __WIN32__ 1
# define __32BIT__ 1
# endif
#endif
#if defined __linux__
#include <endian.h>
#endif
/* Linux NOW has these */
#if !defined BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
#if !defined LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif
/* educated guess, BYTE_ORDER is undefined, i386 is common => little endian */
#if !defined BYTE_ORDER
#if defined UCLINUX
#define BYTE_ORDER BIG_ENDIAN
#else
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#endif
#endif /* _OSDEFS_H */

42
amxmodx/power.c Executable file
View File

@ -0,0 +1,42 @@
/* This file implements two native functions. It is provided as
* an example to show how to add native functions. See the manual
* for more information.
*
* Copyright (c) ITB CompuPhase, 1998, 1999
* This file may be freely used. No warranties of any kind.
*/
#include "amx.h"
static cell power(AMX *amx, cell *params)
{
/* power(value, exponent);
* params[1] = value
* params[2] = exponent
*/
cell result = 1;
while (params[2]-- > 0)
result *= params[1];
return result;
}
static cell sqroot(AMX *amx, cell *params)
{
/* sqroot(value);
* params[1] = value
* This routine uses a simple successice approximation algorithm.
*/
cell div = params[1];
cell result = 1;
while (div > result) { /* end when div == result, or just below */
div = (div + result) / 2; /* take mean value as new divisor */
result = params[1] / div;
} /* while */
return div;
}
AMX_NATIVE_INFO power_Natives[] = {
{ "power", power },
{ "sqroot", sqroot },
{ 0, 0 } /* terminator */
};

48
amxmodx/sclinux.h Executable file
View File

@ -0,0 +1,48 @@
/*
* Things needed to compile under linux.
*
* Should be reworked totally to use GNU's 'configure'
*/
/*
* Getchar is not a 'cool' replacement for MSDOS getch: Linux/unix depends on the features activated or not about the
* controlling terminal's tty. This means that ioctl(2) calls must be performed, for instance to have the controlling terminal tty's
* in 'raw' mode, if we want to be able to fetch a single character. This also means that everything must be put back
* correctly when the program ends.
*
* For interactive use of SRUN/SDBG if would be much better to use GNU's readline package: the user would be able to have
* a complete emacs/vi like line editing system.
*
* So we stick to getchar at the moment... (one needs to key ctrl-d to terminate input if getch is called with a controlling
* terminal driven by a tty having -raw)
*/
#define getch getchar
#define stricmp(a,b) strcasecmp(a,b)
#define strnicmp(a,b,c) strncasecmp(a,b,c)
/*
* WinWorld wants '\'. Unices do not.
*/
#define DIRECTORY_SEP_CHAR '/'
#define DIRECTORY_SEP_STR "/"
/*
* SC assumes that a computer is Little Endian unless told otherwise. It uses
* (and defines) the macros BYTE_ORDER and BIG_ENDIAN.
* For Linux, we must overrule these settings with those defined in glibc.
*/
#if !defined __BYTE_ORDER
# include <stdlib.h>
#endif
#if defined __OpenBSD__
# define __BYTE_ORDER BYTE_ORDER
# define __LITTLE_ENDIAN LITTLE_ENDIAN
# define __BIG_ENDIAN BIG_ENDIAN
#endif
#if !defined __BYTE_ORDER
# error "Can't figure computer byte order (__BYTE_ORDER macro not found)"
#endif

228
amxmodx/srvcmd.cpp Executable file
View File

@ -0,0 +1,228 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
void amx_command(){
const char* cmd = CMD_ARGV(1);
if (!strcmp(cmd,"plugins") || !strcmp(cmd,"list"))
{
print_srvconsole( "Currently loaded plugins:\n");
print_srvconsole( " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n",
"name","version","author","file","status");
int plugins = 0;
int running = 0;
CPluginMngr::iterator a = g_plugins.begin();
while (a)
{
++plugins;
if ( (*a).isValid() && !(*a).isPaused() )
++running;
print_srvconsole( " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n",
plugins,(*a).getTitle(),(*a).getVersion(),
(*a).getAuthor(), (*a).getName(), (*a).getStatus() );
++a;
}
print_srvconsole( "%d plugins, %d running\n",plugins,running );
}
else if (!strcmp(cmd,"pause") && CMD_ARGC() > 2)
{
const char* sPlugin = CMD_ARGV(2);
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
if ( plugin && plugin->isValid() )
{
plugin->pausePlugin();
print_srvconsole("Paused plugin \"%s\"\n",plugin->getName() );
}
else print_srvconsole("Couldn't find plugin matching \"%s\"\n",sPlugin);
}
else if (!strcmp(cmd,"unpause") && CMD_ARGC() > 2)
{
const char* sPlugin = CMD_ARGV(2);
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
if ( plugin && plugin->isValid() )
{
plugin->unpausePlugin();
print_srvconsole("Unpaused plugin \"%s\"\n",plugin->getName() );
}
else print_srvconsole("Couldn't find plugin matching \"%s\"\n",sPlugin);
}
else if (!strcmp(cmd,"cvars"))
{
print_srvconsole( "Registered cvars:\n");
print_srvconsole( " %-24.23s %-24.23s %-16.15s\n",
"name","value","plugin");
int ammount = 0;
for( CList<CCVar>::iterator a = g_cvars.begin(); a ; ++a )
{
print_srvconsole( " [%3d] %-24.23s %-24.23s %-16.15s\n",++ammount,
(*a).getName() ,CVAR_GET_STRING( (*a).getName() ),(*a).getPluginName() );
}
print_srvconsole( "%d cvars\n",ammount);
}
else if ( !strcmp(cmd,"cmds") )
{
print_srvconsole( "Registered commands:\n");
print_srvconsole( " %-24.23s %-16.15s %-8.7s %-16.15s\n",
"name","access" ,"type" ,"plugin");
int ammount = 0;
char access[32];
CmdMngr::iterator a = g_commands.begin( CMD_ConsoleCommand );
while( a )
{
UTIL_GetFlags( access , (*a).getFlags() );
print_srvconsole( " [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n",
++ammount,(*a).getCmdLine() , access , (*a).getCmdType() , (*a).getPlugin()->getName());
++a;
}
print_srvconsole( "%d commands\n",ammount);
}
else if (!strcmp(cmd,"version"))
{
print_srvconsole( "%s %s\n", Plugin_info.name, Plugin_info.version);
print_srvconsole( "author: %s (%s)\n", Plugin_info.author, Plugin_info.url);
print_srvconsole( "compiled: %s\n", __DATE__ ", " __TIME__);
}
else if (!strcmp(cmd,"modules"))
{
print_srvconsole( "Currently loaded modules:\n");
print_srvconsole( " %-23.22s %-7.8s %-8.7s %-20.19s %-11.10s\n",
"name","type","version", "author", "status");
int running = 0;
int modules = 0;
CList<CModule>::iterator a = g_modules.begin();
while ( a )
{
if ( (*a).getStatusValue() == MODULE_LOADED )
++running;
++modules;
print_srvconsole( " [%2d] %-23.22s %-7.6s %-8.7s %-20.19s %-11.10s\n",modules,
(*a).getName(), (*a).getType(), (*a).getVersion(), (*a).getAuthor() , (*a).getStatus() );
++a;
}
print_srvconsole( "%d modules, %d correct\n",modules,running);
}
else
{
print_srvconsole("Usage: amx < command > [ argument ]\n");
print_srvconsole("Commands:\n");
print_srvconsole(" version - display amx version info\n");
print_srvconsole(" plugins - list plugins currently loaded\n");
print_srvconsole(" modules - list modules currently loaded\n");
print_srvconsole(" cvars - list cvars registered by plugins\n");
print_srvconsole(" cmds - list commands registered by plugins\n");
print_srvconsole(" pause < plugin > - pause a running plugin\n");
print_srvconsole(" unpause < plugin > - unpause a previously paused plugin\n");
}
}
void plugin_srvcmd()
{
cell ret = 0;
int err;
const char* cmd = CMD_ARGV(0);
#ifdef ENABLEEXEPTIONS
try{
#endif
CmdMngr::iterator a = g_commands.srvcmdbegin();
while ( a )
{
if ( (*a).matchCommand( cmd ) &&
(*a).getPlugin()->isExecutable( (*a).getFunction() ) )
{
if ((err = amx_Exec( (*a).getPlugin()->getAMX(), &ret , (*a).getFunction()
, 3 , g_srvindex , (*a).getFlags() , (*a).getId() )) != AMX_ERR_NONE)
print_srvconsole("[AMX] Run time error %d on line %ld (plugin \"%s\")\n",
err,(*a).getPlugin()->getAMX()->curline,(*a).getPlugin()->getName());
if ( ret ) break;
}
++a;
}
#ifdef ENABLEEXEPTIONS
}catch( ... )
{
print_srvconsole( "[AMX] fatal error at forward function execution\n");
}
#endif
}

541
amxmodx/string.cpp Executable file
View File

@ -0,0 +1,541 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include <ctype.h>
#include "amxmod.h"
const char* stristr(const char* str,const char* substr)
{
register char *needle = (char *)substr;
register char *prevloc = (char *)str;
register char *haystack = (char *)str;
while (*haystack) {
if (tolower(*haystack) == tolower(*needle)) {
haystack++;
if (!*++needle)
return prevloc;
}
else {
haystack = ++prevloc;
needle = (char *)substr;
}
}
return NULL;
}
char* format_amxstring(AMX *amx, cell *params, int parm,int& len)
{
static char buffer[2][3072];
static char format[16];
char *ptr,*arg;
char *dest = *buffer;
cell *src = get_amxaddr(amx, params[parm++]);
int numparam = *params/sizeof(cell);
while(*src) {
if (*src=='%'&&*(src+1)) {
ptr = format;
*ptr++ = *src++;
if (*src=='%'){
*dest++=*src++;
continue;
}
while (!isalpha(*ptr++=*src++))
;
*ptr=0;
if (numparam < parm) continue;
arg = buffer[1];
switch(*(ptr-1)){
case 's': sprintf(arg,format,get_amxstring(amx, params[parm++],2,len)); break;
case 'f': case 'g': sprintf(arg,format,*(float*)get_amxaddr(amx, params[parm++])); break;
default: sprintf(arg,format,(int)*get_amxaddr(amx, params[parm++]));
}
while(*arg) *dest++=*arg++;
continue;
}
*dest++=*src++;
}
*dest=0;
len = dest - *buffer;
return *buffer;
}
int amxstring_len(cell* a)
{
register int c = 0;
while( a[ c ] )
++c;
return c;
}
cell* get_amxaddr(AMX *amx,cell amx_addr)
{
return (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
}
int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max)
{
cell* dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
cell* start = dest;
while (max--&&*source)
*dest++=(cell)*source++;
*dest = 0;
return dest-start;
}
char* get_amxstring(AMX *amx,cell amx_addr,int id, int& len)
{
static char buffor[4][3072];
register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
register char* dest = buffor[id];
char* start = dest;
while (*dest++=(char)*source++)
;
len = --dest - start;
return start;
}
void copy_amxmemory(cell* dest,cell* src,int len)
{
while (len--)
*dest++=*src++;
}
char* parse_arg(char** line,int& state)
{
static char arg[3072];
char* dest = arg;
state = 0;
while(**line) {
if ( isspace(**line) ) {
if (state == 1)
break;
else if (!state) {
(*line)++;
continue;
}
}
else if (state != 2)
state = 1;
if (**line=='"') {
(*line)++;
if (state == 2)
break;
state = 2;
continue;
}
*dest++ = *(*line)++;
}
*dest = '\0';
return arg;
}
static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
{
static char buffor[3072];
cell *a = get_amxaddr(amx,params[1]);
cell *b = get_amxaddr(amx,params[3]);
cell *c = get_amxaddr(amx,params[4]);
int iMain = amxstring_len(a);
int iWhat = amxstring_len(b);
int iWith = amxstring_len(c);
int iPot = iMain + iWith - iWhat;
if (iPot>=params[2]){
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
char *d = buffor;
cell *x, *y, *z = a, *l = a;
int p = 0;
while(*a){
if (*a==*b){
x=a+1;
y=b+1;
p=1;
if (!*y) break;
while(*x==*y){
x++; y++; p++;
if (!*y) break;
}
if (!*y) break;
p = 0;
*d++=(char)*a++;
continue;
}
*d++=(char)*a++;
}
if (p){
while(*c) *d++=(char)*c++;
a+=p;
while(*a) *d++=(char)*a++;
*d=0;
d = buffor;
while(*d) *z++=*d++;
*z=0;
return (z-l);
}
return 0;
}
static cell AMX_NATIVE_CALL contain(AMX *amx, cell *params) /* 2 param */
{
register cell *a = get_amxaddr(amx,params[2]);
register cell *b = get_amxaddr(amx,params[1]);
register cell *c = b;
cell* str = b;
cell* substr = a;
while (*c) {
if (*c == *a) {
c++;
if (!*++a)
return b - str;
}
else {
c = ++b;
a = substr;
}
}
return -1;
}
static cell AMX_NATIVE_CALL containi(AMX *amx, cell *params) /* 2 param */
{
register cell *a = get_amxaddr(amx,params[2]);
register cell *b = get_amxaddr(amx,params[1]);
register cell *c = b;
cell* str = b;
cell* substr = a;
while (*c) {
if (tolower(*c) == tolower(*a)) {
c++;
if (!*++a)
return b - str;
}
else {
c = ++b;
a = substr;
}
}
return -1;
}
static cell AMX_NATIVE_CALL strtonum(AMX *amx, cell *params) /* 1 param */
{
int iLen;
return atoi(get_amxstring(amx,params[1],0,iLen));
}
static cell AMX_NATIVE_CALL numtostr(AMX *amx, cell *params) /* 3 param */
{
char szTemp[32];
sprintf(szTemp,"%d",(int)params[1]);
return set_amxstring(amx,params[2],szTemp,params[3]);
}
static cell AMX_NATIVE_CALL add(AMX *amx, cell *params) /* 4 param */
{
cell *src = get_amxaddr(amx,params[3]);
cell *dest = get_amxaddr(amx,params[1]);
cell *start = dest;
int c = params[2], d = params[4];
while(*dest&&c--)
++dest;
if (d){
while(c--&&d--&&*src)
*dest++=*src++;
*dest=0;
return (dest-start);
}
while(c--&&*src)
*dest++=*src++;
*dest=0;
return (dest-start);
}
static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */
{
cell *src = get_amxaddr(amx,params[3]);
cell *dest = get_amxaddr(amx,params[1]);
cell *start = dest;
int c = params[2];
while(c--&&*src)
*dest++=*src++;
*dest=0;
return (dest-start);
}
static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */
{
cell *src = get_amxaddr(amx,params[3]);
cell *dest = get_amxaddr(amx,params[1]);
cell *start = dest;
int c = params[2];
cell ch = params[4];
while(c--&&*src&&*src!=ch)
*dest++=*src++;
*dest=0;
return (dest-start);
}
static cell AMX_NATIVE_CALL setc(AMX *amx, cell *params) /* 4 param */
{
cell *src = get_amxaddr(amx,params[1]);
int c = params[2];
cell ch = params[3];
while(c--)
*src++=ch;
return 1;
}
static cell AMX_NATIVE_CALL equal(AMX *amx, cell *params) /* 3 param */
{
cell *a = get_amxaddr(amx,params[1]);
cell *b = get_amxaddr(amx,params[2]);
int c = params[3];
if (c) {
while (--c&&*a&&(*a==*b))
++a, ++b;
return (*a-*b)?0:1;
}
int ret;
while(!(ret=*a-*b)&&*b)
++a, ++b;
return ret?0:1;
}
static cell AMX_NATIVE_CALL equali(AMX *amx, cell *params) /* 3 param */
{
cell *a = get_amxaddr(amx,params[1]);
cell *b = get_amxaddr(amx,params[2]);
int f,l, c = params[3];
if (c) {
do {
f = tolower(*a++);
l = tolower(*b++);
}
while (--c &&l&&f&& f==l);
return(f - l)?0:1;
}
do {
f = tolower(*a++);
l = tolower(*b++);
} while (f && f == l);
return (f - l)?0:1;
}
static cell AMX_NATIVE_CALL format(AMX *amx, cell *params) /* 3 param */
{
int len;
return set_amxstring(amx,params[1],format_amxstring(amx,params,3,len),params[2]);
}
static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
{
int inum = *params/sizeof(cell), iarg = 2, c;
char* arg, *parse = get_amxstring(amx,params[1],0,c);
cell *cptr;
int state;
while(*parse){
arg = parse_arg(&parse,state);
if (state){
if (inum <= iarg)
return( (iarg-2)>>1 );
cptr = get_amxaddr(amx,params[iarg++]);
c = *get_amxaddr(amx,params[iarg++]);
while(c--&&*arg)
*cptr++=(cell)*arg++;
*cptr=0;
}
}
return( (iarg-2)>>1 );
}
static cell AMX_NATIVE_CALL strtolower(AMX *amx, cell *params) /* 1 param */
{
cell *cptr = get_amxaddr(amx,params[1]);
cell *begin = cptr;
while(*cptr){
*cptr = tolower(*cptr);
cptr++;
}
return cptr - begin;
}
static cell AMX_NATIVE_CALL strtoupper(AMX *amx, cell *params) /* 1 param */
{
cell *cptr = get_amxaddr(amx,params[1]);
cell *begin = cptr;
while(*cptr){
*cptr = toupper(*cptr);
cptr++;
}
return cptr - begin;
}
int fo_numargs(AMX *amx)
{
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat;
cell bytes= * (cell *)(data+(int)amx->frm+2*sizeof(cell));
return (int)(bytes/sizeof(cell));
}
int fo_getargnum(AMX *amx, int pos)
{
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat;
cell value = * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell));
return *(cell *)(data+(int)value);
}
float fo_getargfloat(AMX *amx, int pos)
{
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat;
cell value = * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell));
cell number = *(cell *)(data+(int)value);
return *(float *)((void *)&number);
}
char* fo_getargstr(AMX *amx, int swap, int pos)
{
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat;
cell src_value= * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell));
cell value;
static char buffer[2][3072];
char* b = buffer[swap];
int a = 0;
do {
value = src_value + a++ * sizeof(cell);
value = *(cell *)(data+(int)value);
*b++ = value;
} while (value);
return buffer[swap];
}
char* format_arguments(AMX *amx, int parm,int& len)
{
static char buffer[2][3072];
static char format[16];
char *ptr,*arg, *dest = *buffer;
char *src = fo_getargstr(amx, 0,parm++);
int numparam = fo_numargs(amx);
while(*src) {
if (*src=='%'&&*(src+1)) {
ptr = format;
*ptr++ = *src++;
if (*src=='%'){
*dest++=*src++;
continue;
}
while (!isalpha(*ptr++=*src++))
;
*ptr='\0';
if (numparam < parm) continue;
arg = buffer[1];
switch(*(ptr-1)){
case 's': sprintf(arg,format,fo_getargstr(amx,1, parm++)); break;
case 'f': case 'g': sprintf(arg,format,fo_getargfloat(amx, parm++)); break;
default: sprintf(arg,format,fo_getargnum(amx, parm++));
}
while(*arg) *dest++=*arg++;
continue;
}
*dest++=*src++;
}
*dest='\0';
len = dest - *buffer;
return *buffer;
}
static cell AMX_NATIVE_CALL format_args(AMX *amx, cell *params)
{
int len;
int pos = params[3];
if (pos < 0){
amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0;
}
char* string = format_arguments(amx, pos ,len); // indexed from 0
return set_amxstring(amx,params[1],string,params[2]);
}
static cell AMX_NATIVE_CALL is_digit(AMX *amx, cell *params)
{
return isdigit( params[1] );
}
static cell AMX_NATIVE_CALL is_alnum(AMX *amx, cell *params)
{
return isalnum( params[1] );
}
static cell AMX_NATIVE_CALL is_space(AMX *amx, cell *params)
{
return isspace( params[1] );
}
static cell AMX_NATIVE_CALL is_alpha(AMX *amx, cell *params)
{
return isalpha( params[1] );
}
AMX_NATIVE_INFO string_Natives[] = {
{ "add", add },
{ "contain", contain },
{ "containi", containi },
{ "copy", copy },
{ "copyc", copyc },
{ "equal", equal },
{ "equali", equali },
{ "format", format },
{ "format_args", format_args },
{ "isdigit", is_digit },
{ "isalnum", is_alnum },
{ "isspace", is_space },
{ "isalpha", is_alpha },
{ "numtostr", numtostr },
{ "num_to_str", numtostr },
{ "parse", parse },
{ "replace", replace },
{ "setc", setc },
{ "strtolower", strtolower },
{ "strtonum", strtonum },
{ "strtoupper", strtoupper },
{ "str_to_num", strtonum },
{ NULL, NULL }
};

398
amxmodx/strptime.cpp Executable file
View File

@ -0,0 +1,398 @@
/** strptime.c **********************************************************
Locales' support for DOS / Win31 / Win32.
Copyright (c) 1995-1997 by Timofei Bondarenko <tim@ipi.ac.ru>
Localized strptime().
*-----------------------------------------------------------------------*/
//#include "config.h"
#include <time.h>
#include <ctype.h>
#include <string.h>
#ifdef __linux__
#define strnicmp strncasecmp
#endif
const char *_lc_Wday_ [2][ 7],
*_lc_Month_[2][12],
*_lc_AmPm_ [2][ 2];
const char *_lc_fmt_c_[2],
*_lc_fmt_xD[2],
*_lc_fmt_XT[2];
int _lc_Txt_, /* 0="C", 1="Local Win"/"Rus DOS" Wday, Months, AmPm */
_lc_Fmt_; /* 0="C", 1="Local", for formats %c %x %X */
//#include "_locale.h"
struct tm_int
{
int qS, /* Seconds (0...61) */
qM, /* Minutes (0...59) */
qH, /* Hour (0...23) */
qI, /* Hour (1...12) */
qp, /* 0 = AM, 1 = PM */
qd, /* Day of month (1...31)=>[0...30] */
qm, /* Month (1...12)=>[0...11] */
qY, /* Year (0...9999) */
qy, /* year (0...99) */
qC, /* Century (0...99) */
qw, /* Weekday (0...6; Sunday = 0) */
qj, /* Day of year (1..366)=>[0...365] */
qZ, /* 0 = STD, 1 = DST */
qU, /* week in year (0...53) */
qV; /* week in year mode: 'U', 'W', 'V' */
};
/* skips spaces in `strp`. Returns 0 if no spaces skipped */
static void skip_sp(const unsigned char **strp)
{
while(isspace(**strp)) (*strp)++;
}
/* scans no more decimal digits than contained in `max` as an integer,
sign isn't allowed. Returns -1 if 0 digits scanned or
if the scanned number is greater than `max`. */
static int scan_int(const unsigned char **strp, int max)
{
int cc, val, pos;
skip_sp(strp);
for(val = pos = 0; pos < max && isdigit(cc = **strp); (*strp)++)
{
pos = pos * 10 + 9;
if ((val = val * 10 + (cc - '0')) > max) return -1;
/*val = val * 10 + (cc - '0');*/
}
return pos? val: -1;
}
static int scan_int2(const unsigned char **strp)
{
int cc, val, pos;
skip_sp(strp);
for(val = pos = 0; isdigit(cc = **strp); (*strp)++)
{
pos = pos * 10 + 9;
val = val * 10 + (cc - '0');
}
return pos? val: -1;
}
/* scans one word which is equivalence (case insensitive) to a
word from list `n_full` or from list `n_short` or when
n_short is NULL to first 3 characters from a word from `n_full`.
`max` is number of words in each list `n_full` or `n_short`.
Returns the index in a list >= 0 and < `max`, or -1 if no word found. */
static int scan_word_(const unsigned char **strp,
int max, const char *const *n_full
#if USE_ABBR_NAMES
, const char *const *n_short
#endif
)
{
int ix, l_max = 100;
int found, found_len;
const char *const *word_list;
found = found_len = -1;
skip_sp(strp); /* Required? Or Not? */
Scan0:
word_list = n_full;
/*Scan1:*/
for(ix = 0; ix < max; word_list++, ix++)
{
int len;
const char *word = *word_list;
skip_sp((const unsigned char**)&word);
if (l_max < (len = strlen(word))) len = l_max;
if (found_len < len && /* search for maximal lenth */
(!len || /* at least "" always founded */
!strnicmp((const char*)*strp, word, len))) /* found */
found_len = len, found = ix;
}
if (l_max >= 100) /* first pass: full names */
{ /* go to second pass: short names */
#if USE_ABBR_NAMES
if (n_short)
{
l_max--; word_list = n_short; goto Scan1;
}
#endif
l_max = 3; goto Scan0;
}
if (found_len > 0) (*strp) += found_len;
return found; /* -1 or index or first "" */
}
#if USE_ABBR_NAMES
#define scan_word scan_word_ /* pass all arguments as is */
#else
#define scan_word(str,max,n_full,n_short) scan_word_(str,max,n_full)
#endif
static int time_int(struct tm_int *ti,
const unsigned char **buf, const char *fmt, short addthem)
{
int ii;
for(; (ii = (unsigned char)*fmt); fmt++)
if (ii != '%')
{
Other:
if (isspace(ii))
{
/*SkipSp:*/ fmt++; skip_sp((const unsigned char **)&fmt);
fmt--; skip_sp(buf);
} /* toupper(ii) != toupper(**buf) */
/*else if (_lc_igncase[ii] != _lc_igncase[**buf]) return -1;*/
else (*buf)++;
}
else
{
const char *fs;
/*Fmt:*/ switch(ii = (unsigned char)*++fmt)
{
case 0 : goto FmtEnd;
case 'a':
case 'A':
ti->qw = ii = scan_word(buf, 7,
_lc_Wday_[_lc_Txt_],
_lc_Txt_? _lc_WdayS: NULL); break;
case 'h': /* STRFTIME_EXT */
case 'b':
case 'B':
ti->qm = ii = scan_word(buf, 12,
_lc_Month_[_lc_Txt_],
_lc_Txt_? _lc_MonthS: NULL); break;
case 'c':
fs = _lc_fmt_c_[_lc_Fmt_];
strpt: ii = time_int(ti, buf, fs, addthem); break;
#if STRFTIME_EXT
case 'C': /* STRFTIME_EXT */
ti->qC = ii = addthem ? scan_int2(buf) : scan_int(buf,99);
if (ti->qy >= 0) goto SetYear;
else if (ti->qY >= 0)
{
ti->qY = ti->qY % 100 + ii * 100;
goto CleanCy;
}
break;
case 'e': /* STRFTIME_EXT */
#endif
case 'd':
ti->qd = ii = (addthem ? scan_int2(buf) : scan_int(buf, 31)) - 1; break;
#if STRFTIME_EXT
case 'D': /* STRFTIME_EXT */
fs = _lc_fmt_xD[0]; goto strpt;
/* case 'E': STRFTIME_EXT "Era specefic" see %'O' */
/* case 'h': STRFTIME_EXT see %'b' */
#endif
case 'H':
ti->qH = ii = addthem ? scan_int2(buf) : scan_int(buf, 23);
CleanIp: ti->qI = ti->qp = -1; break;
case 'I':
ti->qI =
ti->qH = ii = addthem ? scan_int2(buf) : scan_int(buf, 23);
if (ii == 0 || ii > 12) goto CleanIp;
else ti->qH = -1;
break;
case 'j':
ti->qj = ii = (addthem ? scan_int2(buf) : scan_int(buf, 366)) - 1;
ti->qU = -1; break;
case 'm':
ti->qm = ii = (addthem ? scan_int2(buf) : scan_int(buf, 12)) - 1; break;
case 'M':
ti->qM = ii = addthem ? scan_int2(buf) : scan_int(buf, 59); break;
#if STRFTIME_EXT
case 'n': /* STRFTIME_EXT */
case 't': /* STRFTIME_EXT */ goto SkipSp;
case 'N': /* STRFTIME_EXT */
fs = _lc_fmt_N_; goto strpt;
case 'E': /* STRFTIME_EXT "Era specefic" */
#endif
#if STRFTIME_EXT | STRFTIME_WIN
case 'O': /* STRFTIME_EXT "Alternate digits" */
goto Fmt;
#endif
case 'p':
ti->qp = /*ii =*/ scan_word(buf, 2, _lc_AmPm_[_lc_Txt_], NULL);
break;
#if STRFTIME_EXT
case 'r': /* STRFTIME_EXT */
fs = _lc_fmt_rI; goto strpt;
case 'R': /* STRFTIME_EXT */
fs = _lc_fmt_RH; goto strpt;
#endif
case 'S':
ti->qS = ii = addthem ? scan_int2(buf) : scan_int(buf, 61); break;
#if STRFTIME_EXT
case 'T': /* STRFTIME_EXT */
fs = _lc_fmt_XT[0]; goto strpt;
case 'u': /* STRFTIME_EXT */
ti->qw = ii = addthem ? scan_int2(buf) : scan_int(buf, 7);
if (ii == 7) ti->qw = 0;
else if (!ii) ii--;
break;
#endif
#if STRFTIME_EXT && 0
case 'V': /* STRFTIME_EXT 0 = Wednesday ?(Thursday) */
#endif
case 'U':
case 'W':
ti->qV = ii;
ti->qU = ii = addthem ? scan_int2(buf) : scan_int(buf, 53); break;
case 'w':
ti->qw = ii = addthem ? scan_int2(buf) : scan_int(buf, 6); break;
case 'x':
fs = _lc_fmt_xD[_lc_Fmt_]; goto strpt;
case 'X':
fs = _lc_fmt_XT[_lc_Fmt_]; goto strpt;
case 'y':
ti->qy = ii = addthem ? scan_int2(buf) : scan_int(buf, 99);
#if STRFTIME_EXT
if (ti->qC >= 0)
{
SetYear: ti->qY = ti->qC * 100 + ti->qy;
goto CleanCy;
}
#endif
if (ti->qY >= 0)
{
ti->qY = ti->qY - ti->qY % 100 + ii;
goto CleanCy;
}
break;
case 'Y':
ti->qY = ii = addthem ? scan_int2(buf) : scan_int(buf, 9999);
CleanCy: ti->qC = ti->qy = -1; break;
#if STRFTIME_EXT
case 'Z': /* STRFTIME_EXT */
ti->qZ = ii = scan_word(buf, /*!daylight? 1:*/ 2, tzname, NULL) +1;
if (!ii)
while((ii = **buf) && !isspace(ii)
/*&& !isdigit(ii) && !strchr("+-,", ii)*/
) (*buf)++;
break;
#endif
/* case '%': */
default: /**************************/ goto Other;
} /* end of switch() */
if (ii < 0) return -1;
} /* end of else, for() */
FmtEnd:
return 0;
}
typedef void (*specoper)(int* one, int two);
void justreplace(int* one, int two){
*one = two;
}
void justadd(int* one, int two){
*one += two;
}
char *strptime(const char *buf, const char *fmt, struct tm *tm, short addthem)
{
specoper defoper = addthem ? justadd : justreplace;
struct tm_int ti;
ti.qS = /* Seconds (0...61) */
ti.qM = /* Minutes (0...59) */
ti.qH = /* Hour (0...23) */
ti.qI = /* Hour (1...12) */
ti.qp = /* 0 = AM, 1 = PM */
ti.qd = /* Day of month (1...31)=>[0...30] */
ti.qm = /* Month (1...12)=>[0...11] */
ti.qY = /* Year (0...9999) */
ti.qy = /* year (0...99) */
ti.qC = /* Century (0...99) */
ti.qw = /* Weekday (0...6; Sunday = 0) */
ti.qj = /* Day of year (1..366)=>[0...365] */
ti.qZ = /* 0 = STD, 1 = DST */
ti.qU = /* week in year (0...53) */
ti.qV = -1; /* week in year mode: 0=U, 1=W, 2=V */
if (0 > time_int(&ti, (const unsigned char **)&buf, fmt, addthem)) buf = NULL;
if (0 <= ti.qS) (*defoper) ( &tm->tm_sec , ti.qS );
if (0 <= ti.qM) (*defoper) ( &tm->tm_min , ti.qM ); //tm->tm_min = ti.qM;
if (0 <= ti.qI)
if (0 <= ti.qp) ti.qH = ti.qI % 12 + ti.qp * 12;
else (*defoper) ( &tm->tm_hour , ti.qI ); //tm->tm_hour = ti.qI;
if (0 <= ti.qH) (*defoper) ( &tm->tm_hour , ti.qH ); //tm->tm_hour = ti.qH;
if (0 <= ti.qZ) (*defoper) ( &tm->tm_isdst , ti.qZ - 1 ); //tm->tm_isdst = ti.qZ - 1;
if (0 <= ti.qy) ti.qY = ti.qy;
if (0 <= ti.qY) (*defoper) ( &tm->tm_year ,
ti.qY +=
(ti.qY > 99? -1900:
(ti.qY < 70? 100: 0)) );
/*tm->tm_year = ti.qY +=
(ti.qY > 99? -1900:
(ti.qY < 70? 100: 0));*/
/* ti.qC = %C = Century without an Year - ignored */
if (70 <= ti.qY && ti.qY < 200) /* a representable year */
{
/* 01-01-70 was Thursday, 1968 was leap */
int day = (((ti.qY - 69) >> 2) + ti.qY - 70 + 4) % 7;
/* 2100 wrongly assumed as leap!
if (ti.qY > 200 && --day < 0) day = 6; */
if (0 <= ti.qU && 0 <= ti.qw && 0 > ti.qj)
{
ti.qj = ti.qU * 7;
switch(ti.qV)
{
case 'U': /* %U Sun first */
ti.qj += ti.qw - (day == 0 ? 7: day);
break;
case 'W': /* %W Mon first */
ti.qj += (ti.qw + 6) % 7
- (day == 1 ? 7: (day + 6) % 7);
break;
#if STRFTIME_EXT && 0
case 'V': /* %V >= 4 day */
if (ti.qU == 53) ti.qj = 0;
/* Sun first: */
ti.qj += ti.qw - (day < 4 ? 7: 0) - day;
/* Mon first:
ti.qj += (ti.qw + 6) % 7
- ((day + 6) % 7 < 5 ? 7: 0)
- (day + 6) % 7; */
break;
#endif
default: break;
}
}
#if 0 /* Advanced validating for yday<>m/d/y */
if (0 <= ti.qj)
{
static int m_days[12] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
int mon = (ti.qj + day) % 7;
if (0 > ti.qw) ti.qw = mon;
else if (ti.qw != mon) return NULL;
for(mon = 11; 0 > (day = /* not for 2100: && ti.qY != 200 */
ti.qj - (m_days[mon] + (mon > 1 && !(ti.qY & 3))))
; mon--);
if (0 > ti.qd) ti.qd = day;
else if (ti.qd != day) return NULL;
if (0 > ti.qm) ti.qm = mon;
else if (ti.qm != mon) return NULL;
}
#endif
}
if (0 <= ti.qd) (*defoper) ( &tm->tm_mday , ti.qd + 1 ); //tm->tm_mday = ti.qd + 1;
if (0 <= ti.qm) (*defoper) ( &tm->tm_mon , ti.qm ); //tm->tm_mon = ti.qm;
if (0 <= ti.qw) (*defoper) ( &tm->tm_wday , ti.qw ); //tm->tm_wday = ti.qw;
if (0 <= ti.qj) (*defoper) ( &tm->tm_yday , ti.qj ); //tm->tm_yday = ti.qj;
return (char*)buf;
}
/* end of strftime.c */

271
amxmodx/util.cpp Executable file
View File

@ -0,0 +1,271 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxmod.h"
int UTIL_ReadFlags(const char* c)
{
int flags = 0;
while (*c) flags |= ( 1 << ( *c++ - 'a' ) );
return flags;
}
void UTIL_GetFlags(char* f,int a)
{
for(int i='a';i<='z';++i){
if ( a & 1 ) *f++ = i;
a >>= 1;
}
*f = 0;
}
/* warning - don't pass here const string */
void UTIL_ShowMenu( edict_t* pEdict, int slots, int time, char *menu, int mlen )
{
char *n = menu;
char c = 0;
int a;
while ( *n ) {
a = mlen;
if ( a > 175 ) a = 175;
mlen -= a;
c = *(n+=a);
*n = 0;
MESSAGE_BEGIN( MSG_ONE , gmsgShowMenu, NULL, pEdict );
WRITE_SHORT( slots );
WRITE_CHAR( time );
WRITE_BYTE( c ? TRUE : FALSE);
WRITE_STRING( menu );
MESSAGE_END();
*n = c;
menu = n;
}
}
/* warning - don't pass here const string */
void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
{
MESSAGE_BEGIN( MSG_ONE , gmsgServerName, NULL, client );
WRITE_STRING(name);
MESSAGE_END();
char *n = motd;
char c = 0;
int a;
while ( *n ) {
a = mlen;
if ( a > 175 ) a = 175;
mlen -= a;
c = *(n+=a);
*n = 0;
MESSAGE_BEGIN( MSG_ONE , gmsgMOTD, NULL, client );
WRITE_BYTE( c ? FALSE : TRUE );
WRITE_STRING( motd );
MESSAGE_END();
*n = c;
motd = n;
}
MESSAGE_BEGIN( MSG_ONE , gmsgServerName, NULL, client );
WRITE_STRING( hostname->string );
MESSAGE_END();
}
void UTIL_IntToString(int value, char *output)
{
static const char *words[] = {"zero ","one ","two ","three ","four ",
"five ", "six ","seven ","eight ","nine ","ten ",
"eleven ","twelve ","thirteen ","fourteen ","fifteen ",
"sixteen ","seventeen ","eighteen ","nineteen ",
"twenty ","thirty ","fourty ", "fifty ","sixty ",
"seventy ","eighty ","ninety ",
"hundred ","thousand "};
*output = 0;
if (value < 0) value = -value;
int tho = value / 1000;
int aaa = 0;
if (tho){
aaa += sprintf(&output[aaa], words[ tho ] );
aaa += sprintf(&output[aaa], words[29] );
value = value % 1000;
}
int hun = value / 100;
if (hun) {
aaa += sprintf(&output[aaa], words[ hun ] );
aaa += sprintf(&output[aaa], words[28] );
value = value % 100;
}
int ten = value / 10;
int unit = value % 10;
if ( ten )
aaa += sprintf(&output[aaa], words[ ( ten > 1 ) ? ( ten + 18 ) : ( unit + 10 ) ] );
if ( ten != 1 && ( unit || (!value && !hun && !tho) ) )
sprintf(&output[aaa], words[ unit ] );
}
char* UTIL_SplitHudMessage(const char *src)
{
static char message[512];
short b = 0, d = 0, e = 0, c = -1;
while ( src[ d ] && e < 480 ) {
if ( src[ d ] == ' ' ) {
c = e;
}
else if ( src[ d ] == '\n' ) {
c = -1;
b = 0;
}
message[ e++ ] = src[ d++ ];
if ( ++b == 69 ) {
if ( c == -1 ) {
message[ e++ ] = '\n';
b = 0;
}
else {
message[ c ] = '\n';
b = e - c - 1;
c = -1;
}
}
}
message[ e ] = 0;
return message;
}
unsigned short FixedUnsigned16( float value, float scale )
{
int output = value * scale;
if ( output < 0 )
output = 0;
else if ( output > 0xFFFF )
output = 0xFFFF;
return (unsigned short)output;
}
short FixedSigned16( float value, float scale )
{
int output = value * scale;
if ( output > 32767 )
output = 32767;
else if ( output < -32768 )
output = -32768;
return (short)output;
}
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pMessage)
{
if ( pEntity )
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pEntity );
else
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE(29);
WRITE_BYTE(textparms.channel & 0xFF);
WRITE_SHORT(FixedSigned16(textparms.x, (1<<13) ));
WRITE_SHORT(FixedSigned16(textparms.y, (1<<13) ));
WRITE_BYTE(textparms.effect);
WRITE_BYTE(textparms.r1);
WRITE_BYTE(textparms.g1);
WRITE_BYTE(textparms.b1);
WRITE_BYTE(0);
WRITE_BYTE(255);
WRITE_BYTE(255);
WRITE_BYTE(250);
WRITE_BYTE(0);
WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8) ));
WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8) ));
WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8) ));
if (textparms.effect==2)
WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8) ) );
WRITE_STRING(pMessage);
MESSAGE_END();
}
/* warning - buffer of msg must be longer than 190 chars!
(here in AMX it is always longer) */
void UTIL_ClientPrint( edict_t *pEntity, int msg_dest, char *msg )
{
char c = msg[190];
msg[190] = 0; // truncate without checking with strlen()
if ( pEntity )
MESSAGE_BEGIN( MSG_ONE, gmsgTextMsg, NULL, pEntity );
else
MESSAGE_BEGIN( MSG_BROADCAST , gmsgTextMsg);
WRITE_BYTE( msg_dest );
WRITE_STRING( msg );
MESSAGE_END();
msg[190] = c;
}
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1, const char *arg2) {
if (!cmd) return;
//strncpy(g_fakecmd.argv[0], cmd, 127 );
//g_fakecmd.argv[0][ 127 ] = 0;
g_fakecmd.argv[0] = cmd;
if (arg2){
g_fakecmd.argc = 3;
g_fakecmd.argv[1] = arg1;
g_fakecmd.argv[2] = arg2;
snprintf( g_fakecmd.args ,255 , "%s %s",arg1,arg2 );
g_fakecmd.args[255] = 0;
//strncpy(g_fakecmd.argv[1], arg1 , 127 );
//g_fakecmd.argv[1][ 127 ] = 0;
//strncpy(g_fakecmd.argv[2], arg2 , 127 );
//g_fakecmd.argv[2][ 127 ] = 0;
//snprintf(g_fakecmd.args, 255 , "%s %s",arg1,arg2);
//g_fakecmd.args[255] = 0;
}
else if (arg1){
g_fakecmd.argc = 2;
g_fakecmd.argv[1] = arg1;
snprintf( g_fakecmd.args ,255 , "%s" , arg1 );
g_fakecmd.args[255] = 0;
//strncpy(g_fakecmd.argv[1], arg1, 127 );
//g_fakecmd.argv[1][ 127 ] = 0;
//*g_fakecmd.argv[2] = 0;
//snprintf(g_fakecmd.args, 255 ,"%s",arg1);
//g_fakecmd.args[255] = 0;
}
else
g_fakecmd.argc = 1;
g_fakecmd.fake = true;
MDLL_ClientCommand(pEdict);
g_fakecmd.fake = false;
}

85
amxmodx/vault.cpp Executable file
View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* This file is part of AMX Mod.
*
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
#include <meta_api.h>
#include "CVault.h"
#include "amxmod.h"
Vault g_vault;
static cell AMX_NATIVE_CALL set_vaultdata(AMX *amx,cell *params)
{
int iLen;
g_vault.put( get_amxstring(amx,params[1],0,iLen) , get_amxstring(amx,params[2],1,iLen) );
g_vault.saveVault();
return 1;
}
static cell AMX_NATIVE_CALL get_vaultdata(AMX *amx,cell *params)
{
int iLen;
const char* key = get_amxstring(amx,params[1],0,iLen);
if ( params[3] )
return set_amxstring( amx , params[2] , g_vault.get( key ) , params[3] );
return g_vault.get_number( key );
}
static cell AMX_NATIVE_CALL remove_vaultdata(AMX *amx,cell *params)
{
int iLen;
g_vault.remove( get_amxstring(amx,params[1],0,iLen) );
g_vault.saveVault();
return 1;
}
static cell AMX_NATIVE_CALL vaultdata_exists(AMX *amx,cell *params)
{
int iLen;
return g_vault.exists( get_amxstring(amx,params[1],0,iLen) ) ? 1 : 0;
}
AMX_NATIVE_INFO vault_Natives[] = {
{ "set_vaultdata", set_vaultdata },
{ "get_vaultdata", get_vaultdata },
{ "remove_vaultdata", remove_vaultdata },
{ "delete_vaultdata", remove_vaultdata },
{ "vaultdata_exists", vaultdata_exists },
{ 0, 0 }
};

70
configs/amx.cfg Executable file
View File

@ -0,0 +1,70 @@
// AMX Configuration File
echo Executing AMX Configuration File
// Default access for all non admin players (see users.ini for access details)
amx_default_access ""
// Name of setinfo which should store a password on a client
// (Example: setinfo _pw "password")
amx_password_field "_pw"
// Mode of logging to a server
// 0 - disable logging, players won't be checked (and access won't be set)
// 1 - normal mode which obey flags set in accounts
// 2 - kick all players not on list
amx_mode 1
// Show admins activity
// 0 - disabled
// 1 - show without admin name
// 2 - show with name
amx_show_activity 2
// Frequency in seconds and text of scrolling message
amx_scrollmsg "Welcome to %hostname% -- This server is using AMX" 600
// Center typed colored messages (last parameter is a color in RRRGGGBBB format)
amx_imessage "Welcome to %hostname%" "000255100"
amx_imessage "This server is using AMX\nVisit http://amxmod.net" "000100255"
// Frequency in seconds of colored messages
amx_freq_imessage 180
// Set in seconds how fast players can chat (chat-flood protection)
amx_flood_time 0.75
// Amount of reserved slots (for more details see comments in a plugin source)
amx_reservation 2
// Displaying of time remaining
// a - display white text on bottom
// b - use voice
// c - don't add "remaining" (only in voice)
// d - don't add "hours/minutes/seconds" (only in voice)
// e - show/speak if current time is less than this set in parameter
amx_time_display "ab 1200" "ab 600" "ab 300" "ab 180" "ab 60" "bcde 11"
// Announce "say thetime" and "say timeleft" with voice
amx_time_voice 1
// Minimum delay in seconds between two voting sessions
amx_vote_delay 10
// How long voting session goes on
amx_vote_time 10
// Display who votes for what option
amx_vote_answers 1
// Some ratios for voting success
amx_votekick_ratio 0.40
amx_voteban_ratio 0.40
amx_votemap_ratio 0.40
amx_vote_ratio 0.02
// Max. time to which map can be extended
amx_extendmap_max 90
// Step for each extending
amx_extendmap_step 15

18
configs/clcmds.ini Executable file
View File

@ -0,0 +1,18 @@
; Client commands configuration file
; File location: $moddir/addons/amx/clcmds.ini
; To use with Players Menu plugin
; NOTE: By default in all settings the access level is set to "u".
; However you can change that, to limit the access to some settings.
; Client Commands Menu:
; < description > < command > < flags > < access level >
; "a" - execute from server console
; "b" - execute from admin console
; "c" - execute on selected player
; "d" - back to menu when executed
"Kick player" "amx_kick #%userid%" "b" "u"
"Slay player" "amx_slay #%userid%" "bd" "u"
"Slap with 1 dmg." "amx_slap #%userid% 1" "b" "u"
"Ban on 5 minutes" "amx_banip 5 #%userid%" "b" "u"

17
configs/cmds.ini Executable file
View File

@ -0,0 +1,17 @@
; Menu configuration file
; File location: $moddir/addons/amx/cmds.ini
; To use with Commands Menu plugin
; NOTE: By default in all settings the access level is set to "u".
; However you can change that, to limit the access to some settings.
; Commands Menu:
; < description > < command > < flags > < access level >
; "a" - execute from server console
; "b" - execute from admin console
; "c" - execute on all clients
; "d" - back to menu when executed
"Pause" "amx_pause" "ad" "u"
" " "-" "" "u"
"Restart Round" "sv_restartround 1" "a" "u"

22
configs/configs.ini Executable file
View File

@ -0,0 +1,22 @@
; Menu configuration file
; File location: $moddir/addons/amx/configs.ini
; To use with Commands Menu plugin
; NOTE: By default in all settings the access level is set to "u".
; However you can change that, to limit the access to some settings.
; Commands Menu:
; < description > < command > < flags > < access level >
; "a" - execute from server console
; "b" - execute from admin console
; "c" - execute on all clients
; "d" - back to menu when executed
"PUBLIC Settings" "servercfgfile server.cfg;exec server.cfg" "a" "u"
"Clanbase" "exec clanbase.cfg;servercfgfile \'\'" "a" "u"
"Clanbase Charges Only" "exec clanbase_co.cfg;servercfgfile \'\'" "a" "u"
"Official CAL Match" "exec cal.cfg;servercfgfile \'\'" "a" "u"
"ProvingGrounds Server Config" "exec leagues/pg.cfg;servercfgfile \'\'" "a" "u"
"OGL CS Server Config" "exec ogl.cfg;servercfgfile \'\'" "a" "u"
"OGL CS FF Server Config" "exec ogl_ff.cfg;servercfgfile \'\'" "a" "u"
"OGL CS Advanced Server Config" "exec ogl_adv.cfg;servercfgfile \'\'" "a" "u"

1
configs/conmotd.txt Executable file
View File

@ -0,0 +1 @@
For newest AMX Mod and many plugins visit http://amxmod.net

7
configs/core.ini Executable file
View File

@ -0,0 +1,7 @@
; Configuration file for AMX
amx_logdir addons/amx/logs
amx_modules addons/amx/modules.ini
amx_plugins addons/amx/plugins/plugins.ini
amx_vault addons/amx/vault.ini
csstats_score addons/amx/csstats.amx
csstats addons/amx/csstats.dat

23
configs/cvars.ini Executable file
View File

@ -0,0 +1,23 @@
; Menu configuration file
; File location: $moddir/addons/amx/cvars.ini
; To use with Commands Menu plugin
; Cvars Menu:
; < cvar > < values > ... < access level >
"mp_timelimit" "0" "30" "45" "u"
"mp_friendlyfire" "0" "1" "u"
"mp_autoteambalance" "0" "1" "2" "u"
"sv_password" "" roxor "clanwar" "u"
"mp_limitteams" "0" "1" "2" "u"
"mp_freezetime" 0 "6" "u"
"mp_buytime" "1" "0.5" "u"
"mp_startmoney" "800" "1800" "3600" "u"
"mp_c4timer" "35" "45" "15" "u"
"mp_forcechasecam" "0" "1" "2" "u"
"pausable" 0 1 "u"
"sv_minrate" "2000" "3000" "u"
"sv_maxrate" "7000" "6500" "u"
"allow_spectators" "0" "1" "u"
"sv_voiceenable" "0" "1" "u"
"mp_logmessages" "0" "1" "u"

30
configs/maps.ini Executable file
View File

@ -0,0 +1,30 @@
; Maps configuration file
; File location: $moddir/addons/amx/maps.ini
; To use with Maps Menu plugin
as_oilrig "OilRig - Assassination"
as_tundra "Tundra - Assassination"
de_aztec "Aztec - Bomb/Defuse"
de_cbble "Cobble - Bomb/Defuse"
de_chateau "Chateau - Bomb/Defuse"
de_dust "Dust - Bomb/Defuse"
de_dust2 "Dust II - Bomb/Defuse"
de_inferno "Inferno - Bomb/Defuse"
de_nuke "Nuke - Bomb/Defuse"
de_prodigy "Prodigy - Bomb/Defuse"
de_storm "Storm - Bomb/Defuse"
de_survivor "Survivor - Bomb/Defuse"
de_train "Trainyard - Bomb/Defuse"
de_torn "Torn - Bomb/Defuse"
de_vegas "Vegas - Bomb/Defuse"
de_vertigo "Vertigo - Bomb/Defuse"
cs_747 "747 Hijack - Hostage Rescue"
cs_assault "Assault - Hostage Rescue"
cs_backalley "Alleyway - Hostage Rescue"
cs_estate "Zaphod's Estate - Hostage Rescue"
cs_havana "Havana - Hostage Rescue"
cs_italy "Italy - Hostage Rescue"
cs_militia "Militia - Hostage Rescue"
cs_office "The Office Complex - Hostage Rescue"
cs_siege "Canyon Siege - Hostage Rescue"

14
configs/modules.ini Executable file
View File

@ -0,0 +1,14 @@
; AMX Modules
; You can specify both linux & win32 modules here
; CS Stats
addons/amx/dlls/csstats_mm.dll
addons/amx/dlls/csstats_mm_i386.so
; More functions for modifications in HL
addons/amx/dlls/fun_mm.dll
addons/amx/dlls/fun_mm_i386.so
; MySQL access
;addons/amx/dlls/mysql.dll
;addons/amx/dlls/mysql_i386.so

10
configs/mysql.cfg Executable file
View File

@ -0,0 +1,10 @@
// MySQL access configuration file
// File location: $moddir/addons/amx
// *NOTE* Linux users may encounter problems if they specify "localhost" instead of "127.0.0.1"
// We recommend using your server IP address instead of its name
amx_mysql_host "127.0.0.1"
amx_mysql_user "root"
amx_mysql_pass ""
amx_mysql_db "amx"

26
configs/plugins.ini Executable file
View File

@ -0,0 +1,26 @@
; AMX Mod plugins
admin.amx ; admin base (required for any admin-related)
;admin_mysql.amx ; admin base - MySQL version (comment admin.amx)
admincmd.amx ; basic admin console commands
adminhelp.amx ; help command for admin console commands
adminslots.amx ; slot reservation
menufront.amx ; front-end for admin menus
cmdmenu.amx ; command menu (speech, settings)
plmenu.amx ; players menu (kick, ban, client cmds.)
restmenu.amx ; restrict weapons menu
mapsmenu.amx ; maps menu (vote, changelevel)
antiflood.amx ; prevent clients from chat-flooding the server
adminchat.amx ; console chat commands
adminvote.amx ; vote commands
nextmap.amx ; displays next map in mapcycle
timeleft.amx ; displays time left on map
mapchooser.amx ; allows to vote for next map
scrollmsg.amx ; displays a scrolling message
imessage.amx ; displays information messages
pausecfg.amx ; allows to pause and unpause some plugins
;telemenu.amx ; teleport menu (Fun Module required!)
stats.amx ; stats on death or round end (CSStats Module required!)
stats_logging.amx ; weapons stats logging (CSStats Module required!)
miscstats.amx ; bunch of events announcement for Counter-Strike
statscfg.amx ; allows to manage stats plugins via menu and commands

35
configs/speech.ini Executable file
View File

@ -0,0 +1,35 @@
; Menu configuration file
; File location: $moddir/addons/amx/speech.ini
; To use with Commands Menu plugin
; NOTE: By default in all settings the access level is set to "u".
; However you can change that, to limit the access to some settings.
; Commands Menu:
; < description > < command > < flags > < access level >
; "a" - execute from server console
; "b" - execute from admin console
; "c" - execute on all clients
; "d" - back to menu when executed
"Hello!" "spk \'vox/hello\'" "cd" "u"
"Don't think so" "spk \'barney/dontguess\'" "cd" "u"
"Don't ask me" "spk \'barney/dontaskme\'" "cd" "u"
"Hey! Stop that!" "spk \'barney/donthurtem\'" "cd" "u"
"Yup" "spk \'barney/yup\'" "cd" "u"
"Nope" "spk \'barney/nope\'" "cd" "u"
"Maybe" "spk \'barney/maybe\'" "cd" "u"
"Seeya" "spk \'barney/seeya\'" "cd" "u"
"Man that sounded bad" "spk \'barney/soundsbad\'" "cd" "u"
"Hello and die" "spk \'vox/hello and die\'" "cd" "u"
"Move!" "spk \'hgrunt/move! _comma yessir!\'" "cd" "u"
"You will definitely pay!" "spk \'hgrunt/c2a2_hg_chat5a\'" "cd" "u"
"Laughter" "spk \'hgrunt/c2a3_hg_laugh\'" "cd" "u"
"Silence!" "spk \'hgrunt/silence!\'" "cd" "u"
"You talk too much" "spk \'barney/youtalkmuch\'" "cd" "u"
"You thinkin?" "spk \'barney/thinking\'" "cd" "u"
"Open fire Gordon!" "spk \'barney/openfire\'" "cd" "u"
"Couldnt make a bigger mess" "spk \'barney/bigmess\'" "cd" "u"
"I have a Bad feeling" "spk \'barney/badfeeling\'" "cd" "u"
"Yes sir!" "spk \'hgrunt/yessir!\'" "cd" "u"
"No sir" "spk \'barney/nosir\'" "cd" "u"

42
configs/users.ini Executable file
View File

@ -0,0 +1,42 @@
; Line starting with ; is a comment
; Access flags:
; a - immunity (can't be kicked/baned/slayed/slaped and affected by other commmands)
; b - reservation (can join on reserved slots)
; c - amx_kick command
; d - amx_ban and amx_unban commands
; e - amx_slay and amx_slap commands
; f - amx_map command
; g - amx_cvar command (not all cvars will be available)
; h - amx_cfg command
; i - amx_chat and other chat commands
; j - amx_vote and other vote commands
; k - access to sv_password cvar (by amx_cvar command)
; l - access to amx_rcon command and rcon_password cvar (by amx_cvar command)
; m - custom level A (for additional plugins)
; n - custom level B
; o - custom level C
; p - custom level D
; q - custom level E
; r - custom level F
; s - custom level G
; t - custom level H
; u - menu access
; z - user
; Account flags:
; a - disconnect player on invalid password
; b - clan tag
; c - this is steamid
; d - this is ip
; e - password is not checked (only name/ip/steamid needed)
; Format of admin account:
; <name|ip|steamid> <password> <access flags> <account flags>
; Examples of admin accounts:
; "123.43.43.53" "" "abcdefghijklmnopqrstu" "de"
; "STEAM_0:0:14332" "my_password" "abcdefgnstu" "c"
; "My Name" "my_password" "abcdefghijklmnopqrstu" "a"
"loopback" "" "abcdefghijklmnopqrstu" "de"

202
plugins/admin.sma Executable file
View File

@ -0,0 +1,202 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*/
#include <amxmod>
#include <amxmisc>
#define MAX_ADMINS 64
new g_aPassword[MAX_ADMINS][32]
new g_aName[MAX_ADMINS][32]
new g_aFlags[MAX_ADMINS]
new g_aAccess[MAX_ADMINS]
new g_aNum
new g_logFile[16]
#if !defined NO_STEAM
new g_cmdLoopback[16]
#endif
public plugin_init()
{
register_plugin("Admin Base","0.9","default")
register_cvar("amx_mode","2.0")
register_cvar("amx_password_field","_pw")
register_cvar("amx_default_access","")
get_logfile(g_logFile,15)
#if !defined NO_STEAM
format( g_cmdLoopback, 15, "amxauth%c%c%c%c" ,
random_num('A','Z') , random_num('A','Z') ,random_num('A','Z'),random_num('A','Z') )
register_clcmd( g_cmdLoopback, "ackSignal" )
#endif
remove_user_flags(0,read_flags("z")) // Remove 'user' flag from server rights
new filename[64]
get_basedir( filename , 31 )
server_cmd("exec %s/amx.cfg" , filename ) // Execute main configuration file
format( filename, 63 , "%s/users.ini" , filename )
loadSettings( filename ) // Load admins accounts
}
loadSettings(szFilename[])
{
if (!file_exists(szFilename)) return 0
new szText[256], szFlags[32], szAccess[32]
new a, pos = 0
while ( g_aNum < MAX_ADMINS && read_file(szFilename,pos++,szText,255,a) )
{
if ( szText[0] == ';' ) continue
if ( parse(szText, g_aName[ g_aNum ] ,31,
g_aPassword[ g_aNum ], 31, szAccess,31,szFlags,31 ) < 2 ) continue
g_aAccess[ g_aNum ] = read_flags( szAccess )
g_aFlags[ g_aNum ] = read_flags( szFlags )
++g_aNum
}
return 1
}
getAccess(id,name[],authid[],ip[], password[])
{
new index = -1
new result = 0
for(new i = 0; i < g_aNum; ++i) {
if (g_aFlags[i] & FLAG_AUTHID) {
if (equal(authid,g_aName[i])) {
index = i
break
}
}
else if (g_aFlags[i] & FLAG_IP) {
new c = strlen( g_aName[i] )
if ( g_aName[i][ c - 1 ] == '.' ) { /* check if this is not a xxx.xxx. format */
if ( equal( g_aName[i] , ip , c ) ) {
index = i
break
}
} /* in other case an IP must just match */
else if ( equal(ip,g_aName[i]) ){
index = i
break
}
}
else {
if (g_aFlags[i] & FLAG_TAG) {
if (contain(name,g_aName[i])!=-1){
index = i
break
}
}
else if (equal(name,g_aName[i])) {
index = i
break
}
}
}
if (index != -1) {
if (g_aFlags[index] & FLAG_NOPASS){
result |= 8
new sflags[32]
get_flags(g_aAccess[index],sflags,31)
set_user_flags(id,g_aAccess[index])
log_to_file(g_logFile,"Login: ^"%s<%d><%s><>^" become an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")",
name,get_user_userid(id),authid,g_aName[index] ,sflags,ip)
}
else if (equal(password,g_aPassword[index])) {
result |= 12
set_user_flags(id,g_aAccess[index])
new sflags[32]
get_flags(g_aAccess[index],sflags,31)
log_to_file(g_logFile,"Login: ^"%s<%d><%s><>^" become an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")",
name,get_user_userid(id),authid,g_aName[index] ,sflags,ip)
}
else {
result |= 1
if (g_aFlags[index] & FLAG_KICK){
result |= 2
log_to_file(g_logFile,"Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")",
name,get_user_userid(id),authid,g_aName[index],ip)
}
}
}
else if (get_cvar_float("amx_mode")==2.0) {
result |= 2
}
else {
new defaccess[32]
get_cvar_string("amx_default_access",defaccess,31)
new idefaccess = read_flags(defaccess)
if (idefaccess){
result |= 8
set_user_flags(id,idefaccess)
}
}
return result
}
accessUser( id, name[] = "" )
{
remove_user_flags(id)
new userip[32],userauthid[32],password[32],passfield[32],username[32]
get_user_ip(id,userip,31,1)
get_user_authid(id,userauthid,31)
if ( name[0] ) copy( username , 31, name)
else get_user_name(id,username,31 )
get_cvar_string("amx_password_field",passfield,31)
get_user_info(id,passfield,password,31)
new result = getAccess(id,username,userauthid,userip,password)
if (result & 1) client_cmd(id,"echo ^"* Invalid Password!^"")
if (result & 2) {
#if !defined NO_STEAM
client_cmd(id,"echo ^"* You have no entry to the server...^";%s",g_cmdLoopback)
#else
client_cmd(id,"echo ^"* You have no entry to the server...^";disconnect")
#endif
return PLUGIN_HANDLED
}
if (result & 4) client_cmd(id,"echo ^"* Password accepted^"")
if (result & 8) client_cmd(id,"echo ^"* Privileges set^"")
return PLUGIN_CONTINUE
}
public client_infochanged(id)
{
if ( !is_user_connected(id) || !get_cvar_num("amx_mode") )
return PLUGIN_CONTINUE
new newname[32], oldname[32]
get_user_name(id,oldname,31)
get_user_info(id,"name",newname,31)
if ( !equal(newname,oldname) )
accessUser( id, newname )
return PLUGIN_CONTINUE
}
#if !defined NO_STEAM
public ackSignal(id)
server_cmd("kick #%d", get_user_userid(id) )
public client_authorized(id)
#else
public client_connect(id)
#endif
return get_cvar_num( "amx_mode" ) ? accessUser( id ) : PLUGIN_CONTINUE

234
plugins/admin_mysql.sma Executable file
View File

@ -0,0 +1,234 @@
/* AMX Mod script.
*
* (c) 2003, dJeyL
* This file is provided as is (no warranties).
*
* This AMX plugin requires MySQL module.
*
* For this to work, you might create your MySQL admins table with this SQL query :
CREATE TABLE admins (
auth varchar(32) NOT NULL default '',
password varchar(32) NOT NULL default '',
access varchar(32) NOT NULL default '',
flags varchar(32) NOT NULL default ''
) TYPE=MyISAM;
* IMPORTANT:
* o Check $moddir/addons/amx/mysql.cfg for MySQL access configuration
* o Disable admin.amx plugin if you use admin_mysql.amx
*
*/
#include <amxmod>
#include <amxmisc>
#include <mysql>
#define MAX_ADMINS 64
new g_aPassword[MAX_ADMINS][32]
new g_aName[MAX_ADMINS][32]
new g_aFlags[MAX_ADMINS]
new g_aAccess[MAX_ADMINS]
new g_aNum
new g_logFile[16]
#if !defined NO_STEAM
new g_cmdLoopback[16]
#endif
public plugin_init()
{
register_plugin("Admin Base for MySQL","0.9","default")
register_cvar("amx_mode","2.0")
register_cvar("amx_password_field","_pw")
register_cvar("amx_default_access","")
register_srvcmd("amx_sqladmins","adminSql")
register_cvar("amx_mysql_host","127.0.0.1")
register_cvar("amx_mysql_user","root")
register_cvar("amx_mysql_pass","")
register_cvar("amx_mysql_db","amx")
#if !defined NO_STEAM
format( g_cmdLoopback, 15, "amxauth%c%c%c%c" ,
random_num('A','Z') , random_num('A','Z') ,random_num('A','Z'),random_num('A','Z') )
register_clcmd( g_cmdLoopback, "ackSignal" )
#endif
remove_user_flags(0,read_flags("z")) // remove 'user' flag from server rights
get_logfile(g_logFile,15)
new filename[32]
get_basedir( filename , 31 )
server_cmd("exec %s/amx.cfg" , filename)
server_cmd("exec %s/mysql.cfg;amx_sqladmins" , filename)
}
public adminSql(){
new host[64],user[32],pass[32],db[32],error[128]
get_cvar_string("amx_mysql_host",host,63)
get_cvar_string("amx_mysql_user",user,31)
get_cvar_string("amx_mysql_pass",pass,31)
get_cvar_string("amx_mysql_db",db,31)
new mysql = mysql_connect(host,user,pass,db,error,127)
if(mysql < 1){
server_print("MySQL error: can't connect: '%s'",error)
return PLUGIN_HANDLED
}
if(mysql_query(mysql,"SELECT auth,password,access,flags FROM admins") < 1) {
mysql_error(mysql,error,127)
server_print("MySQL error: can't load admins: '%s'",error)
return PLUGIN_HANDLED
}
new szFlags[32], szAccess[32]
g_aNum = 0 /* reset admins settings */
while( mysql_nextrow(mysql) > 0 )
{
mysql_getfield(mysql, 1, g_aName[ g_aNum ] ,31)
mysql_getfield(mysql, 2, g_aPassword[ g_aNum ] ,31)
mysql_getfield(mysql, 3, szAccess,31)
mysql_getfield(mysql, 4, szFlags,31)
g_aAccess[ g_aNum ] = read_flags( szAccess )
g_aFlags[ g_aNum ] = read_flags( szFlags )
++g_aNum
}
server_print("Loaded %d admin%s from database",g_aNum, (g_aNum == 1) ? "" : "s" )
mysql_close(mysql)
return PLUGIN_HANDLED
}
getAccess(id,name[],authid[],ip[], password[]){
new index = -1
new result = 0
for(new i = 0; i < g_aNum; ++i) {
if (g_aFlags[i] & FLAG_AUTHID) {
if (equal(authid,g_aName[i])) {
index = i
break
}
}
else if (g_aFlags[i] & FLAG_IP) {
new c = strlen( g_aName[i] )
if ( g_aName[i][ c - 1 ] == '.' ) { /* check if this is not a xxx.xxx. format */
if ( equal( g_aName[i] , ip , c ) ) {
index = i
break
}
} /* in other case an IP must just match */
else if ( equal(ip,g_aName[i]) ){
index = i
break
}
}
else {
if (g_aFlags[i] & FLAG_TAG) {
if (contain(name,g_aName[i])!=-1){
index = i
break
}
}
else if (equal(name,g_aName[i])) {
index = i
break
}
}
}
if (index != -1) {
if (g_aFlags[index] & FLAG_NOPASS){
result |= 8
new sflags[32]
get_flags(g_aAccess[index],sflags,31)
set_user_flags(id,g_aAccess[index])
log_to_file(g_logFile,"Login: ^"%s<%d><%s><>^" become an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")",
name,get_user_userid(id),authid,g_aName[index] ,sflags,ip)
}
else if (equal(password,g_aPassword[index])) {
result |= 12
set_user_flags(id,g_aAccess[index])
new sflags[32]
get_flags(g_aAccess[index],sflags,31)
log_to_file(g_logFile,"Login: ^"%s<%d><%s><>^" become an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")",
name,get_user_userid(id),authid,g_aName[index] ,sflags,ip)
}
else {
result |= 1
if (g_aFlags[index] & FLAG_KICK){
result |= 2
log_to_file(g_logFile,"Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")",
name,get_user_userid(id),authid,g_aName[index],ip)
}
}
}
else if (get_cvar_float("amx_mode")==2.0) {
result |= 2
}
else {
new defaccess[32]
get_cvar_string("amx_default_access",defaccess,31)
new idefaccess = read_flags(defaccess)
if (idefaccess){
result |= 8
set_user_flags(id,idefaccess)
}
}
return result
}
accessUser( id, name[]="" )
{
remove_user_flags(id)
new userip[32],userauthid[32],password[32],passfield[32],username[32]
get_user_ip(id,userip,31,1)
get_user_authid(id,userauthid,31)
if ( name[0] ) copy( username , 31, name)
else get_user_name(id,username,31 )
get_cvar_string("amx_password_field",passfield,31)
get_user_info(id,passfield,password,31)
new result = getAccess(id,username,userauthid,userip,password)
if (result & 1) client_cmd(id,"echo ^"* Invalid Password!^"")
if (result & 2) {
#if !defined NO_STEAM
client_cmd(id,"echo ^"* You have no entry to the server...^";%s",g_cmdLoopback)
#else
client_cmd(id,"echo ^"* You have no entry to the server...^";disconnect")
#endif
return PLUGIN_HANDLED
}
if (result & 4) client_cmd(id,"echo ^"* Password accepted^"")
if (result & 8) client_cmd(id,"echo ^"* Privileges set^"")
return PLUGIN_CONTINUE
}
public client_infochanged(id)
{
if ( !is_user_connected(id) || !get_cvar_num("amx_mode") )
return PLUGIN_CONTINUE
new newname[32], oldname[32]
get_user_name(id,oldname,31)
get_user_info(id,"name",newname,31)
if ( !equal(newname,oldname) )
accessUser( id , newname )
return PLUGIN_CONTINUE
}
#if !defined NO_STEAM
public ackSignal(id)
server_cmd("kick #%d", get_user_userid(id) )
public client_authorized(id)
#else
public client_connect(id)
#endif
return get_cvar_num( "amx_mode" ) ? accessUser( id ) : PLUGIN_CONTINUE

204
plugins/adminchat.sma Executable file
View File

@ -0,0 +1,204 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*/
#include <amxmod>
#include <amxmisc>
// Uncomment if you want to display
// names with hud messages
//#define SHOW_NAMES
new g_logFile[16]
new g_msgChannel
#define MAX_CLR 7
new g_Colors[MAX_CLR][] = {"white","red","green","blue","yellow","magenta","cyan"}
new g_Values[MAX_CLR][] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255}}
new Float:g_Pos[4][] = {{0.0,0.0},{0.05,0.55},{-1.0,0.2},{-1.0,0.7}}
public plugin_init(){
register_plugin("Admin Chat","0.9","default")
register_clcmd("say_team","cmdSayAdmin",0,"@<text> - displays message to admins")
register_clcmd("say","cmdSayChat",ADMIN_CHAT,"@[@|@|@][w|r|g|b|y|m|c]<text> - displays hud message")
register_concmd("amx_say","cmdSay",ADMIN_CHAT,"<message> - sends message to all players")
register_concmd("amx_chat","cmdChat",ADMIN_CHAT,"<message> - sends message to admins")
register_concmd("amx_psay","cmdPsay",ADMIN_CHAT,"<name or #userid> <message> - sends private message")
register_concmd("amx_tsay","cmdTsay",ADMIN_CHAT,"<color> <message> - sends left side hud message to all players")
register_concmd("amx_csay","cmdTsay",ADMIN_CHAT,"<color> <message> - sends center hud message to all players")
get_logfile(g_logFile,15)
}
public cmdSayChat(id) {
if (!(get_user_flags(id)&ADMIN_CHAT)) return PLUGIN_CONTINUE
new said[6], i=0
read_argv(1,said,5)
while (said[i]=='@')
i++
if ( !i || i > 3 ) return PLUGIN_CONTINUE
new message[192], a = 0
read_argv(1,message,191)
switch(said[i]){
case 'r': a = 1
case 'g': a = 2
case 'b': a = 3
case 'y': a = 4
case 'm': a = 5
case 'c': a = 6
}
new name[32], authid[32], userid
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
log_to_file(g_logFile,"Chat: ^"%s<%d><%s><>^" tsay ^"%s^"",name,userid,authid,message[i+1])
log_message("^"%s<%d><%s><>^" triggered ^"amx_tsay^" (text ^"%s^") (color ^"%s^")",
name,userid,authid,message[ i+1 ],g_Colors[a])
if (++g_msgChannel>6||g_msgChannel<3)
g_msgChannel = 3
new Float:verpos = g_Pos[i][1] + float(g_msgChannel) / 35.0
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2],
g_Pos[i][0], verpos , 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel )
#if defined SHOW_NAMES
show_hudmessage(0,"%s : %s",name,message[i+1])
client_print(0,print_notify,"%s : %s",name,message[i+1])
#else
show_hudmessage(0,message[i+1])
client_print(0,print_notify,message[i+1])
#endif
return PLUGIN_HANDLED
}
public cmdSayAdmin(id) {
new said[2]
read_argv(1,said,1)
if (said[0]!='@') return PLUGIN_CONTINUE
new message[192], name[32],authid[32], userid
new players[32], inum
read_argv(1,message,191)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
log_to_file(g_logFile,"Chat: ^"%s<%d><%s><>^" chat ^"%s^"",name,userid,authid,message[1])
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")",name,userid,authid,message[1])
format(message,191,"(ADMINS) %s : %s",name,message[1])
get_players(players,inum)
for(new i=0; i<inum; ++i){
if (players[i] != id && get_user_flags(players[i]) & ADMIN_CHAT)
client_print(players[i],print_chat,message)
}
client_print(id,print_chat,message)
return PLUGIN_HANDLED
}
public cmdChat(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new message[192], name[32], players[32], inum, authid[32], userid
read_args(message,191)
remove_quotes(message)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
get_players(players,inum)
log_to_file(g_logFile,"Chat: ^"%s<%d><%s><>^" chat ^"%s^"",name,userid,authid,message)
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")",name,userid,authid,message)
format(message,191,"(ADMINS) %s : %s",name,message)
console_print(id,message)
for(new i = 0; i < inum; ++i){
if ( get_user_flags(players[i]) & ADMIN_CHAT )
client_print(players[i],print_chat,message)
}
return PLUGIN_HANDLED
}
public cmdSay(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new message[192], name[32],authid[32], userid
read_args(message,191)
remove_quotes(message)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
client_print(0,print_chat,"(ALL) %s : %s",name,message)
console_print(id,"(ALL) %s : %s",name,message)
log_to_file(g_logFile,"Chat: ^"%s<%d><%s><>^" say ^"%s^"", name,userid,authid,message)
log_message("^"%s<%d><%s><>^" triggered ^"amx_say^" (text ^"%s^")",name,userid,authid,message)
return PLUGIN_HANDLED
}
public cmdPsay(id,level,cid){
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
new name[32]
read_argv(1,name,31)
new priv = cmd_target(id,name,0)
if (!priv) return PLUGIN_HANDLED
new length = strlen(name)+1
new message[192], name2[32],authid[32],authid2[32], userid, userid2
get_user_authid(id,authid,31)
get_user_name(id,name2,31)
userid = get_user_userid(id)
read_args(message,191)
if (message[0]=='"' && message[length]=='"'){// HLSW fix
message[0]=message[length]=' '
length+=2
}
remove_quotes(message[length])
get_user_name(priv,name,31)
if (id&&id!=priv) client_print(id,print_chat,"(%s) %s : %s",name,name2,message[length])
client_print(priv,print_chat,"(%s) %s : %s",name,name2,message[length])
console_print(id,"(%s) %s : %s",name,name2,message[length])
get_user_authid(priv,authid2,31)
userid2 = get_user_userid(priv)
log_to_file(g_logFile,"Chat: ^"%s<%d><%s><>^" psay ^"%s<%d><%s><>^" ^"%s^"",
name2,userid,authid,name,userid2,authid2,message[length])
log_message("^"%s<%d><%s><>^" triggered ^"amx_psay^" against ^"%s<%d><%s><>^" (text ^"%s^")",
name2,userid,authid,name,userid2,authid2,message[length])
return PLUGIN_HANDLED
}
public cmdTsay(id,level,cid){
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
new cmd[16],color[12], message[192], name[32], authid[32], userid = 0
read_argv(0,cmd,15)
new bool:tsay = (tolower(cmd[4]) == 't')
read_args(message,191)
remove_quotes(message)
parse(message,color,11)
new found = 0,a = 0
for(new i=0;i<MAX_CLR;++i)
if (equal(color,g_Colors[i])) {
a = i
found = 1
break
}
new length = found ? (strlen(color) + 1) : 0
if (++g_msgChannel>6||g_msgChannel<3)
g_msgChannel = 3
new Float:verpos = ( tsay ? 0.55 : 0.1 ) + float(g_msgChannel) / 35.0
get_user_authid(id,authid,31)
get_user_name(id,name,31)
userid = get_user_userid(id)
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel)
#if defined SHOW_NAMES
show_hudmessage(0,"%s : %s",name,message[length])
client_print(0,print_notify,"%s : %s",name,message[length])
console_print(id,"%s : %s",name,message[length])
#else
show_hudmessage(0,message[length])
client_print(0,print_notify,message[length])
console_print(id,message[length])
#endif
log_to_file(g_logFile,"Chat: ^"%s<%d><%s><>^" %s ^"%s^"",name,userid,authid,cmd[4],message[length])
log_message("^"%s<%d><%s><>^" triggered ^"%s^" (text ^"%s^") (color ^"%s^")",
name,userid,authid,cmd,message[length],g_Colors[a])
return PLUGIN_HANDLED
}

459
plugins/admincmd.sma Executable file
View File

@ -0,0 +1,459 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*/
#include <amxmod>
#include <amxmisc>
#define MAXRCONCVARS 16
new g_cvarRcon[ MAXRCONCVARS ][32]
new g_cvarRconNum
new g_logFile[16]
new g_pauseCon
new Float:g_pausAble
new bool:g_Paused
new g_addCvar[] = "amx_cvar add %s"
public plugin_init(){
register_plugin("Admin Commands","0.9","default")
register_concmd("amx_kick","cmdKick",ADMIN_KICK,"<name or #userid> [reason]")
register_concmd("amx_ban","cmdAddBan",ADMIN_BAN,"<minutes> <authid or ip> [reason]")
register_concmd("amx_banid","cmdBan",ADMIN_BAN,"<minutes> <name or #userid> [reason]")
register_concmd("amx_banip","cmdBan",ADMIN_BAN,"<minutes> <name or #userid> [reason]")
register_concmd("amx_unban","cmdUnban",ADMIN_BAN,"<authid or ip>")
register_concmd("amx_slay","cmdSlay",ADMIN_SLAY,"<name or #userid>")
register_concmd("amx_slap","cmdSlap",ADMIN_SLAY,"<name or #userid> [power]")
register_concmd("amx_leave","cmdLeave",ADMIN_KICK,"<tag> [tag] [tag] [tag]")
register_concmd("amx_pause","cmdPause",ADMIN_CVAR,"- pause or unpause the game")
register_concmd("amx_who","cmdWho",0,"- displays who is on server")
register_concmd("amx_cvar","cmdCvar",ADMIN_CVAR,"<cvar> [value]")
register_clcmd("amx_map","cmdMap",ADMIN_MAP,"<mapname>")
register_clcmd("pauseAck","cmdLBack")
register_clcmd("amx_cfg","cmdCfg",ADMIN_CFG,"<fliename>")
register_clcmd("amx_rcon","cmdRcon",ADMIN_RCON,"<command line>")
register_cvar("amx_show_activity","2")
register_cvar("amx_vote_delay","")
register_cvar("amx_vote_time","")
register_cvar("amx_vote_answers","")
register_cvar("amx_vote_ratio","")
register_cvar("amx_show_activity","")
get_logfile(g_logFile,15)
}
public plugin_cfg(){
// Cvars which can be changed only with rcon access
server_cmd( g_addCvar ,"rcon_password")
server_cmd( g_addCvar ,"amx_show_activity")
server_cmd( g_addCvar ,"amx_mode")
server_cmd( g_addCvar ,"amx_password_field")
server_cmd( g_addCvar ,"amx_default_access")
server_cmd( g_addCvar ,"amx_reserved_slots")
server_cmd( g_addCvar ,"amx_reservation")
server_cmd( g_addCvar ,"amx_conmotd_file")
}
public cmdKick(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[32]
read_argv(1,arg,31)
new player = cmd_target(id,arg,1)
if (!player) return PLUGIN_HANDLED
new authid[32],authid2[32],name2[32],name[32],userid2, arg2[32]
get_user_authid(id,authid,31)
get_user_authid(player,authid2,31)
get_user_name(player,name2,31)
get_user_name(id,name,31)
userid2 = get_user_userid(player)
read_argv(2,arg2,31)
log_to_file(g_logFile,"Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")",
name,get_user_userid(id),authid, name2,userid2,authid2,arg2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: kick %s",name,name2)
case 1: client_print(0,print_chat,"ADMIN: kick %s",name2)
}
server_cmd("kick #%d",userid2)
console_print(id,"Client ^"%s^" kicked",name2)
return PLUGIN_HANDLED
}
public cmdUnban(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[32],authid[32],name[32]
read_argv(1,arg,31)
if (contain(arg,".")!=-1) {
server_cmd("removeip ^"%s^";writeip",arg)
console_print(id,"Ip ^"%s^" removed from ban list", arg )
}
else {
server_cmd("removeid ^"%s^";writeid",arg)
console_print(id,"Authid ^"%s^" removed from ban list", arg )
}
get_user_name(id,name,31)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: unban %s",name,arg)
case 1: client_print(0,print_chat,"ADMIN: unban %s",arg)
}
get_user_authid(id,authid,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" unban ^"%s^"",
name,get_user_userid(id),authid, arg )
return PLUGIN_HANDLED
}
public cmdAddBan(id,level,cid){
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
new arg[32],authid[32],name[32],minutes[32],reason[32]
read_argv(1,minutes,31)
read_argv(2,arg,31)
read_argv(3,reason,31)
if (contain(arg,".")!=-1) {
server_cmd("addip ^"%s^" ^"%s^";wait;writeip",minutes,arg)
console_print(id,"Ip ^"%s^" added to ban list", arg )
}
else {
server_cmd("banid ^"%s^" ^"%s^" kick;wait;writeid",minutes,arg)
console_print(id,"Authid ^"%s^" added to ban list", arg )
}
get_user_name(id,name,31)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: ban %s",name,arg)
case 1: client_print(0,print_chat,"ADMIN: ban %s",arg)
}
get_user_authid(id,authid,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" ban ^"%s^" (minutes ^"%s^") (reason ^"%s^")",
name,get_user_userid(id),authid, arg, minutes, reason )
return PLUGIN_HANDLED
}
public cmdBan(id,level,cid){
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
new arg[32], cmd[32]
read_argv(0,cmd,31)
read_argv(2,arg,31)
new player = cmd_target(id,arg,9)
if (!player) return PLUGIN_HANDLED
new minutes[32],authid[32],name2[32],authid2[32],name[32], arg3[32]
new userid2 = get_user_userid(player)
read_argv(1,minutes,31)
get_user_authid(player,authid2,31)
get_user_authid(id,authid,31)
get_user_name(player,name2,31)
get_user_name(id,name,31)
read_argv(3,arg3,31)
log_to_file(g_logFile,"Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")",
name,get_user_userid(id),authid, name2,userid2,authid2,minutes,arg3 )
if ( equal(cmd[7],"ip") || (!equal(cmd[7],"id") && get_cvar_num("sv_lan")) ){
new address[32]
get_user_ip(player,address,31,1)
server_cmd("addip ^"%s^" ^"%s^";wait;writeip",minutes,address)
}
else
server_cmd("banid ^"%s^" ^"%s^" kick;wait;writeid",minutes,authid2)
new activity = get_cvar_num("amx_show_activity")
if (activity) {
new temp[64], temp2[64]
if (activity == 1)
temp = "ADMIN:"
else
format(temp,63,"ADMIN %s:",name)
if (strtonum(minutes))
format(temp2,63,"for %s min.",minutes)
else
temp2 = "permanently"
client_print(0,print_chat,"%s ban %s %s",temp,name2,temp2)
}
console_print(id,"Client ^"%s^" banned",name2)
return PLUGIN_HANDLED
}
public cmdSlay(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[32]
read_argv(1,arg,31)
new player = cmd_target(id,arg,5)
if (!player) return PLUGIN_HANDLED
user_kill(player)
new authid[32],name2[32],authid2[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
get_user_authid(player,authid2,31)
get_user_name(player,name2,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"",
name,get_user_userid(id),authid, name2,get_user_userid(player),authid2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: slay %s",name,name2)
case 1: client_print(0,print_chat,"ADMIN: slay %s",name2)
}
console_print(id,"Client ^"%s^" slayed",name2)
return PLUGIN_HANDLED
}
public cmdSlap(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[32]
read_argv(1,arg,31)
new player = cmd_target(id,arg,5)
if (!player) return PLUGIN_HANDLED
new spower[32],authid[32],name2[32],authid2[32],name[32]
read_argv(2,spower,31)
new damage = strtonum(spower)
user_slap(player,damage)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
get_user_authid(player,authid2,31)
get_user_name(player,name2,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"",
name,get_user_userid(id),authid, damage,name2,get_user_userid(player),authid2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: slap %s with %d damage",name,name2,damage)
case 1: client_print(0,print_chat,"ADMIN: slap %s with %d damage",name2,damage)
}
console_print(id,"Client ^"%s^" slaped with %d damage",name2,damage)
return PLUGIN_HANDLED
}
public chMap(map[])
server_cmd("changelevel %s",map)
public cmdMap(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[32]
new arglen = read_argv(1,arg,31)
if ( !is_map_valid(arg) ){
console_print(id,"Map with that name not found or map is invalid")
return PLUGIN_HANDLED
}
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: changelevel %s",name,arg)
case 1: client_print(0,print_chat,"ADMIN: changelevel %s",arg)
}
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name,get_user_userid(id),authid, arg)
set_task(1.0,"chMap",0,arg,arglen+1)
return PLUGIN_HANDLED
}
onlyRcon( name[] ) {
for(new a = 0; a < g_cvarRconNum; ++a)
if ( equal( g_cvarRcon[a] , name) )
return 1
return 0
}
public cmdCvar(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[32], arg2[64]
read_argv(1,arg,31)
read_argv(2,arg2,63)
if ( equal(arg,"add") && (get_user_flags(id) & ADMIN_RCON) ) {
if ( cvar_exists(arg2) ){
if ( g_cvarRconNum < MAXRCONCVARS )
copy( g_cvarRcon[ g_cvarRconNum++ ] , 31, arg2 )
else
console_print(id,"Can't add more cvars for rcon access!")
}
return PLUGIN_HANDLED
}
if (!cvar_exists(arg)){
console_print(id,"Unknown cvar: %s",arg)
return PLUGIN_HANDLED
}
if ( onlyRcon(arg) && !(get_user_flags(id) & ADMIN_RCON)){
console_print(id,"You have no access to that cvar")
return PLUGIN_HANDLED
}
else if (equal(arg,"sv_password") && !(get_user_flags(id) & ADMIN_PASSWORD)){
console_print(id,"You have no access to that cvar")
return PLUGIN_HANDLED
}
if (read_argc() < 3){
get_cvar_string(arg,arg2,63)
console_print(id,"Cvar ^"%s^" is ^"%s^"",arg,arg2)
return PLUGIN_HANDLED
}
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")",
name,get_user_userid(id),authid, arg,arg2)
set_cvar_string(arg,arg2)
new activity = get_cvar_num("amx_show_activity")
if (activity) {
new temp[64]
if (activity == 1)
temp = "ADMIN:"
else
format(temp,63,"ADMIN %s:",name)
client_print(0,print_chat,"%s set cvar %s to ^"%s^"",temp,arg,equal(arg,"rcon_password") ? "*** PROTECTED ***" : arg2)
}
console_print(id,"Cvar ^"%s^" changed to ^"%s^"",arg,arg2)
return PLUGIN_HANDLED
}
public cmdCfg(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[128]
read_argv(1,arg,127)
if (!file_exists(arg)){
console_print(id,"File ^"%s^" not found",arg)
return PLUGIN_HANDLED
}
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" execute cfg (file ^"%s^")",
name,get_user_userid(id),authid, arg)
console_print(id,"Executing file ^"%s^"",arg)
server_cmd("exec %s",arg)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: execute config %s",name,arg)
case 1: client_print(0,print_chat,"ADMIN: execute config %s",arg)
}
return PLUGIN_HANDLED
}
public cmdLBack(){
set_cvar_float("pausable",g_pausAble)
console_print(g_pauseCon,"Server %s", g_Paused ? "unpaused" : "paused")
g_Paused = !g_Paused
return PLUGIN_HANDLED
}
public cmdPause(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new authid[32],name[32],slayer = id
get_user_authid(id,authid,31)
get_user_name(id,name,31)
g_pausAble = get_cvar_float("pausable")
if (!slayer) slayer = find_player("h")
if (!slayer){
console_print(id,"Server was unable to pause the game. Real players on server are needed")
return PLUGIN_HANDLED
}
set_cvar_float("pausable",1.0)
client_cmd(slayer,"pause;pauseAck")
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" %s server",
name,get_user_userid(id),authid, g_Paused ? "unpause" : "pause" )
console_print(id,"Server proceed %s", g_Paused ? "unpausing" : "pausing")
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: %s server",name,g_Paused ? "unpause" : "pause")
case 1: client_print(0,print_chat,"ADMIN: %s server",g_Paused ? "unpause" : "pause")
}
g_pauseCon = id
return PLUGIN_HANDLED
}
public cmdRcon(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new arg[128],authid[32],name[32]
read_args(arg,127)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" server console (cmdline ^"%s^")",
name,get_user_userid(id),authid, arg)
console_print(id,"Commmand line ^"%s^" sent to server console",arg)
server_cmd(arg)
return PLUGIN_HANDLED
}
public cmdWho(id,level,cid){
new players[32], inum, authid[32],name[32], flags, sflags[32]
get_players(players,inum)
console_print(id,"^nClients on server:^n # %-16.15s %-12s %-8s %-4.3s %-4.3s %s",
"nick","authid","userid","imm","res","access")
for(new a = 0; a < inum; ++a) {
get_user_authid(players[a],authid,31)
get_user_name(players[a],name,31)
flags = get_user_flags(players[a])
get_flags(flags,sflags,31)
console_print(id,"%2d %-16.15s %-12s %-8d %-4.3s %-4.3s %s", players[a],name,authid,
get_user_userid(players[a]),(flags&ADMIN_IMMUNITY)?"yes":"no",
(flags&ADMIN_RESERVATION)?"yes":"no",sflags)
}
console_print(id,"Total %d",inum)
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" ask for players list",name,get_user_userid(id),authid)
return PLUGIN_HANDLED
}
hasTag(name[],tags[4][32],tagsNum){
for(new a=0;a<tagsNum;++a)
if (contain(name,tags[a])!=-1)
return a
return -1
}
public cmdLeave(id,level,cid){
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new argnum = read_argc()
new ltags[4][32]
new ltagsnum = 0
for(new a=1;a<5;++a){
if (a<argnum)
read_argv(a,ltags[ltagsnum++],31)
else
ltags[ltagsnum++][0] = 0
}
new nick[32], ires, pnum = get_maxplayers() + 1, count = 0
for(new b=1;b<pnum;++b){
if (!is_user_connected(b)&&!is_user_connecting(b)) continue
get_user_name(b,nick,31)
ires = hasTag(nick,ltags,ltagsnum)
if (ires!=-1){
console_print(id,"Skipping ^"%s^" (matching ^"%s^")",nick,ltags[ires])
continue
}
if (get_user_flags(b)&ADMIN_IMMUNITY){
console_print(id,"Skipping ^"%s^" (immunity)",nick)
continue
}
console_print(id,"Kicking ^"%s^"",nick)
if (is_user_bot(b))
server_cmd("kick #%d",get_user_userid(b))
else
client_cmd(b,"echo * You have been dropped because admin has left only specified group of clients;disconnect")
count++
}
console_print(id,"Kicked %d clients",count)
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Kick: ^"%s<%d><%s><>^" leave some group (tag1 ^"%s^") (tag2 ^"%s^") (tag3 ^"%s^") (tag4 ^"%s^")",
name,get_user_userid(id),authid,ltags[0],ltags[1],ltags[2],ltags[3] )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: leave %s %s %s %s",name,ltags[0],ltags[1],ltags[2],ltags[3])
case 1: client_print(0,print_chat,"ADMIN: leave %s %s %s %s",ltags[0],ltags[1],ltags[2],ltags[3])
}
return PLUGIN_HANDLED
}

66
plugins/adminhelp.sma Executable file
View File

@ -0,0 +1,66 @@
/* AMX Mod script.
*
* (c) 2003, tcquest78
* This file is provided as is (no warranties).
*
* Provides help for admin commands with amx_help command
*/
#include <amxmod>
#define HELPAMOUNT 10 // Number of commands per page
new g_typeHelp[] = "Type 'amx_help' in the console to see available commands"
new g_timeInfo1[] = "Time Left: %d:%02d min. Next Map: %s"
new g_timeInfo2[] = "No Time Limit. Next Map: %s"
public plugin_init() {
register_plugin("Admin Help","0.9","tcquest78")
register_concmd("amx_help","cmdHelp",0,"- displays this help")
setHelp(0)
}
public client_putinserver(id)
setHelp(id)
public cmdHelp(id,level,cid){
new arg1[8],flags = get_user_flags(id)
new start = read_argv(1,arg1,7) ? strtonum(arg1) : 1
if (--start < 0) start = 0
new clcmdsnum = get_concmdsnum(flags,id)
if (start >= clcmdsnum) start = clcmdsnum - 1
console_print(id,"^n----- AMX Help: Commands -----")
new info[128], cmd[32], eflags
new end = start + HELPAMOUNT
if (end > clcmdsnum) end = clcmdsnum
for (new i = start; i < end; i++){
get_concmd(i,cmd,31,eflags,info,127,flags,id)
console_print(id,"%3d: %s %s",i+1,cmd,info)
}
console_print(id,"----- Entries %d - %d of %d -----",start+1,end,clcmdsnum)
if (end < clcmdsnum)
console_print(id,"----- Use 'amx_help %d' for more -----",end+1)
else
console_print(id,"----- Use 'amx_help 1' for begin -----")
return PLUGIN_HANDLED
}
public dispInfo(id){
if (id) client_print(id,print_chat, g_typeHelp )
else server_print( g_typeHelp )
new nextmap[32]
get_cvar_string("amx_nextmap",nextmap,31)
if (get_cvar_float("mp_timelimit")){
new timeleft = get_timeleft()
if (timeleft > 0){
if (id) client_print(id,print_chat, g_timeInfo1 , timeleft / 60, timeleft % 60,nextmap)
else server_print( g_timeInfo1 , timeleft / 60, timeleft % 60,nextmap)
}
}
else if (id) client_print(id,print_chat, g_timeInfo2 ,nextmap)
else server_print( g_timeInfo2 ,nextmap)
}
setHelp(id)
set_task(15.0,"dispInfo",id)

88
plugins/adminslots.sma Executable file
View File

@ -0,0 +1,88 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Kick a player without reservation who tries
* to enter to one of the reservered slots set
* by amx_reservation cvar.
*
* Cvar:
* amx_reservation <value> - sets amount of reserved slots.
*/
#include <amxmod>
#include <amxmisc>
// Comment if you don't want to hide not used reserved slots
#define HIDE_RESERVED_SLOTS
new g_cmdLoopback[16]
public plugin_init()
{
register_plugin("Slots Reservation","0.9.7","default")
register_cvar("amx_reservation","1")
format( g_cmdLoopback, 15, "amxres%c%c%c%c" ,
random_num('A','Z') , random_num('A','Z') ,random_num('A','Z'),random_num('A','Z') )
register_clcmd( g_cmdLoopback, "ackSignal" )
}
#if !defined NO_STEAM
public ackSignal(id)
server_cmd("kick #%d", get_user_userid(id) )
public client_authorized(id)
#else
public client_connect(id)
#endif
{
new maxplayers = get_maxplayers( )
new players = get_playersnum( 1 )
new limit = maxplayers - get_cvar_num( "amx_reservation" )
if ( (get_user_flags(id) & ADMIN_RESERVATION) || (players <= limit) )
{
#if defined HIDE_RESERVED_SLOTS
setVisibleSlots( players , maxplayers, limit )
#endif
return PLUGIN_CONTINUE
}
#if !defined NO_STEAM
client_cmd(id,"echo ^"Dropped due to slot reservation^";%s" , g_cmdLoopback)
#else
if ( is_user_bot(id) )
server_cmd("kick #%d", get_user_userid(id) )
else
client_cmd(id,"echo ^"Dropped due to slot reservation^";disconnect")
#endif
return PLUGIN_HANDLED
}
#if defined HIDE_RESERVED_SLOTS
public client_disconnect(id)
{
new maxplayers = get_maxplayers( )
setVisibleSlots( get_playersnum(1) - 1 , maxplayers ,
maxplayers - get_cvar_num( "amx_reservation" ) )
return PLUGIN_CONTINUE
}
setVisibleSlots( players , maxplayers , limit )
{
new num = players + 1
if ( players == maxplayers )
num = maxplayers
else if ( players < limit )
num = limit
set_cvar_num( "sv_visiblemaxplayers" , num )
}
#endif

370
plugins/adminvote.sma Executable file
View File

@ -0,0 +1,370 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* I. Vote for changing the level:
* amx_votemap < map > [ map ] [ map ] [ map ]
*
* Examples:
* amx_votemap "de_dust"
* amx_votemap "de_dust" "de_dust2" "cs_italy"
*
* II. Vote for kicking the player:
* amx_votekick <name or #userid>
*
* Examples:
* amx_votekick "Player"
*
* III. Vote for banning and kicking the player for 30 minutes:
* amx_voteban <name or #userid>
*
* Examples:
* amx_voteban "Player"
*
* IV. Custom voting:
* amx_vote < question > < g_Answer1 > < g_Answer2 >
*
* Examples:
* amx_vote "sv_restart" "5" "0"
* amx_vote "mp_timelimit" "20" "45"
* amx_vote "are you hungry?" "yes" "no"
*
*/
#include <amxmod>
#include <amxmisc>
new g_Answer[128]
new g_optionName[4][32]
new g_voteCount[4]
new g_validMaps
new g_yesNoVote
new g_logFile[16]
new g_cstrikeRunning
new g_voteCaller
new g_Execute[256]
new g_execLen
new g_alredyVoting[]= "There is already one voting..."
new g_notAllowed[] = "Voting not allowed at this time"
new g_votingStarted[] = "Voting has started..."
new g_playerTag[] = "PLAYER"
new g_adminTag[] = "ADMIN"
new bool:g_execResult
new Float:g_voteRatio
public plugin_init() {
register_plugin("Admin Votes","0.9","default")
register_menucmd(register_menuid("Change map to ") ,(1<<0)|(1<<1),"voteCount")
register_menucmd(register_menuid("Choose map: ") ,(1<<0)|(1<<1)|(1<<2)|(1<<3),"voteCount")
register_menucmd(register_menuid("Kick ") ,(1<<0)|(1<<1),"voteCount")
register_menucmd(register_menuid("Ban ") ,(1<<0)|(1<<1),"voteCount")
register_menucmd(register_menuid("Vote: ") ,(1<<0)|(1<<1),"voteCount")
register_menucmd(register_menuid("The result: ") ,(1<<0)|(1<<1),"actionResult")
register_concmd("amx_votemap","cmdVoteMap",ADMIN_VOTE,"<map> [map] [map] [map]")
register_concmd("amx_votekick","cmdVoteKickBan",ADMIN_VOTE,"<name or #userid>")
register_concmd("amx_voteban","cmdVoteKickBan",ADMIN_VOTE,"<name or #userid>")
register_concmd("amx_vote","cmdVote",ADMIN_VOTE,"<question> <answer#1> <answer#2>")
register_concmd("amx_cancelvote","cmdCancelVote",ADMIN_VOTE,"- cancels last vote")
register_cvar("amx_votekick_ratio","0.40")
register_cvar("amx_voteban_ratio","0.40")
register_cvar("amx_votemap_ratio","0.40")
register_cvar("amx_vote_ratio","0.02")
register_cvar("amx_vote_time","10")
register_cvar("amx_vote_answers","1")
register_cvar("amx_vote_delay","60")
register_cvar("amx_last_voting","0")
set_cvar_float("amx_last_voting",0.0)
register_cvar("amx_show_activity","2")
g_cstrikeRunning = is_running("cstrike")
get_logfile(g_logFile,15)
}
public cmdCancelVote(id,level,cid){
if (!cmd_access(id,level,cid,0))
return PLUGIN_HANDLED
if ( task_exists( 99889988 , 1 ) ) {
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Vote: ^"%s<%d><%s><>^" cancel vote session", name,get_user_userid(id),authid)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%s %s: cancel vote", (get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag, name)
case 1: client_print(0,print_chat,"%s: cancel vote", (get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag)
}
console_print(id, "Voting canceled" )
client_print(0,print_chat,"Voting canceled")
remove_task( 99889988 , 1 )
set_cvar_float( "amx_last_voting" , get_gametime() )
}
else
console_print(id, "There is no voting to cancel or the vote session can't be canceled with that command" )
return PLUGIN_HANDLED
}
public delayedExec(cmd[])
server_cmd(cmd)
new g_resultRef[] = "Result refused"
new g_resultAcpt[] = "Result accepted"
new g_votingFailed[] = "Voting failed"
new g_votingSuccess[] = "Voting successful"
public autoRefuse(){
log_to_file(g_logFile,"Vote: %s" , g_resultRef)
client_print(0,print_chat,g_resultRef )
}
public actionResult(id,key) {
remove_task( 4545454 )
switch(key){
case 0: {
set_task(2.0,"delayedExec",0,g_Execute,g_execLen)
log_to_file(g_logFile,"Vote: %s",g_resultAcpt)
client_print(0,print_chat,g_resultAcpt )
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
}
public checkVotes() {
new best = 0
if ( !g_yesNoVote ) {
for(new a = 0; a < 4; ++a)
if (g_voteCount[a] > g_voteCount[best])
best = a
}
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3]
new iRatio = votesNum ? floatround( g_voteRatio * float( votesNum ) ,floatround_ceil) : 1
new iResult = g_voteCount[best]
if ( iResult < iRatio ){
if (g_yesNoVote)
client_print(0,print_chat,"%s (yes ^"%d^") (no ^"%d^") (needed ^"%d^")",g_votingFailed, g_voteCount[0], g_voteCount[1] , iRatio )
else
client_print(0,print_chat,"%s (got ^"%d^") (needed ^"%d^")",g_votingFailed,iResult , iRatio )
log_to_file(g_logFile,"Vote: %s (got ^"%d^") (needed ^"%d^")",g_votingFailed,iResult , iRatio )
return PLUGIN_CONTINUE
}
g_execLen = format(g_Execute,255,g_Answer,g_optionName[best]) + 1
if (g_execResult){
g_execResult = false
if ( is_user_connected(g_voteCaller) ) {
new menuBody[512]
new len = format(menuBody,511,g_cstrikeRunning ? "\yThe result: \w%s^n^n" : "The result: %s^n^n", g_Execute )
len += copy( menuBody[len] ,511 - len, g_cstrikeRunning ? "\yDo you want to continue?^n\w" : "Do you want to continue?^n" )
copy( menuBody[len] ,511 - len, "^n1. Yes^n2. No")
show_menu( g_voteCaller ,0x03 ,menuBody, 10 )
set_task(10.0,"autoRefuse",4545454)
}
else
set_task(2.0,"delayedExec",0,g_Execute,g_execLen)
}
client_print(0,print_chat,"%s (got ^"%d^") (needed ^"%d^"). The result: %s", g_votingSuccess, iResult , iRatio , g_Execute )
log_to_file(g_logFile,"Vote: %s (got ^"%d^") (needed ^"%d^") (result ^"%s^")", g_votingSuccess, iResult , iRatio , g_Execute )
return PLUGIN_CONTINUE
}
public voteCount(id,key){
if ( get_cvar_num("amx_vote_answers") ) {
new name[32]
get_user_name(id,name,31)
if (g_yesNoVote)
client_print(0,print_chat,"%s voted %s",name,key ? "against" : "for" )
else
client_print(0,print_chat,"%s voted for option #%d",name,key+1)
}
++g_voteCount[key]
return PLUGIN_HANDLED
}
public cmdVoteMap(id,level,cid) {
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime()){
console_print(id, g_alredyVoting )
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
console_print(id, g_notAllowed )
return PLUGIN_HANDLED
}
new argc = read_argc()
if (argc > 5) argc = 5
g_validMaps = 0
g_optionName[0][0] = g_optionName[1][0] = g_optionName[2][0] = g_optionName[3][0] = 0
for(new i = 1; i < argc; ++i){
read_argv(i,g_optionName[g_validMaps],31)
if (is_map_valid(g_optionName[g_validMaps]))
g_validMaps++;
}
if (g_validMaps == 0) {
console_print(id,"Given %s not valid",(argc==2)?"map is":"maps are")
return PLUGIN_HANDLED
}
new menu_msg[256]
new keys = 0
if (g_validMaps > 1){
keys = (1<<9)
copy(menu_msg,255,g_cstrikeRunning ? "\yChoose map: \w^n^n" : "Choose map: ^n^n")
new temp[128]
for(new a = 0; a < g_validMaps; ++a){
format(temp,127,"%d. %s^n",a+1,g_optionName[a])
add(menu_msg,255,temp)
keys |= (1<<a)
}
add(menu_msg,255,"^n0. None")
g_yesNoVote = 0
}
else{
format(menu_msg,255,g_cstrikeRunning ? "\yChange map to %s?\w^n^n1. Yes^n2. No"
: "Change map to %s?^n^n1. Yes^n2. No",g_optionName[0])
keys = (1<<0)|(1<<1)
g_yesNoVote = 1
}
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
if (argc==2)
log_to_file(g_logFile,"Vote: ^"%s<%d><%s><>^" vote map (map ^"%s^")",
name,get_user_userid(id),authid,g_optionName[0])
else
log_to_file(g_logFile,"Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
name,get_user_userid(id),authid,g_optionName[0],g_optionName[1],g_optionName[2],g_optionName[3])
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%s %s: vote map(s)",name,
(get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag)
case 1: client_print(0,print_chat,"%s: vote map(s)",
(get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag)
}
g_execResult = true
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time )
g_voteRatio = get_cvar_float("amx_votemap_ratio")
g_Answer = "changelevel %s"
show_menu(0,keys,menu_msg,floatround(vote_time))
set_task(vote_time,"checkVotes" , 99889988 )
g_voteCaller = id
console_print(id, g_votingStarted )
g_voteCount = { 0,0, 0,0 }
return PLUGIN_HANDLED
}
public cmdVote(id,level,cid) {
if (!cmd_access(id,level,cid,4))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime()){
console_print(id, g_alredyVoting )
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
console_print(id, g_notAllowed )
return PLUGIN_HANDLED
}
new quest[48]
read_argv(1,quest,47)
if ((contain(quest,"sv_password")!=-1)||(contain(quest,"rcon_password")!=-1)||
(contain(quest,"kick")!=-1)||(contain(quest,"addip")!=-1)||(contain(quest,"ban")!=-1)){
console_print(id,"Voting for that has been forbidden")
return PLUGIN_HANDLED
}
read_argv(2,g_optionName[0],31)
read_argv(3,g_optionName[1],31)
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Vote: ^"%s<%d><%s><>^" vote custom (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")",
name,get_user_userid(id),authid,quest,g_optionName[0],g_optionName[1])
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%s %s: vote custom",
(get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag,name )
case 1: client_print(0,print_chat,"%s: vote custom",
(get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag)
}
new menu_msg[256]
new keys = (1<<0)|(1<<1)
format(menu_msg,255, g_cstrikeRunning ? "\yVote: %s\w^n^n1. %s^n2. %s"
: "Vote: %s^n^n1. %s^n2. %s",quest,g_optionName[0],g_optionName[1])
g_execResult = false
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time )
g_voteRatio = get_cvar_float("amx_vote_ratio")
format(g_Answer,127,"%s - %%s",quest)
show_menu(0,keys,menu_msg,floatround(vote_time))
set_task(vote_time,"checkVotes" , 99889988 )
g_voteCaller = id
console_print(id, g_votingStarted )
g_voteCount ={ 0,0,0,0}
g_yesNoVote = 0
return PLUGIN_HANDLED
}
public cmdVoteKickBan(id,level,cid) {
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime()){
console_print(id, g_alredyVoting )
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
console_print(id, g_notAllowed )
return PLUGIN_HANDLED
}
new cmd[32]
read_argv(0,cmd,31)
new voteban = equal(cmd,"amx_voteban")
new arg[32]
read_argv(1,arg,31)
new player = cmd_target(id,arg,1)
if (!player) return PLUGIN_HANDLED
if (voteban && is_user_bot(player)) {
new imname[32]
get_user_name(player,imname,31)
console_print(id,"That action can't be performed on bot ^"%s^"",imname)
return PLUGIN_HANDLED
}
new keys = (1<<0)|(1<<1)
new menu_msg[256]
get_user_name(player,arg,31)
format(menu_msg,255,g_cstrikeRunning ? "\y%s %s?\w^n^n1. Yes^n2. No"
: "%s %s?^n^n1. Yes^n2. No", voteban ? "Ban" : "Kick", arg)
g_yesNoVote = 1
if (voteban)
get_user_authid(player,g_optionName[0],31)
else
numtostr(get_user_userid(player),g_optionName[0],31)
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Vote: ^"%s<%d><%s><>^" vote %s (target ^"%s^")",
name,get_user_userid(id),authid,voteban ? "ban" : "kick",arg)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%s %s: vote %s for %s",
(get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag,name,voteban ? "ban" : "kick",arg )
case 1: client_print(0,print_chat,"%s: vote %s for %s",
(get_user_flags(id) & ADMIN_USER) ? g_playerTag : g_adminTag,voteban ? "ban" : "kick",arg)
}
g_execResult = true
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time )
g_voteRatio = get_cvar_float(voteban ? "amx_voteban_ratio" : "amx_votekick_ratio")
g_Answer = voteban ? "banid 30.0 %s kick" : "kick #%s"
show_menu(0,keys,menu_msg,floatround(vote_time))
set_task(vote_time,"checkVotes" , 99889988 )
g_voteCaller = id
console_print(id, g_votingStarted )
g_voteCount = {0,0,0,0}
return PLUGIN_HANDLED
}

41
plugins/antiflood.sma Executable file
View File

@ -0,0 +1,41 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Cvar:
* amx_flood_time <time in sec.> - set frequency of chating
*/
#include <amxmod>
new Float:g_Flooding[33]
public plugin_init()
{
register_plugin("Anti Flood","0.9","default")
register_clcmd("say","chkFlood")
register_clcmd("say_team","chkFlood")
register_cvar("amx_flood_time","0.75")
}
public chkFlood(id)
{
new Float:maxChat = get_cvar_float("amx_flood_time")
if ( maxChat )
{
new Float:nexTime = get_gametime()
if ( g_Flooding[id] > nexTime )
{
client_print( id , print_notify , "** Stop flooding the server!" )
g_Flooding[ id ] = nexTime + maxChat + 3.0
return PLUGIN_HANDLED
}
g_Flooding[id] = nexTime + maxChat
}
return PLUGIN_CONTINUE
}

373
plugins/cmdmenu.sma Executable file
View File

@ -0,0 +1,373 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
#include <amxmisc>
/* Commands Menus */
#define MAX_CMDS_LAYERS 3
new g_cmdMenuName[ MAX_CMDS_LAYERS ][ ] = {
"Commands Menu",
"Configs Menu",
"Speech Menu"
}
new g_cmdMenuCmd[ MAX_CMDS_LAYERS ][ ] = {
"amx_cmdmenu",
"amx_cfgmenu",
"amx_speechmenu"
}
new g_cmdMenuCfg[ MAX_CMDS_LAYERS ][ ] = {
"cmds.ini",
"configs.ini",
"speech.ini"
}
new g_cmdMenuHelp[ MAX_CMDS_LAYERS ][ ] = {
"- displays commands menu",
"- displays configs menu",
"- displays speech menu"
}
/* End of Commands Menu */
#define MAX_CMDS 32
#define MAX_CVARS 32
new g_cmdName[MAX_CMDS*MAX_CMDS_LAYERS][32]
new g_cmdCmd[MAX_CMDS*MAX_CMDS_LAYERS][64]
new g_cmdMisc[MAX_CMDS*MAX_CMDS_LAYERS][2]
new g_cmdNum[MAX_CMDS_LAYERS]
new g_cvarNames[MAX_CVARS][32]
new g_cvarMisc[MAX_CVARS][3]
new g_cvarCmd[MAX_CVARS*5][32]
new g_cvarCmdNum
new g_cvarNum
new g_menuPosition[33]
new g_menuSelect[33][64]
new g_menuSelectNum[33]
new g_menuLayer[33]
new g_cstrikeRunning
public plugin_init()
{
register_plugin("Commands Menu","0.9","default")
new basedir[32], workdir[64]
get_basedir( basedir , 31 )
for(new a = 0; a < MAX_CMDS_LAYERS; ++a) {
register_menucmd(register_menuid( g_cmdMenuName[ a ] ),1023,"actionCmdMenu")
register_clcmd( g_cmdMenuCmd[ a ] ,"cmdCmdMenu",ADMIN_MENU, g_cmdMenuHelp[ a ] )
format( workdir, 63, "%s/%s" , basedir , g_cmdMenuCfg[ a ] )
loadCmdSettings( workdir , a )
}
register_menucmd(register_menuid("Cvars Menu"),1023,"actionCvarMenu")
register_clcmd("amx_cvarmenu","cmdCvarMenu",ADMIN_CVAR,"- displays cvars menu")
format( workdir, 63, "%s/cvars.ini" , basedir )
loadCvarSettings( workdir )
g_cstrikeRunning = is_running("cstrike")
}
/* Commands menu */
public actionCmdMenu(id,key)
{
switch(key){
case 8: displayCmdMenu(id,++g_menuPosition[id])
case 9: displayCmdMenu(id,--g_menuPosition[id])
default:{
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new flags = g_cmdMisc[ option ][ 1 ]
if ( flags & 1)
server_cmd( g_cmdCmd[ option ] )
else if ( flags & 2)
client_cmd(id, g_cmdCmd[ option ] )
else if ( flags & 4)
client_cmd(0, g_cmdCmd[ option ] )
if ( flags & 8 ) displayCmdMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayCmdMenu(id,pos){
if (pos < 0) return
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511,g_cstrikeRunning ?
"\y%s\R%d/%d^n\w^n" : "%s %d/%d^n^n" , g_cmdMenuName[ g_menuLayer[id] ],
pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) )
new end = start + 8
new keys = (1<<9)
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for(new a = start; a < end; ++a)
{
if ( g_cmdCmd[ g_menuSelect[id][ a ] ][0] == '-' )
{
if ( g_cstrikeRunning)
len += format(menuBody[len],511-len,"\d%s^n\w",g_cmdName[ g_menuSelect[id][ a ] ] )
else
len += format(menuBody[len],511-len,"%s^n",g_cmdName[ g_menuSelect[id][ a ] ] )
++b
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_cmdName[ g_menuSelect[id][ a ] ] )
}
}
if (end != g_menuSelectNum[id]) {
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit" )
show_menu(id,keys,menuBody)
}
public cmdCmdMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new szCmd[32]
read_argv(0, szCmd, 31)
new lvl = 0
while( lvl < MAX_CMDS_LAYERS )
{
if ( equal( g_cmdMenuCmd[ lvl ], szCmd ) )
break
++lvl
}
g_menuLayer[ id ] = lvl
new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
new a = lvl * MAX_CMDS
new d , c = 0
while( c < g_cmdNum[ lvl ] )
{
d = a + c
if ( g_cmdMisc[ d ][0] & flags )
{
g_menuSelect[id][ g_menuSelectNum[id]++ ] = d
}
++c
}
displayCmdMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
loadCmdSettings( szFilename[], level )
{
if ( !file_exists ( szFilename ) )
return 0
new text[256], szFlags[32], szAccess[32]
new a, pos = 0, c, d = level * MAX_CMDS
while ( g_cmdNum[ level ] < MAX_CMDS && read_file (szFilename,pos++,text,255,a) )
{
if ( text[0] == ';' ) continue
c = d + g_cmdNum[ level ]
if ( parse( text , g_cmdName[ c ] , 31 ,
g_cmdCmd[ c ] ,63,szFlags,31,szAccess,31 ) > 3 )
{
while ( replace( g_cmdCmd[ c ] ,63,"\'","^"") ) {
// do nothing
}
g_cmdMisc[ c ][ 1 ] = read_flags ( szFlags )
g_cmdMisc[ c ][ 0 ] = read_flags ( szAccess )
g_cmdNum[ level ]++
}
}
return 1
}
/* Cvars menu */
public actionCvarMenu(id,key)
{
switch(key){
case 8: displayCvarMenu(id,++g_menuPosition[id])
case 9: displayCvarMenu(id,--g_menuPosition[id])
default:{
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new szValue[32]
get_cvar_string( g_cvarNames[ option ], szValue ,31)
new end = g_cvarMisc[ option ][ 2 ]
new start = g_cvarMisc[ option ][ 1 ]
for(new i = start ; ; ++i )
{
if ( i < end )
{
if ( equal( szValue , g_cvarCmd[ i ] ) )
{
if (++i >= end)
{
i = start
}
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ i ] )
break
}
}
else
{
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ start ] )
break
}
}
displayCvarMenu(id, g_menuPosition[id] )
}
}
return PLUGIN_HANDLED
}
displayCvarMenu(id,pos){
if (pos < 0) return
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n",
pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) )
new end = start + 8
new keys = (1<<9)
new szValue[64]
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for(new a = start; a < end; ++a)
{
get_cvar_string( g_cvarNames[ g_menuSelect[id][ a ] ],szValue,31)
keys |= (1<<b)
++b
if ( g_cstrikeRunning )
len += format(menuBody[len],511-len,"%d. %s\R%s^n\w", b, g_cvarNames[ g_menuSelect[id][ a ] ], szValue )
else
len += format(menuBody[len],511-len,"%d. %s %s^n", b, g_cvarNames[ g_menuSelect[id][ a ] ], szValue )
}
if (end != g_menuSelectNum[id]) {
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
public cmdCvarMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
for(new a = 0; a < g_cvarNum; ++a)
if ( g_cvarMisc[ a ][0] & flags )
g_menuSelect[id][ g_menuSelectNum[id]++ ] = a
displayCvarMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
loadCvarSettings( szFilename[] )
{
if ( !file_exists ( szFilename ) )
return 0
new text[256], szValues[12][32]
new inum , a, pos = 0
new cvar_values = MAX_CVARS * 5
// a b c d
while ( g_cvarNum < MAX_CVARS && read_file (szFilename,pos++,text,255,a) )
{
if ( text[0] == ';' ) continue
inum = parse( text , g_cvarNames[ g_cvarNum ] , 31 ,
szValues[0] ,31 , szValues[1] ,31 , szValues[2] ,31 ,
szValues[3] ,31 , szValues[4] ,31 , szValues[5] ,31 ,
szValues[6] ,31 , szValues[7] ,31 , szValues[8] ,31 ,
szValues[9] ,31 , szValues[10] ,31 , szValues[11] ,31 )
inum -= 2
if ( inum < 2 ) continue
g_cvarMisc[ g_cvarNum ][1] = g_cvarCmdNum
for( a = 0 ; a < inum && g_cvarCmdNum < cvar_values ; ++a )
{
while ( replace( szValues[ a ] ,31 , "\'" , "^"" ) ) {
// do nothing
}
copy ( g_cvarCmd[ g_cvarCmdNum ] , 31 , szValues[ a ] )
g_cvarCmdNum++
}
g_cvarMisc[ g_cvarNum ][2] = g_cvarCmdNum
g_cvarMisc[ g_cvarNum ][0] = read_flags( szValues[ inum ] )
g_cvarNum++
}
return 1
}

12
plugins/compile.bat Executable file
View File

@ -0,0 +1,12 @@
@echo off
if not exist compiled mkdir compiled
if exist temp.txt del temp.txt
for %%i in (*.sma) do sc %%i -ocompiled\%%i >> temp.txt
copy compiled\*.sma compiled\*.amx
del compiled\*.sma
cls
type temp.txt
del temp.txt
pause

6
plugins/compile.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
test -e compiled || mkdir compiled
ls *.sma | xargs -i ./sc \{\} -ocompiled/\{\} > temp.txt
ls compiled/*.sma | xargs -i basename \{\} .sma | xargs -i mv compiled/\{\}.sma compiled/\{\}.amx
more temp.txt
rm temp.txt

26
plugins/csstats.sma Executable file
View File

@ -0,0 +1,26 @@
/* Get Score for CS STATS.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Function calculates position in rank.
*
* Stats:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
*
* Returning cellmin as value in get_score function
* makes that rank won't be saved.
*
* File location: $moddir/addons/amx
*/
#include <amxmod>
public get_score( stats[8] , body[8] )
return stats[0] - stats[1] // kills - deaths

76
plugins/imessage.sma Executable file
View File

@ -0,0 +1,76 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Server command:
* amx_imessage <msg> <colour in RRRGGGBBB format>
*
*/
#include <amxmod>
#include <amxmisc>
#define MAX_MESSAGES 6
#define X_POS -1.0
#define Y_POS 0.30
#define HOLD_TIME 12.0
new g_Values[MAX_MESSAGES][3]
new g_Messages[MAX_MESSAGES][384]
new g_MessagesNum
new g_Current
public plugin_init(){
register_plugin("Info. Messages","0.9","default")
register_srvcmd("amx_imessage","setMessage")
register_cvar("amx_freq_imessage","10")
new lastinfo[8]
get_localinfo("lastinfomsg",lastinfo,7)
g_Current = strtonum(lastinfo)
set_localinfo("lastinfomsg","")
}
public infoMessage(){
if (g_Current >= g_MessagesNum)
g_Current = 0
set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2],
X_POS, Y_POS, 0, 0.5, HOLD_TIME , 2.0, 2.0, 1)
show_hudmessage(0,g_Messages[g_Current])
client_print(0,print_console,g_Messages[g_Current])
++g_Current
new Float:freq_im = get_cvar_float("amx_freq_imessage")
if ( freq_im > 0.0 ) set_task( freq_im ,"infoMessage",12345)
}
public setMessage(id,level,cid) {
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
if (g_MessagesNum >= MAX_MESSAGES) {
console_print(id,"Information Messages limit reached!")
return PLUGIN_HANDLED
}
remove_task(12345)
read_argv(1,g_Messages[g_MessagesNum],380)
new hostname[64]
get_cvar_string("hostname",hostname,63)
replace(g_Messages[g_MessagesNum],380,"%hostname%",hostname)
while(replace(g_Messages[g_MessagesNum],380,"\n","^n")){}
new mycol[12]
read_argv(2,mycol,11) // RRRGGGBBB
g_Values[g_MessagesNum][2] = strtonum(mycol[6])
mycol[6] = 0
g_Values[g_MessagesNum][1] = strtonum(mycol[3])
mycol[3] = 0
g_Values[g_MessagesNum][0] = strtonum(mycol[0])
g_MessagesNum++
new Float:freq_im = get_cvar_float("amx_freq_imessage")
if ( freq_im > 0.0 ) set_task( freq_im ,"infoMessage",12345)
return PLUGIN_HANDLED
}
public plugin_end(){
new lastinfo[8]
numtostr(g_Current,lastinfo,7)
set_localinfo("lastinfomsg",lastinfo)
}

205
plugins/include/amxconst.inc Executable file
View File

@ -0,0 +1,205 @@
/* AMX Mod
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _amxconst_included
#endinput
#endif
#define _amxconst_included
// Uncomment if you are not using Steam
//#define NO_STEAM
#define ADMIN_IMMUNITY (1<<0) /* flag "a" */
#define ADMIN_RESERVATION (1<<1) /* flag "b" */
#define ADMIN_KICK (1<<2) /* flag "c" */
#define ADMIN_BAN (1<<3) /* flag "d" */
#define ADMIN_SLAY (1<<4) /* flag "e" */
#define ADMIN_MAP (1<<5) /* flag "f" */
#define ADMIN_CVAR (1<<6) /* flag "g" */
#define ADMIN_CFG (1<<7) /* flag "h" */
#define ADMIN_CHAT (1<<8) /* flag "i" */
#define ADMIN_VOTE (1<<9) /* flag "j" */
#define ADMIN_PASSWORD (1<<10) /* flag "k" */
#define ADMIN_RCON (1<<11) /* flag "l" */
#define ADMIN_LEVEL_A (1<<12) /* flag "m" */
#define ADMIN_LEVEL_B (1<<13) /* flag "n" */
#define ADMIN_LEVEL_C (1<<14) /* flag "o" */
#define ADMIN_LEVEL_D (1<<15) /* flag "p" */
#define ADMIN_LEVEL_E (1<<16) /* flag "q" */
#define ADMIN_LEVEL_F (1<<17) /* flag "r" */
#define ADMIN_LEVEL_G (1<<18) /* flag "s" */
#define ADMIN_LEVEL_H (1<<19) /* flag "t" */
#define ADMIN_MENU (1<<20) /* flag "u" */
#define ADMIN_USER (1<<25) /* flag "z" */
#define FLAG_KICK (1<<0) /* flag "a" */
#define FLAG_TAG (1<<1) /* flag "b" */
#define FLAG_AUTHID (1<<2) /* flag "c" */
#define FLAG_IP (1<<3) /* flag "d" */
#define FLAG_NOPASS (1<<4) /* flag "e" */
#define PLUGIN_CONTINUE 0 /* Results returned by public functions */
#define PLUGIN_HANDLED 1 /* stop other plugins */
#define PLUGIN_HANDLED_MAIN 2 /* to use in client_command(), continue all plugins but stop the command */
/* Destination types for message_begin() */
#define MSG_BROADCAST 0 /* unreliable to all */
#define MSG_ONE 1 /* reliable to one (msg_entity) */
#define MSG_ALL 2 /* reliable to all */
#define MSG_INIT 3 /* write to the init string */
#define MSG_PVS 4 /* Ents in PVS of org */
#define MSG_PAS 5 /* Ents in PAS of org */
#define MSG_PVS_R 6 /* Reliable to PVS */
#define MSG_PAS_R 7 /* Reliable to PAS */
#define MSG_ONE_UNRELIABLE 8 /* Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) */
#define MSG_SPEC 9 /* Sends to all spectator proxies */
/* Message types for message_begin() */
#define SVC_TEMPENTITY 23
#define SVC_INTERMISSION 30
#define SVC_CDTRACK 32
#define SVC_WEAPONANIM 35
#define SVC_ROOMTYPE 37
#define SVC_ADDANGLE 38 /* [vec3] add this angle to the view angle */
#define SVC_NEWUSERMSG 39
#define SVC_HLTV 50
/* Flags for register_cvar() */
#define FCVAR_ARCHIVE 1 /* set to cause it to be saved to vars.rc */
#define FCVAR_USERINFO 2 /* changes the client's info string */
#define FCVAR_SERVER 4 /* notifies players when changed */
#define FCVAR_EXTDLL 8 /* defined by external DLL */
#define FCVAR_CLIENTDLL 16 /* defined by the client dll */
#define FCVAR_PROTECTED 32 /* It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value */
#define FCVAR_SPONLY 64 /* This cvar cannot be changed by clients connected to a multiplayer server. */
#define FCVAR_PRINTABLEONLY 128 /* This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). */
#define FCVAR_UNLOGGED 256 /* If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log */
/* Id of weapons in CS */
#define CSW_P228 1
#define CSW_SCOUT 3
#define CSW_HEGRENADE 4
#define CSW_XM1014 5
#define CSW_C4 6
#define CSW_MAC10 7
#define CSW_AUG 8
#define CSW_SMOKEGRENADE 9
#define CSW_ELITE 10
#define CSW_FIVESEVEN 11
#define CSW_UMP45 12
#define CSW_SG550 13
#define CSW_GALI 14
#define CSW_FAMAS 15
#define CSW_USP 16
#define CSW_GLOCK18 17
#define CSW_AWP 18
#define CSW_MP5NAVY 19
#define CSW_M249 20
#define CSW_M3 21
#define CSW_M4A1 22
#define CSW_TMP 23
#define CSW_G3SG1 24
#define CSW_FLASHBANG 25
#define CSW_DEAGLE 26
#define CSW_SG552 27
#define CSW_AK47 28
#define CSW_KNIFE 29
#define CSW_P90 30
/* Parts of body for hits */
#define HIT_GENERIC 0 /* none */
#define HIT_HEAD 1
#define HIT_CHEST 2
#define HIT_STOMACH 3
#define HIT_LEFTARM 4
#define HIT_RIGHTARM 5
#define HIT_LEFTLEG 6
#define HIT_RIGHTLEG 7
/* Constants for emit_sound() */
/* Channels */
#define CHAN_AUTO 0
#define CHAN_WEAPON 1
#define CHAN_VOICE 2
#define CHAN_ITEM 3
#define CHAN_BODY 4
#define CHAN_STREAM 5 /* allocate stream channel from the static or dynamic area */
#define CHAN_STATIC 6 /* allocate channel from the static area */
#define CHAN_NETWORKVOICE_BASE 7 /* voice data coming across the network */
#define CHAN_NETWORKVOICE_END 500 /* network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). */
/* Attenuation values */
#define ATTN_NONE 0.00
#define ATTN_NORM 0.80
#define ATTN_IDLE 2.00
#define ATTN_STATIC 1.25
/* Pitch values */
#define PITCH_NORM 100 /* non-pitch shifted */
#define PITCH_LOW 95 /* other values are possible - 0-255, where 255 is very high */
#define PITCH_HIGH 120
/* Volume values */
#define VOL_NORM 1.0
/* Destination types for client_print() */
enum {
print_notify = 1,
print_console,
print_chat,
print_center,
}
/* Destination types for engclient_print() */
enum {
engprint_console = 0,
engprint_center,
engprint_chat,
}
/* Render for set_user_rendering() */
enum {
kRenderNormal, /* src */
kRenderTransColor, /* c*a+dest*(1-a) */
kRenderTransTexture, /* src*a+dest*(1-a) */
kRenderGlow, /* src*a+dest -- No Z buffer checks */
kRenderTransAlpha, /* src*srca+dest*(1-srca) */
kRenderTransAdd, /* src*a+dest */
}
/* Fx for set_user_rendering() */
enum {
kRenderFxNone = 0,
kRenderFxPulseSlow,
kRenderFxPulseFast,
kRenderFxPulseSlowWide,
kRenderFxPulseFastWide,
kRenderFxFadeSlow,
kRenderFxFadeFast,
kRenderFxSolidSlow,
kRenderFxSolidFast,
kRenderFxStrobeSlow,
kRenderFxStrobeFast,
kRenderFxStrobeFaster,
kRenderFxFlickerSlow,
kRenderFxFlickerFast,
kRenderFxNoDissipation,
kRenderFxDistort, /* Distort/scale/translate flicker */
kRenderFxHologram, /* kRenderFxDistort + distance fade */
kRenderFxDeadPlayer, /* kRenderAmt is the player index */
kRenderFxExplode, /* Scale up really big! */
kRenderFxGlowShell, /* Glowing Shell */
kRenderFxClampMinScale, /* Keep this sprite from getting very small (SPRITES only!) */
}
enum {
force_exactfile, /* File on client must exactly match server's file */
force_model_samebounds, /* For model files only, the geometry must fit in the same bbox */
force_model_specifybounds, /* For model files only, the geometry must fit in the specified bbox */
}

104
plugins/include/amxmisc.inc Executable file
View File

@ -0,0 +1,104 @@
/* AMX Mod misc.
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _amxmisc_included
#endinput
#endif
#define _amxmisc_included
stock cmd_access(a,b,c,d){
if ( ((get_user_flags(a)&b)!=b) && (a!=(is_dedicated_server()?0:1)) ){
console_print(a,"You have no access to that command")
return 0
}
if (read_argc() < d){
new hcmd[32], hinfo[128], hflag
get_concmd(c,hcmd,31,hflag,hinfo,127,b)
console_print(a,"Usage: %s %s",hcmd,hinfo)
return 0
}
return 1
}
stock access(id,level)
return (get_user_flags(id) & level)
/* Flags:
* 1 - obey immunity
* 2 - allow yourself
* 4 - must be alive
* 8 - can't be bot
*/
stock cmd_target(id,const arg[],flags = 1) {
new player = find_player("bl",arg)
if (player){
if ( player != find_player("blj",arg) ){
console_print(id,"There are more clients matching to your argument")
return 0
}
}
else if ( ( player = find_player("c",arg) )==0 && arg[0]=='#' && arg[1] )
player = find_player("k",strtonum(arg[1]))
if (!player){
console_print(id,"Client with that name or userid not found")
return 0
}
if (flags & 1){
if ((get_user_flags(player)&ADMIN_IMMUNITY) && ((flags&2)?(id!=player):true) ){
new imname[32]
get_user_name(player,imname,31)
console_print(id,"Client ^"%s^" has immunity",imname)
return 0
}
}
if (flags & 4){
if (!is_user_alive(player)){
new imname[32]
get_user_name(player,imname,31)
console_print(id,"That action can't be performed on dead client ^"%s^"",imname)
return 0
}
}
if (flags & 8){
if (is_user_bot(player)){
new imname[32]
get_user_name(player,imname,31)
console_print(id,"That action can't be performed on bot ^"%s^"",imname)
return 0
}
}
return player
}
stock show_activity( id, const name[], {Float,_}: ... ){
new buffer[128]
format_args( buffer , 127 , 2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"%s %s: %s",
(get_user_flags(id) & ADMIN_USER) ? "PLAYER" : "ADMIN" , name , buffer )
case 1: client_print(0,print_chat,"%s: %s",
(get_user_flags(id) & ADMIN_USER) ? "PLAYER" : "ADMIN", buffer )
}
}
stock is_running(const arg[]){
new mod_name[32]
get_modname(mod_name,31)
return equal(mod_name,arg)
}
stock build_path( path[] , len , {Float,_}:... ) {
new basedir[32]
get_localinfo( "amx_basedir", basedir , 31 )
format_args( path , len , 2 )
return replace( path , len , "$basedir", basedir )
}
stock get_basedir( name[], len )
return get_localinfo( "amx_basedir", name , len )
stock get_logfile( name[], len )
return get_time("admin%m%d.log",name,len)

560
plugins/include/amxmod.inc Executable file
View File

@ -0,0 +1,560 @@
/* AMX Mod functions
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _amxmod_included
#endinput
#endif
#define _amxmod_included
#include <core>
#include <float>
#include <amxconst>
#include <string>
#include <file>
#include <fun>
#include <vault>
/* Function is called just after server activation.
* Good place for configuration loading, commands and cvars registration. */
forward plugin_init();
/* Function is called when all plugin_init from plugins
* were called, so all commmands and cvars should be already registered. */
forward plugin_cfg();
/* Function called before plugin unloading (server deactivation) */
forward plugin_end();
/* Called on log message. */
forward plugin_log();
/* Use here model_precache() and sound_precache() functions. */
forward plugin_precache();
/* Whenever player info is changed, this function is called. */
forward client_infochanged(id);
/* Called on client connection. */
forward client_connect(id);
/* Called when client gets valid STEAM id (usually
* between client_connect() and client_putinserver()). */
forward client_authorized(id);
/* Called when client is disconnecting from server. */
forward client_disconnect(id);
/* Called when client is sending command. */
forward client_command(id);
/* Called when client is entering to a game. */
forward client_putinserver(id);
/* Sets informations about plugin. */
native register_plugin(const plugin_name[],const version[],const author[]);
/* Gets info about plugin by given index.
* Function returns -1 if plugin doesn't exist with given index. */
native get_plugin(index,filename[],len1,name[],len2,version[],len3,author[],len4,status[],len5);
/* Returns number of all loaded plugins. */
native get_pluginsnum();
/* Precache model. Can be used only in plugin_precache() function.*/
native precache_model(const name[]);
/* Precache sound. Can be used only in plugin_precache() function.*/
native precache_sound(const name[]);
/* Sets info for player. */
native set_user_info(index,const info[],const value[]);
/* Gets info from player. */
native get_user_info(index,const info[],output[],len);
/* Sets info for server. */
native set_localinfo(const info[],const value[]);
/* Gets info from server. */
native get_localinfo(const info[],output[],len);
/* Shows text in MOTD window. When there is no header, the MOTD title
* will be the name of server. If message is filename, then a contents
* of this file will be displayed as MOTD. */
native show_motd(player,const message[],const header[]="");
/* Sends message to player. Set index to 0 to send text globaly. */
native client_print(index,type,const message[],{Float,_}:...);
/* Sends message to player by engine. Set index to 0 to send text globaly. */
native engclient_print(player,type,const message[],{Float,_}:...);
/* Sends message to console. */
native console_print(id,const message[],{Float,_}:...);
/* Sends command to console. */
native console_cmd(id,const cmd[],{Float,_}:...);
/* Registers event on which a given function will be called
* Flags:
* "a" - global event.
* "b" - specified.
* "c" - send only once when repeated to other players.
* "d" - call if is send to dead player.
* "e" - to alive.
* Examples for conditions:
* "2=c4" - 2nd parameter of message must be sting "c4".
* "3>10" - 3rd parameter must be greater then 10.
* "3!4" - 3rd must be different from 4.
* "2&Buy" - 2nd parameter of message must contain "Buy" substring.
* "2!Buy" - 2nd parameter of message can't contain "Buy" substring. */
native register_event(const event[],const function[],const flags[],cond[]="", ... );
/* Registers log event on which the given function will be called
* Examples for conditions:
* "0=World triggered" "1=Game_Commencing"
* "1=say"
* "3=Terrorists_Win"
* "1=entered the game"
* "0=Server cvar"
*/
native register_logevent(const function[], argsnum, ... );
/* Sets format for hudmessage. */
native set_hudmessage(red=200, green=100, blue=0, Float:x=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2,channel=4);
/* Displays HUD message to given player. */
native show_hudmessage(index,const message[],{Float,_}:...);
/* Displays menu. Keys have bit values (key 1 is (1<<0), key 5 is (1<<4) etc.). */
native show_menu(index,keys,const menu[], time = -1);
/* Gets value from client messages.
* When you are asking for string the array and length is needed (read_data(2,name,len)).
* Integer is returned by function (new me = read_data(3)).
* Float is set in second parameter (read_data(3,value)). */
native read_data(value, {Float,_}:... );
/* Returns number of values in client message. */
native read_datanum();
/* Gets log message. Can be called only in plugin_log() forward function. */
native read_logdata(output[],len);
/* Returns number of log arguments.
* Can be called only in plugin_log() forward function. */
native read_logargc();
/* Gets log argument indexed from 0.
* Can be called only in plugin_log() forward function. */
native read_logargv(id,output[],len);
/* Parse log data about user ( "Butcher<5><BOT><TERRORIST>" etc. ). */
native parse_loguser(const text[], name[], nlen, &userid = -2, authid[] = "", alen = 0, team[]="", tlen=0);
/* Prints message to server console.
* You may use text formating (f.e. server_print("%-32s %.2f!","hello",7.345)) */
native server_print(const message[], {Float,_}:...);
/* Returns 1 or 0. */
native is_map_valid(const mapname[]);
/* Returns 1 or 0. */
native is_user_bot(index);
/* Returns 1 or 0. */
native is_user_hltv(index);
/* Returns 1 or 0. */
native is_user_connected(index);
/* Returns 1 or 0. */
native is_user_connecting(index);
/* Returns 1 or 0. */
native is_user_alive(index);
/* Returns 1 or 0. */
native is_dedicated_server();
/* Returns 1 or 0. */
native is_linux_server();
/* If player is not attacked function returns 0, in other
* case returns index of attacking player. On second and third
* parameter you may get info about weapon and body hit place. */
native get_user_attacker(index,...);
/* If player doesn't hit at anything function returns 0.0,
* in other case the distance between hit point and player is returned.
* If player is aiming at another player then the id and part of body are set. */
native Float:get_user_aiming(index,&id,&body,dist=9999);
/* Returns player frags. */
native get_user_frags(index);
/* Returns player deaths. */
native get_user_deaths(index);
/* Returns player armor. */
native get_user_armor(index);
/* Returns player health. */
native get_user_health(index);
/* Returns index. */
native get_user_index(const name[]);
/* Returns ip. */
native get_user_ip(index,ip[],len, without_port = 0);
/* Returns id of currently carried weapon. Gets also
* ammount of ammo in clip and backpack. */
native get_user_weapon(index,&clip,&ammo);
/* Gets ammo and clip from current weapon. */
native get_user_ammo(index,weapon,&clip,&ammo);
/* Converts numbers from range 0 - 999 to words. */
native num_to_word(num,output[],len);
/* Returns team id. When length is greater then 0
* then a name of team is set. */
native get_user_team(index, team[]="", len = 0);
/* Returns player playing time in seconds.
* If flag is set then result is without connection time. */
native get_user_time(index, flag = 0);
/* Gets ping and loss at current time. */
native get_user_ping(index, &ping, &loss);
/* Gets origin from player.
* Modes:
* 0 - current position.
* 1 - position from eyes (weapon aiming).
* 2 - end position from player position.
* 3 - end position from eyes (hit point for weapon).
* 4 - position of last bullet hit (only CS). */
native get_user_origin(index, origin[3], mode = 0);
/* Returns all carried weapons as bit sum. Gets
* also theirs indexes. */
native get_user_weapons(index,weapons[32],&num);
/* Returns weapon name. */
native get_weaponname(id,weapon[],len);
/* Returns player name. */
native get_user_name(index,name[],len);
/* Gets player authid. */
native get_user_authid(index, authid[] ,len);
/* Returns player wonid. */
native get_user_wonid(index);
/* Returns player userid. */
native get_user_userid(index);
/* Slaps player with given power. */
native user_slap(index,power,rnddir=1);
/* Kills player. When flag is set to 1 then death won't decrase frags. */
native user_kill(index,flag=0);
/* Sends message to standard HL logs. */
native log_message(const message[],{Float,_}:...);
/* Sends log message to specified file. */
native log_to_file(const file[],const message[],{Float,_}:...);
/* Returns number of players put in server.
* If flag is set then also connecting are counted. */
native get_playersnum(flag=0);
/* Sets indexes of players.
* Flags:
* "a" - don't collect dead players.
* "b" - don't collect alive players.
* "c" - skip bots.
* "d" - skip real players.
* "e" - match with team.
* "f" - match with part of name.
* "g" - ignore case sensitivity.
* Example: Get all alive CTs: get_players(players,num,"ae","CT") */
native get_players(players[32], &num ,const flags[]="", const team[]="");
/* Gets argument from command. */
native read_argv(id,output[],len);
/* Gets line of all arguments. */
native read_args(output[],len);
/* Returns number of arguments (+ one as command). */
native read_argc();
/* Converts string to sum of bits.
* Example: "abcd" is a sum of 1, 2, 4 and 8. */
native read_flags(const flags[]);
/* Converts sum of bits to string.
* Example: 3 will return "ab". */
native get_flags(flags,output[],len);
/* Find player.
* Flags:
* "a" - with given name.
* "b" - with given part of name.
* "c" - with given authid.
* "d" - with given ip.
* "e" - with given team name.
* "f" - don't look in dead players.
* "g" - don't look in alive players.
* "h" - skip bots.
* "i" - skip real players.
* "j" - return index of last found player.
* "k" - with given userid.
* "l" - ignore case sensitivity. */
native find_player(const flags[], ... );
/* Removes quotes from sentence. */
native remove_quotes(text[]);
/* Executes command on player. */
native client_cmd(index,const command[],{Float,_}:...);
/* This is an emulation of a client command (commands aren't send to client!).
* It allows to execute some commands on players and bots.
* Function is excellent for forcing to do an action related to a game (not settings!).
* The command must stand alone but in arguments you can use spaces. */
native engclient_cmd(index,const command[],arg1[]="",arg2[]="");
/* Executes command on a server console. */
native server_cmd(const command[],{Float,_}:...);
/* Sets a cvar to given value. */
native set_cvar_string(const cvar[],const value[]);
/* If a cvar exists returns 1, in other case 0 */
native cvar_exists(const cvar[]);
/* Removes a cvar flags (not allowed for amx_version,
* fun_version and sv_cheats cvars). */
native remove_cvar_flags(const cvar[],flags = -1);
/* Sets a cvar flags (not allowed for amx_version,
* fun_version and sv_cheats cvars). */
native set_cvar_flags(const cvar[],flags);
/* Returns a cvar flags. */
native get_cvar_flags(const cvar[]);
/* Sets a cvar to given float. */
native set_cvar_float(const cvar[],Float:value);
/* Gets a cvar float. */
native Float:get_cvar_float(const cvarname[]);
/* Gets a cvar integer value. */
native get_cvar_num(const cvarname[]);
/* Sets a cvar with integer value. */
native set_cvar_num(const cvarname[],value);
/* Reads a cvar value. */
native get_cvar_string(const cvarname[],output[],iLen);
/* Returns a name of currently played map. */
native get_mapname(name[],len);
/* Returns time remaining on map in seconds. */
native get_timeleft();
/* Returns a game time. */
native Float:get_gametime();
/* Returns maxplayers setting. */
native get_maxplayers();
/* Returns a name of currently played mod. */
native get_modname(name[],len);
/* Returns time in given format. The most popular is: "%m/%d/%Y - %H:%M:%S". */
native get_time(const format[],output[],len);
/* Returns time in given format. The most popular is: "%m/%d/%Y - %H:%M:%S".
* Last parameter sets time to format. */
native format_time(output[],len, const format[],time = -1);
/* Returns system time in seconds elapsed since 00:00:00 on January 1, 1970.
* Offset is given in seconds.*/
native get_systime(offset = 0);
/* Returns time in input and additionaly fills missing information
* with current time and date. If time is different than -1 then parsed
* time is added to given time.
* Example:
* parset_time( "10:32:54 04/02/2003", "%H:%M:%S %m:%d:%Y" )
* For more information see strptime(...) function from C libraries. */
native parse_time(const input[],const format[], time = -1);
/* Calls function on specified time.
* Flags:
* "a" - repeat.
* "b" - loop task.
* "c" - do task on time after a map timeleft.
* "d" - do task on time before a map timelimit. */
native set_task(Float:time,const function[],id = 0,parameter[]="",len = 0,flags[]="", repeat = 0);
/* Removes all tasks with given id. If outside var is
* set then a task can be removed also when
* was set in another plugin. */
native remove_task(id = 0, outside = 0);
/* Returns 1 if task under given id exists. */
native task_exists(id = 0, outside = 0);
/* Sets flags for player. Set flags to -1 if you want to clear all flags.
* You can use different settings by changing the id, which is from range 0 - 31. */
native set_user_flags(index,flags=-1,id=0);
/* Gets flags from player. Set index to 0 if you want to read flags from server. */
native get_user_flags(index,id=0);
/* Removes flags for player. */
native remove_user_flags(index,flags=-1,id=0);
/* Registers function which will be called from client console. */
native register_clcmd(const client_cmd[],const function[],flags=-1, info[]="");
/* Registers function which will be called from any console. */
native register_concmd(const cmd[],const function[],flags=-1, info[]="");
/* Registers function which will be called from server console. */
native register_srvcmd(const server_cmd[],const function[],flags=-1, info[]="");
/* Gets info about client command. */
native get_clcmd(index, command[], len1, &flags, info[], len2, flag);
/* Returns number of registered client commands. */
native get_clcmdsnum(flag);
/* Gets info about server command. */
native get_srvcmd(index,server_cmd[],len1,&flags, info[],len2, flag);
/* Returns number of registered server commands. */
native get_srvcmdsnum(flag);
/* Gets info about console command. If id is set to 0,
then function returns only server cmds, if positive then
returns only client cmds. in other case returns all console commands. */
native get_concmd(index,cmd[],len1,&flags, info[],len2, flag, id = -1);
/* Returns number of registered console commands. */
native get_concmdsnum(flag,id = -1);
/* Gets unique id of menu. Outside set to 1 allows
* to catch menus outside a plugin where register_menuid is called. */
native register_menuid(const menu[], outside=0 );
/* Calls function when player uses specified menu and proper keys. */
native register_menucmd(menuid,keys, const function[] );
/* Gets what menu the player is watching and what keys for menu he have.
* When there is no menu the index is 0. If the id is negative then the menu
* is VGUI in other case the id is from register_menuid() function. */
native get_user_menu(index,&id,&keys);
/* Forces server to execute sent server command at current time.
* Very useful for map changes, setting cvars and other activities. */
native server_exec();
/* Emits sound. Sample must be precached. */
native emit_sound(index, channel, sample[], Float:vol, Float:att,flags, pitch);
/* Returns distance between two vectors. */
native get_distance(origin1[3],origin2[3]);
/* Registers new cvar for HL engine. */
native register_cvar(const name[],const string[],flags = 0,Float:fvalue = 0.0);
/* Generates random floating point number from a to b. */
native Float:random_float(Float:a,Float:b);
/* Generates random integer from a to b. */
native random_num(a,b);
/* Pauses function or plugin so it won't be executed.
* In most cases param1 is name of function and
* param2 name of plugin (all depends on flags).
* Flags:
* "a" - pause whole plugin.
* "b" - pause function.
* "c" - look outside the plugin (by given plugin name).
* "d" - set "stopped" status when pausing whole plugin.
* "e" - set "locked" status when pausing whole plugin.
* In this status plugin is unpauseable.
* Example: pause("ac","myplugin.amx")
* pause("bc","myfunc","myplugin.amx") */
native pause(flag[], const param1[]="",const param2[]="");
/* Unpauses function or plugin.
* Flags:
* "a" - unpause whole plugin.
* "b" - unpause function.
* "c" - look outside the plugin (by given plugin name). */
native unpause(flag[], const param1[]="",const param2[]="");
/* Returns id of client message.
* Example: get_user_msgid("TextMsg"). */
native get_user_msgid(const name[]);
/* These functinos are used to generate client messages.
* You may generate menu, smoke, shockwaves, thunderlights,
* intermission and many many others messages.
* See HL SDK for more examples. */
native message_begin( dest, msg_type, origin[3]={0,0,0},player=0);
native message_end();
native write_byte( x );
native write_char( x );
native write_short( x );
native write_long( x );
native write_entity( x );
native write_angle( x );
native write_coord( x );
native write_string( x[] );
/* Called on inconsistent file. You can put any text
* into reason to change an original message. */
forward inconsistent_file(id,const filename[], reason[64] );
/* Forces the client and server to be running with the same
* version of the specified file ( e.g., a player model ). */
native force_unmodified(force_type, mins[3] , maxs[3], const filename[]);
/* Checks if public variable with given name exists in loaded plugins. */
native xvar_exists( const name[] );
/* Returns an unique id for public variable specified by name. If such
* variable doesn't exist then returned value is -1. */
native get_xvar_id( const name[] );
/* Returns an integer value of a public variable. Id is a value
* returned by get_xvar_id(...) native. */
native get_xvar_num( id );
/* Returns a float value of a public variable. Id is a value
* returned by get_xvar_id(...) native. */
native Float:get_xvar_float( id );
/* Sets a value of a public variable. Id is a value
* returned by get_xvar_id(...) native. */
native set_xvar_num( id, value = 0 );
/* Sets a float value of a public variable. Id is a value
* returned by get_xvar_id(...) native. */
native set_xvar_float( id, Float:value = 0.0 );

39
plugins/include/core.inc Executable file
View File

@ -0,0 +1,39 @@
/* Core functions
*
* (c) Copyright 1998-2002, ITB CompuPhase
* This file is provided as is (no warranties).
*/
#if defined _core_included
#endinput
#endif
#define _core_included
native heapspace();
native funcidx(const name[]);
native numargs();
native getarg(arg, index=0);
native setarg(arg, index=0, value);
native strlen(const string[]);
native strpack(dest[], const source[]);
native strunpack(dest[], const source[]);
native tolower(c);
native toupper(c);
native swapchars(c);
native random(max);
native min(value1, value2);
native max(value1, value2);
native clamp(value, min=cellmin, max=cellmax);
native power(value, exponent);
native sqroot(value);
native time(&hour=0,&minute=0,&second=0);
native date(&year=0,&month=0,&day=0);
native tickcount(&granularity=0);

55
plugins/include/csstats.inc Executable file
View File

@ -0,0 +1,55 @@
/* CS Stats functions
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _csstats_included
#endinput
#endif
#define _csstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[8],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[8],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[8],bodyhits[8],name[],len);
/* Returns number of all entries in stats. */
native get_statsnum();

34
plugins/include/file.inc Executable file
View File

@ -0,0 +1,34 @@
/* Files functions
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _file_included
#endinput
#endif
#define _file_included
/* Reads content from directory.
* Returns index of next element or 0 when end of dir. is reached. */
native read_dir(const dirname[],pos,output[],len,&outlen);
/* Reads line from file. Returns index of next line or 0 when end of file is reached. */
native read_file(const file[],line,text[],len,&txtlen);
/* Writes text to file. Function returns 0 on failure.
* When line is set to -1, the text is added at the end of file. */
native write_file(const file[],const text[],line = -1);
/* Deletes file. Function returns 1 on success, 0 on failure. */
native delete_file(const file[]);
/* Checks for file. If file exists function returns 1, in other case 0. */
native file_exists(const file[]);
/* Returns a file size in bytes if flag is set to 0.
When flag is set to 1 returns number of lines in the file,
and when flags is 2, function returns 1 if the file ends
with line feed. If file doesn't exist returns -1.*/
native file_size(const file[], flag=0);

122
plugins/include/float.inc Executable file
View File

@ -0,0 +1,122 @@
/* Float arithmetic
*
* (c) Copyright 1999, Artran, Inc.
* Written by Greg Garner (gmg@artran.com)
* Modified in March 2001 to include user defined
* operators for the floating point functions.
*
* This file is provided as is (no warranties).
*/
#if defined _float_included
#endinput
#endif
#define _float_included
native Float:float(value);
native Float:floatstr(const string[]);
native Float:floatmul(Float:oper1, Float:oper2);
native Float:floatdiv(Float:dividend, Float:divisor);
native Float:floatadd(Float:dividend, Float:divisor);
native Float:floatsub(Float:oper1, Float:oper2);
native Float:floatfract(Float:value);
enum floatround_method {
floatround_round,
floatround_floor,
floatround_ceil
}
native floatround(Float:value, floatround_method:method=floatround_round);
native floatcmp(Float:fOne, Float:fTwo);
#pragma rational Float
/* user defined operators */
native Float:operator*(Float:oper1, Float:oper2) = floatmul;
native Float:operator/(Float:oper1, Float:oper2) = floatdiv;
native Float:operator+(Float:oper1, Float:oper2) = floatadd;
native Float:operator-(Float:oper1, Float:oper2) = floatsub;
stock Float:operator++(Float:oper)
return oper+1.0;
stock Float:operator--(Float:oper)
return oper-1.0;
stock Float:operator-(Float:oper)
return oper^Float:0x80000000; /* IEEE values are sign/magnitude */
stock Float:operator*(Float:oper1, oper2)
return floatmul(oper1, float(oper2)); /* "*" is commutative */
stock Float:operator/(Float:oper1, oper2)
return floatdiv(oper1, float(oper2));
stock Float:operator/(oper1, Float:oper2)
return floatdiv(float(oper1), oper2);
stock Float:operator+(Float:oper1, oper2)
return floatadd(oper1, float(oper2)); /* "+" is commutative */
stock Float:operator-(Float:oper1, oper2)
return floatsub(oper1, float(oper2));
stock Float:operator-(oper1, Float:oper2)
return floatsub(float(oper1), oper2);
stock bool:operator==(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) == 0;
stock bool:operator==(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) == 0; /* "==" is commutative */
stock bool:operator!=(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) != 0;
stock bool:operator!=(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) != 0; /* "==" is commutative */
stock bool:operator>(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) > 0;
stock bool:operator>(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) > 0;
stock bool:operator>(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) > 0;
stock bool:operator>=(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) >= 0;
stock bool:operator>=(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) >= 0;
stock bool:operator>=(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) >= 0;
stock bool:operator<(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) < 0;
stock bool:operator<(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) < 0;
stock bool:operator<(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) < 0;
stock bool:operator<=(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) <= 0;
stock bool:operator<=(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) <= 0;
stock bool:operator<=(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) <= 0;
stock bool:operator!(Float:oper)
return floatcmp(oper, 0.0) == 0;
/* forbidden operations */
forward operator%(Float:oper1, Float:oper2);
forward operator%(Float:oper1, oper2);
forward operator%(oper1, Float:oper2);

86
plugins/include/fun.inc Executable file
View File

@ -0,0 +1,86 @@
/* Fun functions
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _fun_included
#endinput
#endif
#define _fun_included
/* Sets who can listen who. Function returns 0
* if for some reasons this setting can't be done. */
native set_user_listening(receiver,sender,listen);
/* Returns 1 if receiver hears sender via voice communication. */
native get_user_listening(receiver,sender);
/* Sets player godmode. If you want to disable godmode set only first parameter. */
native set_user_godmode(index,godmode = 0);
/* Returns 1 if godmode is set. */
native get_user_godmode(index);
/* Sets player noclip. If you want to disable noclip set only first parameter. */
native set_user_noclip(index,noclip = 0);
/* Returns 1 if noclip is set. */
native get_user_noclip(index);
/* Sets player frags. */
native set_user_frags(index,frags);
/* Sets player armor. */
native set_user_armor(index,armor);
/* Sets player health. */
native set_user_health(index, health);
/* Move player to origin. */
native set_user_origin(index, origin[3]);
/* Sets player rendering mode. */
native set_user_rendering(index,fx = kRenderFxNone, r=255,g=255,b=255, render = kRenderNormal,amount=16);
/* Gives item to player, name of item can start
* with weapon_, ammo_ and item_. This event
* is announced with proper message to all players. */
native give_item(index,const item[]);
/* Sets hit zones for player. This event is announced
* with proper message to all players.
* Parts of body are as bits:
* 2 - head
* 4 - chest
* 8 - stomach
* 16 - left arm
* 32 - right arm
* 64 - left leg
* 128 - right leg*/
native set_user_hitzones(index=0,target=0,body=255);
/* Returns hit zones for player. */
native get_user_hitzones(index,target);
/* Makes that player spawns. This event is announced
* with proper message to all players. */
native user_spawn(index);
/* Sets users max. speed. */
native set_user_maxspeed(index,Float:speed=-1.0);
/* Returns users max. speed. */
native Float:get_user_maxspeed(index);
/* Sets users gravity. */
native set_user_gravity(index,Float:gravity=1.0);
/* Returns users gravity. */
native Float:get_user_gravity(index);
/* Gives money to user. */
native set_user_money(index,money,flash=1);
/* Returns users money. */
native get_user_money(index);

30
plugins/include/mysql.inc Executable file
View File

@ -0,0 +1,30 @@
/* MySQL functions
*
* (c) Copyright 2002, dJeyL
* This file is provided as is (no warranties).
*/
#if defined _mysql_included
#endinput
#endif
#define _mysql_included
/* Opens connection. If already such exists then that will be used.
* Function returns sql id to use with other sql natives.
* Host can be plain ip or with port seperated with ':' char. */
native mysql_connect(host[],user[],pass[],dbname[],error[],maxlength);
/* Uses an existing connection (sql) to perform a new query (query) (might close previous query if any). */
native mysql_query(sql,query[]);
/* Prepares next row of current query (sql) for read access ; returns the number of the row, 0 at end. */
native mysql_nextrow(sql);
/* Stores specified column (fieldnum) of current query (sql) in (dest) with (maxlength) characters maximum. */
native mysql_getfield(sql,fieldnum,dest[],maxlength);
/* Clears query (sql) and closes connection (if any other plugin doesn't use it). */
native mysql_close(sql);
/* Stores last error of current query/connection (sql) in (dest) with (maxlength) characters maximum. */
native mysql_error(sql,dest[],maxlength);

85
plugins/include/string.inc Executable file
View File

@ -0,0 +1,85 @@
/* Strings manipulation
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _string_included
#endinput
#endif
#define _string_included
/* Checks if source contains string. On success function
* returns position in source, on failure returns -1. */
native contain(const source[],const string[]);
/* Checks if source contains string with case ignoring. On success function
* returns position in source, on failure returns -1. */
native containi(const source[],const string[]);
/* Replaces given string to another in given text. */
native replace(text[],len,const what[],const with[]);
/* Adds one string to another. Last parameter different from 0, specifies
* how many chars we want to add. Function returns number of all merged chars. */
native add(dest[],len,const src[],max=0);
/* Fills string with given format and parameters.
* Function returns number of copied chars.
* Example: format(dest,"Hello %s. You are %d years old","Tom",17). */
native format(output[] ,len ,const format[] , {Float,_}:...);
/* Gets parameters from function as formated string. */
native format_args(output[] ,len ,pos = 0);
/* Converts number to string. */
native num_to_str(num,string[],len);
native numtostr(num,string[],len);
/* Returns converted string to number. */
native str_to_num(const string[]);
native strtonum(const string[]);
/* Checks if two strings equal. If len var is set
* then there are only c chars comapred. */
native equal(const a[],const b[],c=0);
/* Checks if two strings equal with case ignoring.
* If len var is set then there are only c chars comapred. */
native equali(const a[],const b[],c=0);
/* Copies one string to another. By len var
* you may specify max. number of chars to copy. */
native copy(dest[],len,const src[]);
/* Copies one string to another until char ch is found.
* By len var you may specify max. number of chars to copy. */
native copyc(dest[],len,const src[],ch);
/* Sets string with given character. */
native setc(src[],len,ch);
/* Gets parameters from text.
* Example: to split text: "^"This is^" the best year",
* call function like this: parse(text,arg1,len1,arg2,len2,arg3,len3,arg4,len4)
* and you will get: "This is", "the", "best", "year"
* Function returns number of parsed parameters. */
native parse(const text[], ... );
/* Converts all chars in string to lower case. */
native strtolower(string[]);
/* Converts all chars in string to upper case. */
native strtoupper(string[]);
/* Returns true when value is digit. */
native isdigit(ch);
/* Returns true when value is letter. */
native isalpha(ch);
/* Returns true when value is space. */
native isspace(ch);
/* Returns true when value is letter or digit. */
native isalnum(ch);

24
plugins/include/vault.inc Executable file
View File

@ -0,0 +1,24 @@
/* Vault
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*/
#if defined _vault_included
#endinput
#endif
#define _vault_included
/* Reads a data from given key.
* If len is set to zero then get_vaultdata
* returns value as an number. */
native get_vaultdata(const key[], data[] = "", len = 0);
/* Sets a data under given key. */
native set_vaultdata(const key[], const data[] = "" );
/* Removes a key from vault.*/
native remove_vaultdata(const key[]);
/* Checks if a key exists in the vault.*/
native vaultdata_exists(const key[]);

191
plugins/mapchooser.sma Executable file
View File

@ -0,0 +1,191 @@
/* AMX Mod script.
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*
* On two minutes before the timelimit plugin
* displays menu with 5 random maps to select.
* One of the options is also map extending.
* Map with most votes becomes the nextmap.
*
* Maps to selected are in maps.ini file.
*
* Cvars:
* amx_extendmap_max <time in mins.> - max. time for overall extending
* amx_extendmap_step <time in mins.> - with what time the map will be extended
*
* NOTE: Nextmap plugin is required for proper working of this plugin.
*/
#include <amxmod>
#include <amxmisc>
#define MAX_MAPS 128
#define SELECTMAPS 5
new g_mapName[MAX_MAPS][32]
new g_mapNums
new g_nextName[SELECTMAPS]
new g_voteCount[SELECTMAPS+2]
new g_mapVoteNum
new g_teamScore[2]
new g_lastMap[32]
new g_cstrikeRunning
new bool:g_selected = false
new g_logFile[16]
public plugin_init()
{
register_plugin("Nextmap chooser","0.9","default")
register_menucmd(register_menuid("AMX Choose nextmap:"),(-1^(-1<<(SELECTMAPS+2))),"countVote")
register_cvar("amx_extendmap_max","90")
register_cvar("amx_extendmap_step","15")
if ( ( g_cstrikeRunning = is_running("cstrike") ) != 0 )
register_event("TeamScore", "team_score", "a")
get_localinfo("lastMap",g_lastMap,31)
set_localinfo("lastMap","")
get_logfile(g_logFile,15)
new filename[64]
build_path( filename , 63 , "$basedir/maps.ini" )
if ( loadSettings( filename ) )
set_task(15.0,"voteNextmap",987456,"",0,"b")
}
public checkVotes(){
new b = 0
for(new a = 0; a < g_mapVoteNum; ++a)
if (g_voteCount[b] < g_voteCount[a])
b = a
if ( g_voteCount[SELECTMAPS] > g_voteCount[b] ) {
new mapname[32]
get_mapname(mapname,31)
new Float:steptime = get_cvar_float("amx_extendmap_step")
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime )
client_print(0,print_chat,"Choosing finished. Current map will be extended to next %.0f minutes", steptime )
log_to_file(g_logFile,"Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes",
mapname , steptime )
return
}
if ( g_voteCount[b] && g_voteCount[SELECTMAPS+1] <= g_voteCount[b] )
set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]] )
new smap[32]
get_cvar_string("amx_nextmap",smap,31)
client_print(0,print_chat,"Choosing finished. The nextmap will be %s", smap )
log_to_file(g_logFile,"Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
}
public countVote(id,key){
if ( get_cvar_float("amx_vote_answers") ) {
new name[32]
get_user_name(id,name,31)
if ( key == SELECTMAPS )
client_print(0,print_chat,"%s chose map extending", name )
else if ( key < SELECTMAPS )
client_print(0,print_chat,"%s chose %s", name, g_mapName[g_nextName[key]] )
}
++g_voteCount[key]
return PLUGIN_HANDLED
}
bool:isInMenu(id){
for(new a=0; a<g_mapVoteNum; ++a)
if (id==g_nextName[a])
return true
return false
}
public voteNextmap(){
new winlimit = get_cvar_num("mp_winlimit")
new maxrounds = get_cvar_num("mp_maxrounds")
if ( winlimit ) {
new c = winlimit - 2
if ( (c > g_teamScore[0]) && (c > g_teamScore[1]) ) {
g_selected = false
return
}
}
else if ( maxrounds ) {
if ( (maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]) ){
g_selected = false
return
}
}
else {
new timeleft = get_timeleft()
if (timeleft<1||timeleft>129){
g_selected = false
return
}
}
if (g_selected)
return
g_selected = true
new menu[512], a, mkeys = (1<<SELECTMAPS+1)
new pos = copy(menu,511,g_cstrikeRunning ? "\yAMX Choose nextmap:\w^n^n" : "AMX Choose nextmap:^n^n")
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
for(g_mapVoteNum = 0;g_mapVoteNum<dmax;++g_mapVoteNum){
a=random_num(0,g_mapNums-1)
while( isInMenu(a) )
if (++a >= g_mapNums) a = 0
g_nextName[g_mapVoteNum] = a
pos += format(menu[pos],511,"%d. %s^n",g_mapVoteNum+1,g_mapName[a])
mkeys |= (1<<g_mapVoteNum)
g_voteCount[g_mapVoteNum] = 0
}
menu[pos++]='^n'
g_voteCount[SELECTMAPS] = 0
g_voteCount[SELECTMAPS+1] = 0
new mapname[32]
get_mapname(mapname,31)
if ( (winlimit + maxrounds)==0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max"))){
pos += format(menu[pos],511,"%d. Extend map %s^n",SELECTMAPS+1,mapname)
mkeys |= (1<<SELECTMAPS)
}
format(menu[pos],511,"%d. None",SELECTMAPS+2)
show_menu(0,mkeys,menu,15)
set_task(15.0,"checkVotes")
client_print(0,print_chat,"It's time to choose the nextmap...")
client_cmd(0,"spk Gman/Gman_Choose2")
log_to_file(g_logFile,"Vote: Voting for the nextmap started")
}
loadSettings(filename[])
{
if (!file_exists(filename)) return 0
new szText[32]
new a, pos = 0
new currentMap[32]
get_mapname(currentMap,31)
while ( (g_mapNums < MAX_MAPS) && read_file(filename,pos++,szText,31,a) )
{
if ( szText[0] != ';'
&& parse(szText, g_mapName[g_mapNums] ,31 )
&& is_map_valid( g_mapName[g_mapNums] )
&& !equali( g_mapName[g_mapNums] ,g_lastMap)
&& !equali( g_mapName[g_mapNums] ,currentMap) )
++g_mapNums
}
return g_mapNums
}
public team_score(){
new team[2]
read_data(1,team,1)
g_teamScore[ (team[0]=='C') ? 0 : 1 ] = read_data(2)
}
public plugin_end(){
new current_map[32]
get_mapname(current_map,31 )
set_localinfo("lastMap",current_map)
}

473
plugins/mapsmenu.sma Executable file
View File

@ -0,0 +1,473 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Content for configuation copied from ClanMod cfg. file.
*
* Admin command:
* amx_mapmenu - displays maps menu
*
* Example configuration in addons/amx/maps.ini
as_oilrig "OilRig - Assassination"
as_tundra "Tundra - Assassination"
de_aztec "Aztec - Bomb/Defuse"
de_cbble "Cobble - Bomb/Defuse"
de_chateau "Chateau - Bomb/Defuse"
de_dust "Dust - Bomb/Defuse"
de_dust2 "Dust II - Bomb/Defuse"
de_inferno "Inferno - Bomb/Defuse"
de_nuke "Nuke - Bomb/Defuse"
de_prodigy "Prodigy - Bomb/Defuse"
de_storm "Storm - Bomb/Defuse"
de_survivor "Survivor - Bomb/Defuse"
de_train "Trainyard - Bomb/Defuse"
de_torn "Torn - Bomb/Defuse"
de_vegas "Vegas - Bomb/Defuse"
de_vertigo "Vertigo - Bomb/Defuse"
cs_747 "747 Hijack - Hostage Rescue"
cs_assault "Assault - Hostage Rescue"
cs_backalley "Alleyway - Hostage Rescue"
cs_estate "Zaphod's Estate - Hostage Rescue"
cs_havana "Havana - Hostage Rescue"
cs_italy "Italy - Hostage Rescue"
cs_militia "Militia - Hostage Rescue"
cs_office "The Office Complex - Hostage Rescue"
cs_siege "Canyon Siege - Hostage Rescue"
*/
#include <amxmod>
#include <amxmisc>
#define MAX_MAPS 64
new g_mapName[MAX_MAPS][32]
new g_mapDesc[MAX_MAPS][32]
new g_mapNums
new g_menuPosition[33]
new g_logFile[16]
new g_voteCount[5]
new g_voteSelected[33][4]
new g_voteSelectedNum[33]
new g_cstrikeRunning
new g_choosed
public plugin_init()
{
register_plugin("Maps Menu","0.9","default")
register_clcmd("amx_mapmenu","cmdMapsMenu",ADMIN_MAP,"- displays changelevel menu")
register_clcmd("amx_votemapmenu","cmdVoteMapMenu",ADMIN_MAP,"- displays votemap menu")
register_menucmd(register_menuid("Changelevel Menu"),1023,"actionMapsMenu")
register_menucmd(register_menuid("Which map do you want?"),527,"voteCount")
register_menucmd(register_menuid("Change map to"),527,"voteCount")
register_menucmd(register_menuid("Votemap Menu"),1023,"actionVoteMapMenu")
register_menucmd(register_menuid("The winner: ") ,3,"actionResult")
new filename[64]
build_path( filename , 63 , "$basedir/maps.ini" )
load_settings( filename )
get_logfile(g_logFile,15)
g_cstrikeRunning = is_running("cstrike")
}
new g_resultAck[] = "Result accepted"
new g_resultRef[] = "Result refused"
public autoRefuse(){
log_to_file(g_logFile,"Vote: %s" , g_resultRef)
client_print(0,print_chat, g_resultRef )
}
public actionResult(id,key) {
remove_task( 4545454 )
switch(key){
case 0: {
message_begin(MSG_ALL, SVC_INTERMISSION)
message_end()
set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 )
log_to_file(g_logFile,"Vote: %s" , g_resultAck )
client_print(0,print_chat, g_resultAck)
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
}
new g_voteSuccess[] = "Voting successful. Map will be changed to"
new g_VoteFailed[] = "Voting failed"
public checkVotes( id )
{
id -= 34567
new num, ppl[32],a = 0
get_players(ppl,num,"c")
if (num == 0) num = 1
g_choosed = -1
for(new i = 0; i < g_voteSelectedNum[id] ; ++i)
if ( g_voteCount[a] < g_voteCount[i] )
a = i
if ( 100 * g_voteCount[a] / num > 50 ) {
g_choosed = g_voteSelected[id][a]
client_print(0,print_chat, "%s %s" , g_voteSuccess , g_mapName[ g_choosed ] )
log_to_file(g_logFile,"Vote: %s %s" , g_voteSuccess , g_mapName[ g_choosed ] )
}
if ( g_choosed != -1 ) {
if ( is_user_connected( id ) ) {
new menuBody[512]
new len = format(menuBody,511,g_cstrikeRunning ? "\yThe winner: \w%s^n^n" : "The winner: %s^n^n", g_mapName[ g_choosed ] )
len += copy( menuBody[len] ,511 - len, g_cstrikeRunning ? "\yDo you want to continue?^n\w" : "Do you want to continue?^n" )
copy( menuBody[len] ,511 - len, "^n1. Yes^n2. No")
show_menu( id ,0x03 ,menuBody, 10 )
set_task(10.0,"autoRefuse",4545454)
}
else {
message_begin(MSG_ALL, SVC_INTERMISSION)
message_end()
set_task(2.0,"delayedChange",0, g_mapName[ g_choosed ] , strlen(g_mapName[ g_choosed ]) + 1 )
}
}
else {
client_print(0,print_chat, g_VoteFailed )
log_to_file(g_logFile,"Vote: %s" , g_VoteFailed)
}
remove_task(34567 + id)
}
public voteCount(id,key)
{
if (key > 3) {
client_print(0,print_chat,"Voting has been canceled")
remove_task(34567 + id)
set_cvar_float( "amx_last_voting" , get_gametime() )
log_to_file(g_logFile,"Vote: Cancel vote session")
return PLUGIN_HANDLED
}
if (get_cvar_float("amx_vote_answers")) {
new name[32]
get_user_name(id,name,31)
client_print(0,print_chat,"%s voted for option #%d", name , key + 1 )
}
++g_voteCount[key]
return PLUGIN_HANDLED
}
isMapSelected( id , pos )
{
for( new a = 0 ; a < g_voteSelectedNum[ id ]; ++a )
if ( g_voteSelected[ id ][ a ] == pos )
return 1
return 0
}
displayVoteMapsMenu(id,pos)
{
if (pos < 0)
return
new menuBody[512], b = 0 , start = pos * 7
if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\yVotemap Menu\R%d/%d^n\w^n" : "Votemap Menu %d/%d^n^n",
pos+1,( g_mapNums / 7 + (( g_mapNums % 7) ? 1 : 0 )) )
new end = start + 7, keys = (1<<9)
if (end > g_mapNums)
end = g_mapNums
for(new a = start; a < end; ++a)
{
if ( g_voteSelectedNum[id]==4 || isMapSelected( id , pos * 7 + b ) )
{
++b
if ( g_cstrikeRunning)
len += format(menuBody[len],511-len,"\d%d. %s^n\w", b ,g_mapDesc[ a ])
else
len += format(menuBody[len],511-len,"#. %s^n", g_mapDesc[ a ])
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n", ++b ,g_mapDesc[ a ])
}
}
if ( g_voteSelectedNum[id] )
{
keys |= (1<<7)
len += format(menuBody[len],511-len,"^n8. Start Voting^n")
}
else
len += format(menuBody[len],511-len, g_cstrikeRunning ?
"^n\d8. Start Voting^n\w" : "^n#. Start Voting^n")
if (end != g_mapNums)
{
len += format(menuBody[len],511-len,"^n9. More...^n0. %s^n", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else
len += format(menuBody[len],511-len,"^n0. %s^n", pos ? "Back" : "Exit")
len += format(menuBody[len],511-len, g_voteSelectedNum[id] ?
( g_cstrikeRunning ? "^n\ySelected Maps:^n\w" : "^nSelected Maps:^n") : "^n^n")
for(new c = 0; c < 4; c++)
{
if ( c < g_voteSelectedNum[id] )
len += format(menuBody[len],511-len,"%s^n", g_mapDesc[ g_voteSelected[id][ c ] ] )
else
len += format(menuBody[len],511-len,"^n" )
}
show_menu(id,keys,menuBody)
}
public cmdVoteMapMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
if ( get_cvar_float("amx_last_voting") > get_gametime() )
{
client_print(id,print_chat,"There is already one voting...")
return PLUGIN_HANDLED
}
g_voteSelectedNum[id] = 0
if ( g_mapNums )
{
displayVoteMapsMenu(id,g_menuPosition[id] = 0)
}
else
{
console_print(id,"There are no maps in menu")
client_print(id,print_chat,"There are no maps in menu")
}
return PLUGIN_HANDLED
}
public cmdMapsMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
if ( g_mapNums )
{
displayMapsMenu(id,g_menuPosition[id] = 0)
}
else
{
console_print(id,"There are no maps in menu")
client_print(id,print_chat,"There are no maps in menu")
}
return PLUGIN_HANDLED
}
public delayedChange(mapname[])
server_cmd("changelevel %s",mapname)
public actionVoteMapMenu(id,key)
{
switch(key){
case 7:{
new Float:voting = get_cvar_float("amx_last_voting")
if ( voting > get_gametime() ){
client_print(id,print_chat,"There is already one voting...")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
client_print(id,print_chat,"Voting not allowed at this time")
return PLUGIN_HANDLED
}
g_voteCount = { 0 , 0 , 0 , 0 , 0 }
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time )
new iVoteTime = floatround( vote_time )
set_task( vote_time , "checkVotes",34567 + id)
new menuBody[512]
new players[32]
new pnum, keys, len
get_players(players,pnum)
if ( g_voteSelectedNum[id] > 1 )
{
len = format(menuBody,511,g_cstrikeRunning ?
"\yWhich map do you want?^n\w^n" : "Which map do you want?^n^n")
for(new c = 0; c < g_voteSelectedNum[id] ; ++c)
{
len += format(menuBody[len],511,"%d. %s^n", c + 1 , g_mapDesc[ g_voteSelected[id][ c ] ] )
keys |= (1<<c)
}
keys |= (1<<8)
len += format(menuBody[len],511,"^n9. None^n")
}
else
{
len = format(menuBody,511, g_cstrikeRunning ? "\yChange map to^n%s?^n\w^n1. Yes^n2. No^n"
: "Change map to^n%s?^n^n1. Yes^n2. No^n" , g_mapDesc[ g_voteSelected[id][ 0 ] ] )
keys = (1<<0) | (1<<1)
}
for(new b = 0; b < pnum; ++b)
if ( players[b] != id )
show_menu(players[b],keys,menuBody, iVoteTime)
format(menuBody[len],511,"^n0. Cancel Vote")
keys |= (1<<9)
show_menu(id,keys,menuBody, iVoteTime)
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: vote map(s)",name)
case 1: client_print(0,print_chat,"ADMIN: vote map(s)")
}
log_to_file(g_logFile,"Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
name,get_user_userid(id),authid,
g_voteSelectedNum[id] > 0 ? g_mapName[ g_voteSelected[id][ 0 ] ] : "" ,
g_voteSelectedNum[id] > 1 ? g_mapName[ g_voteSelected[id][ 1 ] ] : "" ,
g_voteSelectedNum[id] > 2 ? g_mapName[ g_voteSelected[id][ 2 ] ] : "",
g_voteSelectedNum[id] > 3 ? g_mapName[ g_voteSelected[id][ 3 ] ] : "")
}
case 8: displayVoteMapsMenu(id,++g_menuPosition[id])
case 9: displayVoteMapsMenu(id,--g_menuPosition[id])
default:
{
g_voteSelected[id][ g_voteSelectedNum[id]++ ] = g_menuPosition[id] * 7 + key
displayVoteMapsMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
public actionMapsMenu(id,key)
{
switch(key){
case 8: displayMapsMenu(id,++g_menuPosition[id])
case 9: displayMapsMenu(id,--g_menuPosition[id])
default:
{
new a = g_menuPosition[id] * 8 + key
message_begin(MSG_ALL, SVC_INTERMISSION)
message_end()
new authid[32],name[32]
get_user_authid(id,authid,31)
get_user_name(id,name,31)
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: changelevel %s",name,g_mapName[ a ])
case 1: client_print(0,print_chat,"ADMIN: changelevel %s",g_mapName[ a ])
}
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"",
name,get_user_userid(id),authid, g_mapName[ a ] )
set_task(2.0,"delayedChange",0, g_mapName[ a ] , strlen(g_mapName[ a ]) + 1 )
/* displayMapsMenu(id,g_menuPosition[id]) */
}
}
return PLUGIN_HANDLED
}
displayMapsMenu(id,pos)
{
if (pos < 0)
return
new menuBody[512]
new start = pos * 8
new b = 0
if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\yChangelevel Menu\R%d/%d^n\w^n" : "Changelevel Menu %d/%d^n^n",
pos+1,( g_mapNums / 8 + (( g_mapNums % 8) ? 1 : 0 )) )
new end = start + 8
new keys = (1<<9)
if (end > g_mapNums)
end = g_mapNums
for(new a = start; a < end; ++a)
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,g_mapDesc[ a ])
}
if (end != g_mapNums)
{
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
load_settings(filename[])
{
if (!file_exists(filename))
return 0
new text[256], szDesc[48]
new a , pos = 0
while ( g_mapNums < MAX_MAPS && read_file(filename,pos++,text,255,a) )
{
if ( text[0] == ';' ) continue
if ( parse(text, g_mapName[g_mapNums] ,31, szDesc ,47) < 2 ) continue
if ( !is_map_valid( g_mapName[g_mapNums] ) ) continue
if ( strlen( szDesc ) > 31 )
{
copy(g_mapDesc[g_mapNums],28, szDesc )
g_mapDesc[g_mapNums][28] = g_mapDesc[g_mapNums][29] = g_mapDesc[g_mapNums][30] = '.'
g_mapDesc[g_mapNums][31] = 0
}
else copy(g_mapDesc[g_mapNums],31, szDesc )
g_mapNums++
}
return 1
}

175
plugins/menufront.sma Executable file
View File

@ -0,0 +1,175 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
#include <amxmisc>
new g_menuPosition[33]
#define MENUS_NUMBER 15
new g_menuBody[MENUS_NUMBER][] = {
"Kick Player",
"Ban Player",
"Slap/Slay Player",
"Team Player^n",
"Changelevel",
"Vote for maps^n",
"Speech Stuff",
"Client Commands",
// Next Page
"Server Commands",
"Cvars Settings",
"Configuration",
"Stats Settings^n",
"Pause Plugins",
"Restrict Weapons",
"Teleport Player" /* Last is Teleport menu - if you want to move
it change also code in displayMenu (look for fun module check) */
}
new g_menuCmd[MENUS_NUMBER][] = {
"amx_kickmenu",
"amx_banmenu",
"amx_slapmenu",
"amx_teammenu",
"amx_mapmenu",
"amx_votemapmenu",
"amx_speechmenu",
"amx_clcmdmenu",
// Next Page
"amx_cmdmenu",
"amx_cvarmenu",
"amx_cfgmenu",
"amx_statscfgmenu",
"amx_pausecfgmenu",
"amx_restmenu",
"amx_teleportmenu"
}
// Second value sets if menu is only for CS...
new g_menuAccess[MENUS_NUMBER][2] = {
{ADMIN_KICK,0},
{ADMIN_BAN,0},
{ADMIN_SLAY,0},
{ADMIN_LEVEL_A,1},
{ADMIN_MAP,0},
{ADMIN_MAP,0},
{ADMIN_MENU,0},
{ADMIN_LEVEL_A,0},
// Next Page
{ADMIN_MENU,0},
{ADMIN_CVAR,0},
{ADMIN_MENU,0},
{ADMIN_CFG,1},
{ADMIN_CFG,0},
{ADMIN_CFG,1},
{ADMIN_LEVEL_A,0}
}
new g_cstrikeRunning
new g_funModule
public plugin_init()
{
register_plugin("Menus Front-End","0.9","default")
register_menucmd(register_menuid("AMX Mod Menu"),1023,"actionMenu")
register_clcmd("amxmodmenu","cmdMenu",ADMIN_MENU,"- displays menus")
g_cstrikeRunning = is_running("cstrike")
g_funModule = cvar_exists( "fun_version" )
}
public actionMenu(id,key)
{
switch(key){
case 8: displayMenu(id,++g_menuPosition[id])
case 9: displayMenu(id,--g_menuPosition[id])
default: client_cmd(id, g_menuCmd[ g_menuPosition[id] * 8 + key ] )
}
return PLUGIN_HANDLED
}
displayMenu(id,pos){
if (pos < 0) return
new menuBody[512]
new b = 0
new start = pos * 8
if ( start >= MENUS_NUMBER )
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511,
g_cstrikeRunning ? "\yAMX Mod Menu\R%d/%d^n\w^n" : "AMX Mod Menu %d/%d^n^n" , pos+1, 2 )
new end = start + 8
new keys = (1<<9)
if (end > MENUS_NUMBER )
end = MENUS_NUMBER
new flags = get_user_flags(id)
for(new a = start; a < end; ++a)
{
if ( a == MENUS_NUMBER - 1 && !g_funModule )
continue // checks if there is fun module for teleport menu
if ( (flags & g_menuAccess[a][0]) && ( g_menuAccess[a][1] ? g_cstrikeRunning : 1 ) )
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_menuBody[ a ] )
}
else
{
++b
if ( g_cstrikeRunning )
len += format(menuBody[len],511-len, "\d%d. %s^n\w",b, g_menuBody[ a ] )
else
len += format(menuBody[len],511-len, "#. %s^n",g_menuBody[ a ] )
}
}
if (end != MENUS_NUMBER )
{
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
public cmdMenu(id,level,cid)
{
if (cmd_access(id,level,cid,1))
displayMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}

514
plugins/miscstats.sma Executable file
View File

@ -0,0 +1,514 @@
/* AMX Mod script.
*
* This file is provided as is (no warranties).
*
* This plugin contains:
* o multikill announcement
* o bomb events
* o killing streak
* o enemy remaining
* o round counter
* o italy bonus kill
* o knife kill
* o headshot kill
* o greanade kill
* o last man
* o double kill
* o player name
* o first blood sound
*
* To use with AMX 0.9.6 (and higher) and Counter-Strike.
* Stats can be enabled with amx_statscfg and amx_statscfgmenu commands.
* NOTE: For pernament disable, comment file from plugins.ini
* or use amx_pausecfg and amx_pausecfgmenu commands.
* Rest of stats can be found in csstats plugin.
*/
#include <amxmod>
public MultiKill
public MultiKillSound
public BombPlanting
public BombDefusing
public BombPlanted
public BombDefused
public BombFailed
public BombPickUp
public BombDrop
public BombCountVoice
public BombCountDef
public BombReached
public ItalyBonusKill
public EnemyRemaining
public LastMan
public KnifeKill
public KnifeKillSound
public GrenadeKill
public GrenadeSuicide
public HeadShotKill
public HeadShotKillSound
public RoundCounterSound
public RoundCounter
public KillingStreak
public KillingStreakSound
public DoubleKill
public DoubleKillSound
public PlayerName
public FirstBloodSound
new g_streakKills[33][2]
new g_multiKills[33][2]
new g_Planter
new g_Defuser
new g_C4Timer
new g_Defusing
new Float:g_LastOmg
new Float:g_LastPlan
new g_LastAnnounce
new g_roundCount
new Float:g_doubleKill
new g_doubleKillId
new g_friend[33]
new g_firstBlood
new g_MultiKillMsg[7][] = {
"Multi-Kill! %s^nwith %d kills (%d hs)",
"Ultra-Kill!!! %s^nwith %d kills (%d hs)",
"%s IS ON A KILLING SPREE!!!^nwith %d kills (%d hs)",
"RAMPAGE!!! %s^nwith %d kills (%d hs)" ,
"%s IS UNSTOPPABLE!!!^nwith %d kills (%d hs)" ,
"%s IS A MONSTER!^nwith %d kills (%d hs)",
"%s IS GODLIKE!!!!^nwith %d kills (%d hs)"
}
new g_Sounds[7][] = {
"multikill",
"ultrakill",
"killingspree",
"rampage",
"unstoppable",
"monsterkill",
"godlike"
}
new g_KillingMsg[7][] = {
"%s: Multi-Kill!",
"%s: Ultra-Kill!!!",
"%s IS ON A KILLING SPREE!!!",
"%s: RAMPAGE!!!",
"%s IS UNSTOPPABLE!!!",
"%s IS A MONSTER!",
"%s IS GODLIKE!!!"
}
new g_KinfeMsg[4][] = {
"%s sliced and diced %s",
"%s pulled out knife and gutted %s",
"%s sneaks carefully behind and knifed %s",
"%s knived %s"
}
new g_LastMessages[4][] = {
"Now all depend on you!",
"I hope you still have a healthpack.",
"All your teammates were killed. Good luck!",
"Now you are alone. Have fun!"
}
new g_HeMessages[4][] = {
"%s sends a little gift to %s",
"%s throws a small present to %s",
"%s made a precision throw to %s",
"%s got a big explosion for %s"
}
new g_SHeMessages[4][] = {
"%s detonated himself with a grenade",
"%s trys the effect of a HE Grenade",
"%s kicked a grenade into his own ass",
"%s explodes!"
}
new g_HeadShots[7][] = {
"$kn killed $vn with a well^nplaced shot to the head!",
"$kn removed $vn's^nhead with the $wn",
"$kn turned $vn's head^ninto pudding with the $wn",
"$vn got pwned by $kn",
"$vn's head has been^nturned into red jello",
"$kn has superb aim with the $wn,^nas $vn well knows.",
"$vn's head stayed in $kn's^ncrosshairs a bit too long..."
}
new g_teamsNames[2][] = {
"TERRORIST",
"CT"
}
public plugin_init(){
register_plugin("Misc. Stats","0.9","default")
register_event("DeathMsg","eDeathMsg","a")
register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("RoundTime", "eNewRound", "bc")
register_event("StatusValue","setTeam","be","1=1")
register_event("StatusValue","showStatus","be","1=2","2!0")
register_event("StatusValue","hideStatus","be","1=1","2=0")
new mapname[32]
get_mapname(mapname,31)
if (equali(mapname,"de_",3)||equali(mapname,"csde_",5)){
register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4")
register_event("SendAudio", "eBombPlanted", "a", "2&%!MRAD_BOMBPL")
register_event("SendAudio", "eBombDef", "a", "2&%!MRAD_BOMBDEF")
register_event("TextMsg", "eBombFail", "a", "2&#Target_B")
register_event("BarTime", "eBombDefG", "be", "1=10", "1=5","1=3")
register_event("BarTime", "eBombDefL", "be", "1=0")
register_event("TextMsg", "eBombPickUp", "bc", "2&#Got_bomb")
register_event("TextMsg", "eBombDrop", "bc", "2&#Game_bomb_d")
}
else if ( equali( mapname , "cs_italy" ) ) {
register_event( "23" , "chickenKill", "a" , "1=108" , /*"12=106",*/ "15=4" )
register_event( "23" , "radioKill", "a" , "1=108" , /*"12=294",*/ "15=2" )
}
}
public plugin_cfg(){
new g_addStast[] = "amx_statscfg add ^"%s^" %s"
server_cmd(g_addStast,"MultiKill","MultiKill")
server_cmd(g_addStast,"MultiKillSound","MultiKillSound")
server_cmd(g_addStast,"Bomb Planting","BombPlanting")
server_cmd(g_addStast,"Bomb Defusing","BombDefusing")
server_cmd(g_addStast,"Bomb Planted","BombPlanted")
server_cmd(g_addStast,"Bomb Defuse Succ.","BombDefused")
server_cmd(g_addStast,"Bomb Def. Failure","BombFailed")
server_cmd(g_addStast,"Bomb PickUp","BombPickUp")
server_cmd(g_addStast,"Bomb Drop","BombDrop")
server_cmd(g_addStast,"Bomb Count Down","BombCountVoice")
server_cmd(g_addStast,"Bomb Count Down (def)","BombCountDef")
server_cmd(g_addStast,"Bomb Site Reached","BombReached")
server_cmd(g_addStast,"Italy Bonus Kill","ItalyBonusKill")
server_cmd(g_addStast,"Last Man","LastMan")
server_cmd(g_addStast,"Knife Kill","KnifeKill")
server_cmd(g_addStast,"Knife Kill Sound","KnifeKillSound")
server_cmd(g_addStast,"Grenade Kill","GrenadeKill")
server_cmd(g_addStast,"Grenade Suicide","GrenadeSuicide")
server_cmd(g_addStast,"HeadShot Kill","HeadShotKill")
server_cmd(g_addStast,"HeadShot Kill Sound","HeadShotKillSound")
server_cmd(g_addStast,"Round Counter","RoundCounter")
server_cmd(g_addStast,"Round Counter Sound","RoundCounterSound")
server_cmd(g_addStast,"Killing Streak","KillingStreak")
server_cmd(g_addStast,"Killing Streak Sound","KillingStreakSound")
server_cmd(g_addStast,"Enemy Remaining","EnemyRemaining")
server_cmd(g_addStast,"Double Kill","DoubleKill")
server_cmd(g_addStast,"Double Kill Sound","DoubleKillSound")
server_cmd(g_addStast,"Player Name","PlayerName")
server_cmd(g_addStast,"First Blood Sound","FirstBloodSound")
}
public client_putinserver(id)
g_multiKills[id] = g_streakKills[ id ] = { 0 , 0 }
public eDeathMsg(){
new killerId = read_data(1)
if ( killerId == 0 ) return
new victimId = read_data(2)
new bool:enemykill = (get_user_team(killerId) != get_user_team(victimId))
new headshot = read_data(3)
if ( g_firstBlood ) {
g_firstBlood = 0
if ( FirstBloodSound ) client_cmd(0,"spk misc/firstblood")
}
if ( (KillingStreak || KillingStreakSound) && enemykill ) {
g_streakKills[ killerId ][ 0 ]++
g_streakKills[ killerId ][ 1 ] = 0
g_streakKills[ victimId ][ 1 ]++
g_streakKills[ victimId ][ 0 ] = 0
new a = g_streakKills[ killerId ][ 0 ] - 3
if ( (a > -1) && !( a % 2 ) ) {
new name[32]
get_user_name( killerId , name , 31 )
if ( (a >>= 1) > 6 ) a = 6
if ( KillingStreak ){
set_hudmessage(0, 100, 255, 0.05, 0.55, 2, 0.02, 6.0, 0.01, 0.1, 3)
show_hudmessage(0,g_KillingMsg[ a ], name )
}
if ( KillingStreakSound ) client_cmd( 0 , "spk misc/%s" , g_Sounds[ a ] )
}
}
if ( MultiKill || MultiKillSound ) {
if (killerId && enemykill ) {
g_multiKills[killerId][0]++
g_multiKills[killerId][1] += headshot
new param[2]
param[0] = killerId
param[1] = g_multiKills[killerId][0]
set_task( 4.0 + float( param[1] ) ,"checkKills",0,param,2)
}
}
if ( EnemyRemaining ) {
new ppl[32], pplnum
new team = get_user_team( victimId ) - 1
get_players(ppl,pplnum,"e", g_teamsNames[1 - team] )
if (pplnum){
new eppl[32], epplnum
get_players(eppl,epplnum,"ae",g_teamsNames[team])
if (epplnum) {
new message[128]
format(message,127,"%d %s%s Remaining...",epplnum,g_teamsNames[team],(epplnum==1)?"":"S" )
set_hudmessage(255,255,255,0.02,0.85,2, 0.05, 0.1, 0.02, 3.0, 3)
for(new a=0; a<pplnum; ++a) show_hudmessage(ppl[a],message)
//client_print(ppl[a],print_chat,message)
}
}
}
if ( LastMan ) {
new cts[32], ts[32], ctsnum, tsnum
get_players(cts,ctsnum,"ae", g_teamsNames[1] )
get_players(ts,tsnum,"ae", g_teamsNames[0] )
if ( ctsnum == 1 && tsnum == 1 ){
new ctname[32], tname[32]
get_user_name(cts[0],ctname,31)
get_user_name(ts[0],tname,31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%s vs. %s",ctname,tname)
client_cmd(0,"spk misc/maytheforce")
}
else if ( !g_LastAnnounce ) {
new oposite = 0, team = 0
if ( ctsnum == 1 && tsnum > 1 ) {
g_LastAnnounce = cts[0]
oposite = tsnum
team = 0
}
else if ( tsnum == 1 && ctsnum > 1 ) {
g_LastAnnounce = ts[0]
oposite = ctsnum
team = 1
}
if (g_LastAnnounce){
new name[32]
get_user_name(g_LastAnnounce,name,31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"%s (%d HP) vs. %d %s%s: %s",name,
get_user_health(g_LastAnnounce),oposite,
g_teamsNames[team],(oposite==1)?"":"S" ,g_LastMessages[ random_num(0,3) ] )
client_cmd(g_LastAnnounce,"spk misc/oneandonly")
}
}
}
new arg[4]
read_data( 4 , arg , 3 )
if ( equal( arg, "kni" ) && ( KnifeKill || KnifeKillSound ) ) {
if ( KnifeKill ) {
new killer[32], victim[32]
get_user_name(killerId,killer,31)
get_user_name(victimId,victim,31)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,g_KinfeMsg[ random_num(0,3) ],killer,victim)
}
if ( KnifeKillSound ) client_cmd(0,"spk misc/humiliation")
}
else if ( equal( arg, "gre" ) && (GrenadeKill || GrenadeSuicide) ) {
new killer[32], victim[32]
get_user_name(killerId,killer,32)
get_user_name(victimId,victim,32)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, 1)
if ( killerId != victimId ){
if ( GrenadeKill ) show_hudmessage(0,g_HeMessages[ random_num(0,3)],killer,victim)
}
else if ( GrenadeSuicide ) show_hudmessage(0,g_SHeMessages[ random_num(0,3) ],victim)
}
if ( headshot && (HeadShotKill || HeadShotKillSound) ) {
if ( HeadShotKill ){
new killer[32], victim[32], weapon[32], message[128]
get_user_name(killerId,killer,31)
get_user_name(victimId,victim,31)
read_data( 4 , weapon , 31 )
copy( message, 127, g_HeadShots[ random_num(0,6) ] )
replace( message, 127 , "$vn", victim )
replace( message, 127 , "$wn", weapon )
replace( message, 127 , "$kn", killer )
set_hudmessage(100, 100, 255, -1.0, 0.29, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,message )
}
if ( HeadShotKillSound ) {
client_cmd(killerId,"spk misc/headshot")
client_cmd(victimId,"spk misc/headshot")
}
}
if ( DoubleKill || DoubleKillSound ) {
new Float:nowtime = get_gametime()
if ( g_doubleKill == nowtime && g_doubleKillId == killerId ) {
if ( DoubleKill ) {
new name[32]
get_user_name( killerId , name , 31 )
set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0,"Wow! %s made a double kill!!!" ,name )
}
if ( DoubleKillSound ) client_cmd(0,"spk misc/doublekill")
}
g_doubleKill = nowtime
g_doubleKillId = killerId
}
}
public hideStatus(id)
if ( PlayerName ){
set_hudmessage(0,0,0,0.0,0.0,0, 0.0, 0.01, 0.0, 0.0, 4)
show_hudmessage(id,"")
}
public setTeam(id)
g_friend[id] = read_data(2)
public showStatus(id)
if ( PlayerName ){
new name[32],pid = read_data(2)
get_user_name(pid,name,31)
new color1 = 0,color2 = 0
if ( get_user_team(pid)==1 )
color1 = 255
else
color2 = 255
if (g_friend[id]==1){ // friend
new clip, ammo, wpnid = get_user_weapon(pid,clip,ammo)
new wpnname[32]
get_weaponname(wpnid,wpnname,31)
set_hudmessage(color1,50,color2,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, 4)
show_hudmessage(id,"%s -- %d HP / %d AP / %s",name,
get_user_health(pid),get_user_armor(pid),wpnname[7])
}
else {
set_hudmessage(color1,50,color2,-1.0,0.60,1, 0.01, 3.0, 0.01, 0.01, 4)
show_hudmessage(id,name)
}
}
public eNewRound()
if ( read_data(1) == floatround(get_cvar_float("mp_roundtime") * 60.0) ) {
g_firstBlood = 1
g_C4Timer = 0
++g_roundCount
if ( RoundCounter ) {
set_hudmessage(200, 0, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0, "Prepare to FIGHT!^nRound %d" , g_roundCount )
}
if ( RoundCounterSound ) client_cmd( 0 , "spk misc/prepare" )
if ( KillingStreak ) {
new appl[32],ppl, i
get_players(appl,ppl, "ac" )
for(new a = 0; a < ppl; ++a) {
i = appl[ a ]
if ( g_streakKills[ i ][ 0 ] >= 2 )
client_print( i , print_chat , "* You've killed %d in a row so far", g_streakKills[ i ][ 0 ] )
else if ( g_streakKills[ i ][ 1 ] >= 2 )
client_print( i , print_chat , "* Careful! You've died %d rounds in a row now...", g_streakKills[ i ][ 1 ] )
}
}
}
public eRestart(){
eEndRound()
g_roundCount = 0
g_firstBlood = 1
}
public eEndRound(){
g_C4Timer = -2
g_LastPlan = 0.0
g_LastOmg = 0.0
g_LastPlan = 0.0
remove_task(8038)
g_LastAnnounce = 0
}
public checkKills(param[]){
new id = param[0]
new a = param[1]
if (a == g_multiKills[id][0]){
a -= 3
if ( a > -1 ){
if ( MultiKill ) {
new name[32]
get_user_name(id,name,31)
set_hudmessage(255, 0, 100, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2)
if ( a > 6 ) a = 6
show_hudmessage(0,g_MultiKillMsg[a],name,g_multiKills[id][0],g_multiKills[id][1])
}
if ( MultiKillSound ) client_cmd(0,"spk misc/%s",g_Sounds[a])
}
g_multiKills[id] = { 0,0 }
}
}
public chickenKill()
if ( ItalyBonusKill ) announceEvent( 0 , "Somebody killed a chicken!!!" )
public radioKill()
if ( ItalyBonusKill ) announceEvent( 0 , "Somebody blew up the radio!!!" )
announceEvent( id , message[] ){
new name[32]
get_user_name(id, name , 31)
set_hudmessage(255, 100, 50, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0,message,name)
}
public eGotBomb(id){
g_Planter = id
g_Defuser = g_Defusing = 0
if ( BombReached && read_data(1)==2 && g_LastOmg<get_gametime()){
g_LastOmg = get_gametime() + 15.0
announceEvent(g_Planter , "Omg! %s reached the target!" )
}
}
public eBombDefG(id){
if (read_data(1) == 3){
if ( BombPlanting && g_LastPlan<get_gametime() ){
g_LastPlan = get_gametime() + 15.0
announceEvent(g_Planter , "%s is planting the bomb!" )
}
}
else {
g_Defuser = g_Defusing = id
if ( BombDefusing && g_LastPlan<get_gametime()){
g_LastPlan = get_gametime() + 15.0
announceEvent(g_Defusing , "%s is defusing the bomb..." )
}
}
}
public eBombDefL(id)
g_Defusing = 0
public eBombPlanted()
if ( g_C4Timer != -2 ){
if (BombPlanted) announceEvent(g_Planter , "%s set us up the bomb!!!" )
g_C4Timer = get_cvar_num("mp_c4timer") - 2
set_task(1.0,"bombTimer",8038,"",0,"b")
g_LastPlan = 0.0
}
public bombTimer(){
if (--g_C4Timer > 0){
if (BombCountVoice) {
if (g_C4Timer == 30 || g_C4Timer == 20){
new temp[48]
num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s seconds until explosion^"",temp)
}
else if (g_C4Timer < 11){
new temp[48]
num_to_word(g_C4Timer,temp,47)
client_cmd(0,"spk ^"vox/%s^"",temp)
}
}
if (BombCountDef && g_Defusing) client_print(g_Defusing,print_center,"%d",g_C4Timer)
}
else remove_task(8038)
}
public eBombDef()
if (BombDefused) announceEvent(g_Defuser , "%s defused the bomb!" )
public eBombFail()
if (BombFailed && g_Defuser ) announceEvent(g_Defuser , "%s failed to defuse the bomb..." )
public eBombPickUp(id)
if (BombPickUp) announceEvent(id , "%s pick up the bomb...")
public eBombDrop()
if (BombDrop) announceEvent(g_Planter , "%s dropped the bomb!!!")

137
plugins/nextmap.sma Executable file
View File

@ -0,0 +1,137 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Mapcycle is immune to manual map changes and map votes.
*
* Cvars:
* amx_nextmap < mapname > - sets nextmap
* Commands:
* say nextmap - dispalys the nextmap (available for all clients)
*/
#include <amxmod>
// WARNING: If you comment this line make sure
// that in your mapcycle file maps don't repeat.
// However the same map in a row is still valid.
#define OBEY_MAPCYCLE
new g_nextMap[32]
new g_mapCycle[32]
new g_pos
public plugin_init()
{
register_plugin("NextMap","0.9","default")
register_event( "30" , "changeMap", "a" )
register_clcmd("say nextmap","sayNextMap",0,"- displays nextmap")
register_cvar("amx_nextmap","",FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
new szString[32], szString2[32], szString3[8]
get_localinfo( "lastmapcycle", szString , 31 )
parse( szString, szString2, 31, szString3 , 7 )
g_pos = strtonum( szString3 )
get_cvar_string( "mapcyclefile" , g_mapCycle , 31 )
if ( !equal( g_mapCycle , szString2 ) )
g_pos = 0 // mapcyclefile has been changed - go from first
readMapCycle( g_mapCycle , g_nextMap , 31 )
set_cvar_string( "amx_nextmap", g_nextMap )
format( szString3 , 31, "%s %d", g_mapCycle , g_pos ) // save lastmapcycle settings
set_localinfo( "lastmapcycle", szString3 )
}
getNextMapName(szArg[],iMax){
new len = get_cvar_string("amx_nextmap",szArg,iMax)
if ( is_map_valid(szArg) ) return len
len = copy(szArg,iMax,g_nextMap)
set_cvar_string("amx_nextmap",g_nextMap)
return len
}
public sayNextMap(){
new name[32]
getNextMapName(name,31)
client_print(0,print_chat,"Next Map: %s",name)
}
public delayedChange( param[] )
server_cmd( "changelevel %s", param )
public changeMap(){
new string[32]
set_cvar_float( "mp_chattime" , 3.0 ) // make sure mp_chattime is long
new len = getNextMapName(string, 31) + 1
set_task( 1.5 , "delayedChange" , 0 , string , len ) // change with 1.5 sec. delay
}
new g_warning[] = "WARNING: Couldn't find a valid map or the file doesn't exist (file ^"%s^")"
#if defined OBEY_MAPCYCLE
readMapCycle(szFileName[], szNext[], iNext ){
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32]
if ( file_exists( szFileName ) ) {
while( read_file( szFileName , i++ , szBuffer , 31 , b ) ) {
if ( !isalpha( szBuffer[0] ) || !is_map_valid( szBuffer ) ) continue
if ( !iMaps ) copy( szFirst, 31, szBuffer )
if ( ++iMaps > g_pos ) {
copy( szNext , iNext , szBuffer )
g_pos = iMaps
return
}
}
}
if ( !iMaps ) {
log_message( g_warning , szFileName )
get_mapname( szFirst , 31 )
}
copy( szNext , iNext , szFirst )
g_pos = 1
}
#else
readMapCycle(szFileName[], szNext[], iNext )
{
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32], szCurrent[32]
get_mapname( szCurrent , 31 )
new a = g_pos
if ( file_exists( szFileName ) ) {
while( read_file( szFileName , i++ , szBuffer , 31 , b ) ) {
if ( !isalpha( szBuffer[0] ) || !is_map_valid( szBuffer ) ) continue
if ( !iMaps ) {
iMaps = 1
copy( szFirst, 31, szBuffer )
}
if ( iMaps == 1 ){
if ( equali( szCurrent , szBuffer ) ) {
if ( a-- == 0 )
iMaps = 2
}
}
else {
if ( equali( szCurrent , szBuffer ) )
++g_pos
else
g_pos = 0
copy( szNext , iNext , szBuffer )
return
}
}
}
if ( !iMaps ) {
log_message( g_warning , szFileName )
copy( szNext ,iNext , szCurrent )
}
else copy( szNext ,iNext , szFirst )
g_pos = 0
}
#endif

366
plugins/pausecfg.sma Executable file
View File

@ -0,0 +1,366 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Admin commads:
* amx_pausecfgmenu - displays menu by which you can pause, unpause and stop plugins
* amx_pausecfg - list commands for pause/unpause managment
*
* WARNING: Stopped plugins won't work properly after activation
* (without mapchange) due to unactive status during players connections.
* For proper activation clear the file with stopped plugins
* (option #7 in menu) or unstop selected one, save configuration,
* then change your map.
*/
#include <amxmod>
#include <amxmisc>
// Uncomment if you want to have two new commands
// amx_off - pause plugins not marked as unpauseable
// amx_on - enable plugins not marked as unpauseable
//#define DIRECT_ONOFF
#define MAX_SYSTEM 32
new g_menuPos[33]
new g_fileToSave[64]
new g_cstrikeRunning
new g_Modified
new g_couldntFind[] = "Couldn't find a plugin matching ^"%s^""
new g_pluginMatch[] = "Plugin matching ^"%s^" %s"
new g_addCmd[] = "amx_pausecfg add ^"%s^""
new g_system[MAX_SYSTEM]
new g_systemNum
public plugin_init(){
register_plugin("Pause Plugins","0.9","default")
register_concmd("amx_pausecfg","cmdPlugin",ADMIN_CFG,"- list commands for pause/unpause managment")
register_clcmd("amx_pausecfgmenu","cmdMenu",ADMIN_CFG,"- pause/unpause plugins with menu")
#if defined DIRECT_ONOFF
register_concmd("amx_off","cmdOFF",ADMIN_CFG,"- pauses some plugins")
register_concmd("amx_on","cmdON",ADMIN_CFG,"- unpauses some plugins")
#endif
register_menucmd(register_menuid("Pause/Unpause Plugins"),1023,"actionMenu")
g_cstrikeRunning = is_running("cstrike")
return PLUGIN_CONTINUE
}
#if defined DIRECT_ONOFF
public cmdOFF(id,level,cid){
if (cmd_access(id,level,cid,1))
pausePlugins(id)
return PLUGIN_HANDLED
}
public cmdON(id,level,cid){
if (cmd_access(id,level,cid,1))
unpausePlugins(id)
return PLUGIN_HANDLED
}
#endif
public plugin_cfg() {
build_path( g_fileToSave , 63 , "$basedir/pausecfg.ini" )
loadSettings(g_fileToSave)
// Put here titles of plugins which you don't want to pause
server_cmd(g_addCmd , "Pause Plugins" )
server_cmd(g_addCmd , "Admin Commands" )
server_cmd(g_addCmd , "TimeLeft" )
server_cmd(g_addCmd , "Slots Reservation" )
server_cmd(g_addCmd , "Admin Chat" )
server_cmd(g_addCmd , "NextMap" )
server_cmd(g_addCmd , "Admin Help" )
server_cmd(g_addCmd , "Admin Base" )
server_cmd(g_addCmd , "Admin Votes" )
server_cmd(g_addCmd , "Welcome Message" )
server_cmd(g_addCmd , "Stats Configuration" )
server_cmd(g_addCmd , "Commands Menu" )
server_cmd(g_addCmd , "Maps Menu" )
server_cmd(g_addCmd , "Menus Front-End" )
server_cmd(g_addCmd , "Admin Base for MySQL" )
server_cmd(g_addCmd , "Players Menu" )
server_cmd(g_addCmd , "Teleport Menu" )
}
public actionMenu(id,key){
switch(key){
case 6:{
if (file_exists(g_fileToSave)){
delete_file(g_fileToSave)
client_print(id,print_chat,"* Configuration file cleared. Reload the map if needed")
}
else
client_print(id,print_chat,"* Configuration was already cleared!")
displayMenu(id,g_menuPos[id])
}
case 7:{
if (saveSettings(g_fileToSave)){
g_Modified = 0
client_print(id,print_chat,"* Configuration saved successfully")
}
else
client_print(id,print_chat,"* Configuration saving failed!!!")
displayMenu(id,g_menuPos[id])
}
case 8: displayMenu(id,++g_menuPos[id])
case 9: displayMenu(id,--g_menuPos[id])
default:{
new option = g_menuPos[id] * 6 + key
new file[32],status[2]
get_plugin(option,file,31,status,0,status,0,status,0,status,1)
switch( status[0] ) {
case 'r': pause("ac",file)
case 'p': {
g_Modified = 1
pause("dc",file)
}
case 's': {
g_Modified = 1
unpause("ac",file)
}
}
displayMenu(id,g_menuPos[id])
}
}
return PLUGIN_HANDLED
}
getStatus( code, arg[], iarg ){
switch(code){
case 'r': copy( arg, iarg , "ON" )
case 's': copy( arg, iarg , "STOPPED" )
case 'p': copy( arg, iarg , "OFF" )
case 'b': copy( arg, iarg , "ERROR" )
default: copy( arg, iarg , "LOCKED" )
}
}
isSystem( id ){
for( new a = 0; a < g_systemNum; ++a)
if ( g_system[ a ] == id )
return 1
return 0
}
displayMenu(id, pos){
if (pos < 0) return
new filename[32],title[32],status[8]
new datanum = get_pluginsnum()
new menu_body[512], start = pos * 6, k = 0
if (start >= datanum) start = pos = g_menuPos[id] = 0
new len = format(menu_body,511,
g_cstrikeRunning ? "\yPause/Unpause Plugins\R%d/%d^n\w^n" : "Pause/Unpause Plugins %d/%d^n^n" ,
pos + 1,((datanum/6)+((datanum%6)?1:0)))
new end = start + 6, keys = (1<<9)|(1<<7)|(1<<6)
if (end > datanum) end = datanum
for(new a = start; a < end; ++a){
get_plugin(a,filename,31,title,31,status,0,status,0,status,1)
getStatus( status[0] , status , 7 )
if ( isSystem( a ) || (status[0]!='O'&&status[0]!='S')) {
if (g_cstrikeRunning){
len += format(menu_body[len],511-len, "\d%d. %s\R%s^n\w",++k, title, status )
}
else{
++k
len += format(menu_body[len],511-len, "#. %s %s^n", title, status )
}
}
else{
keys |= (1<<k)
len += format(menu_body[len],511-len,g_cstrikeRunning ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n",++k,title, status )
}
}
len += format(menu_body[len],511-len,"^n7. Clear file with stopped^n")
len += format(menu_body[len],511-len,g_cstrikeRunning ? "8. Save stopped \y\R%s^n\w"
: "8. Save stopped %s^n" ,g_Modified ? "*" : "")
if (end != datanum){
format(menu_body[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menu_body[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menu_body)
}
public cmdMenu(id,level,cid){
if (cmd_access(id,level,cid,1))
displayMenu(id,g_menuPos[id] = 0)
return PLUGIN_HANDLED
}
pausePlugins(id){
new filename[32],title[32],status[2]
new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){
get_plugin(a,filename,31,title,31,status,0,status,0,status,1)
if ( !isSystem( a ) && status[0]=='r' && pause("ac",filename) ) {
//console_print(id,"Pausing %s (file ^"%s^")",title,filename)
++count
}
}
console_print(id,"Paused %d plugin%s",count,(count==1)?"":"s")
}
unpausePlugins(id){
new filename[32],title[32],status[2]
new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){
get_plugin(a,filename,31,title,31,status,0,status,0,status,1)
if ( !isSystem( a ) && status[0]=='p' && unpause("ac",filename) ) {
//console_print(id,"Unpausing %s (file ^"%s^")",title,filename)
++count
}
}
console_print(id,"Unpaused %d plugin%s",count,(count==1)?"":"s")
}
findPluginByFile(arg[32],&len){
new name[32],title[32],status[2]
new inum = get_pluginsnum()
for(new a = 0; a < inum; ++a){
get_plugin(a,name,31,title,31,status,0,status,0,status,1)
if ( equali(name,arg,len) && (status[0]=='r'||status[0]=='p'||status[0]=='s') ){
len = copy(arg,31,name)
return a
}
}
return -1
}
findPluginByTitle(name[],file[],len){
new title[32],status[2]
new inum = get_pluginsnum()
for(new a = 0; a < inum; ++a){
get_plugin(a,file,len,title,31,status,0,status,0,status,1)
if ( equali( title , name ) )
return a
}
return -1
}
public cmdPlugin(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new cmds[32]
read_argv(1,cmds,31)
if ( equal(cmds, "add" ) && read_argc() > 2 ) {
read_argv(2, cmds ,31)
new file[2]
if ( (g_system[ g_systemNum ] = findPluginByTitle( cmds , file , 0 )) != -1 ) {
if ( g_systemNum < MAX_SYSTEM )
g_systemNum++
else
console_print( id , "Can't mark more plugins as unpauseable!" )
}
}
else if ( equal(cmds, "off" ) ){
pausePlugins(id)
}
else if ( equal(cmds, "on" ) ){
unpausePlugins(id)
}
else if ( equal(cmds, "save" ) ){
if (saveSettings(g_fileToSave)){
g_Modified = 0
console_print(id,"Configuration saved successfully")
}
else
console_print(id,"Configuration saving failed!!!")
}
else if ( equal(cmds, "clear" ) ) {
if (file_exists(g_fileToSave)){
delete_file(g_fileToSave)
console_print(id,"Configuration file cleared. Reload the map if needed")
}
else
console_print(id,"Configuration was already cleared!")
}
else if ( equal(cmds, "pause" ) ) {
new arg[32], a ,len = read_argv(2,arg,31)
if ( len && ((a = findPluginByFile(arg,len)) != -1) && !isSystem( a ) && pause("ac",arg) )
console_print(id,g_pluginMatch,arg , "paused")
else console_print(id,g_couldntFind,arg)
}
else if ( equal(cmds, "enable" ) ) {
new arg[32], a , len = read_argv(2,arg,31)
if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && unpause("ac",arg) )
console_print(id,g_pluginMatch,arg , "unpaused")
else console_print(id,g_couldntFind,arg)
}
else if ( equal(cmds, "stop" ) ) {
new arg[32], a, len = read_argv(2,arg,31)
if ( len && (a = findPluginByFile(arg,len)) != -1 && !isSystem( a ) && pause("dc",arg)){
g_Modified = 1
console_print(id,g_pluginMatch,arg , "stopped")
}
else console_print(id,g_couldntFind,arg)
}
else if ( equal(cmds, "list" ) ) {
new arg1[8], running = 0
new start = read_argv(2,arg1,7) ? strtonum(arg1) : 1
if (--start < 0) start = 0
new plgnum = get_pluginsnum()
if (start >= plgnum) start = plgnum - 1
console_print(id,"^n----- Pause Plugins: Loaded plugins -----")
console_print(id, " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s","name","version","author","file","status")
new plugin[32],title[32],version[16],author[32],status[16]
new end = start + 10
if (end > plgnum) end = plgnum
for (new a = start; a < end; ++a){
get_plugin(a,plugin,31,title,31,version,15,author,31,status,15)
if (status[0] == 'r') ++running
console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s",a+1,title,version,author,plugin, status )
}
console_print(id,"----- Entries %d - %d of %d (%d running) -----",start+1,end,plgnum,running)
if (end < plgnum)
console_print(id,"----- Use 'amx_pausecfg list %d' for more -----",end+1)
else
console_print(id,"----- Use 'amx_pausecfg list 1' for begin -----")
}
else {
console_print(id,"Usage: amx_pausecfg <command> [name]")
console_print(id,"Commands:")
console_print(id,"^toff - pauses all plugins not in the list")
console_print(id,"^ton - unpauses all plugins")
console_print(id,"^tstop <file> - stops a plugin")
console_print(id,"^tpause <file> - pauses a plugin")
console_print(id,"^tenable <file> - enables a plugin")
console_print(id,"^tsave - saves a list of stopped plugins")
console_print(id,"^tclear - clears a list of stopped plugins")
console_print(id,"^tlist [id] - lists plugins")
console_print(id,"^tadd <title> - marks a plugin as unpauseable")
}
return PLUGIN_HANDLED
}
saveSettings(filename[]){
if (file_exists(filename))
delete_file(filename)
new text[256], file[32],title[32],status[2]
new inum = get_pluginsnum()
if (!write_file(filename,";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename"))
return 0
for(new a = 0; a < inum; ++a){
get_plugin(a,file,31,title,31,status,0,status,0,status,1)
if ( status[0] == 's' ){
format(text,255,"^"%s^" ;%s",title,file)
write_file(filename,text)
}
}
return 1
}
loadSettings(filename[]){
if (!file_exists(filename)) return 0
new name[256], file[32], i, pos = 0
while (read_file(filename,pos++,name,255,i)){
if ( name[0]!= ';' && parse(name,name,31) &&
(i = findPluginByTitle( name , file , 31 ) != -1) )
pause("dc", file )
}
return 1
}

689
plugins/plmenu.sma Executable file
View File

@ -0,0 +1,689 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Admin commands:
* amx_kickmenu - displays kick menu
* amx_banmenu - displays ban menu
* amx_slapmenu - displays slap/slay menu
* amx_teammenu - displays team menu
* amx_clcmdmenu - displays client commands menu
*
*/
#include <amxmod>
#include <amxmisc>
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_menuOption[33]
new g_menuSettings[33]
new g_menuSelect[33][64]
new g_menuSelectNum[33]
#define MAX_CLCMDS 24
new g_clcmdName[MAX_CLCMDS][32]
new g_clcmdCmd[MAX_CLCMDS][64]
new g_clcmdMisc[MAX_CLCMDS][2]
new g_clcmdNum
new g_logFile[16]
new g_cstrikeRunning
public plugin_init()
{
register_plugin("Players Menu","0.9","default")
register_clcmd("amx_kickmenu","cmdKickMenu",ADMIN_KICK,"- displays kick menu")
register_clcmd("amx_banmenu","cmdBanMenu",ADMIN_BAN,"- displays ban menu")
register_clcmd("amx_slapmenu","cmdSlapMenu",ADMIN_SLAY,"- displays slap/slay menu")
register_clcmd("amx_teammenu","cmdTeamMenu",ADMIN_LEVEL_A,"- displays team menu")
register_clcmd("amx_clcmdmenu","cmdClcmdMenu",ADMIN_LEVEL_A,"- displays client cmds menu")
register_menucmd(register_menuid("Ban Menu"),1023,"actionBanMenu")
register_menucmd(register_menuid("Kick Menu"),1023,"actionKickMenu")
register_menucmd(register_menuid("Slap/Slay Menu"),1023,"actionSlapMenu")
register_menucmd(register_menuid("Team Menu"),1023,"actionTeamMenu")
register_menucmd(register_menuid("Client Cmds Menu"),1023,"actionClcmdMenu")
g_cstrikeRunning = is_running("cstrike")
new filename[64]
build_path( filename , 63 , "$basedir/clcmds.ini" )
load_settings( filename )
get_logfile(g_logFile,15)
}
/* Ban menu */
public actionBanMenu(id,key)
{
switch(key){
case 7:{
++g_menuOption[id]
g_menuOption[id] %= 3
switch(g_menuOption[id]){
case 0: g_menuSettings[id] = 0
case 1: g_menuSettings[id] = 5
case 2: g_menuSettings[id] = 60
}
displayBanMenu(id,g_menuPosition[id])
}
case 8: displayBanMenu(id,++g_menuPosition[id])
case 9: displayBanMenu(id,--g_menuPosition[id])
default:{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name[32], name2[32], authid[32],authid2[32]
get_user_name(player,name2,31)
get_user_authid(id,authid,31)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
new userid2 = get_user_userid(player)
log_to_file(g_logFile,"Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")",
name,get_user_userid(id),authid, name2,userid2,authid2, g_menuSettings[id] )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: ban %s",name,name2)
case 1: client_print(0,print_chat,"ADMIN: ban %s",name2)
}
if (equal("4294967295",authid2)){ /* lan */
new ipa[32]
get_user_ip(player,ipa,31,1)
server_cmd("addip %d %s;writeip",g_menuSettings[id],ipa)
}
else
server_cmd("banid %d #%d kick;writeid",g_menuSettings[id],userid2)
server_exec()
displayBanMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayBanMenu(id,pos){
if (pos < 0) return
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\yBan Menu\R%d/%d^n\w^n" : "Ban Menu %d/%d^n^n",
pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
new end = start + 7
new keys = (1<<9)|(1<<7)
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for(new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if ( is_user_bot(i) || (get_user_flags(i)&ADMIN_IMMUNITY) )
{
++b
if ( g_cstrikeRunning )
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
else
len += format(menuBody[len],511-len,"#. %s^n",name)
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
}
}
if ( g_menuSettings[id] )
len += format(menuBody[len],511-len,"^n8. Ban on %d minutes^n" , g_menuSettings[id] )
else
len += format(menuBody[len],511-len,"^n8. Ban permanently^n" )
if (end != g_menuPlayersNum[id])
{
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
public cmdBanMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
g_menuOption[id] = 1
g_menuSettings[id] = 5
displayBanMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Slap/Slay */
public actionSlapMenu(id,key)
{
switch(key){
case 7:{
++g_menuOption[id]
g_menuOption[id] %= 4
switch(g_menuOption[id]){
case 1: g_menuSettings[id] = 0
case 2: g_menuSettings[id] = 1
case 3: g_menuSettings[id] = 5
}
displaySlapMenu(id,g_menuPosition[id])
}
case 8: displaySlapMenu(id,++g_menuPosition[id])
case 9: displaySlapMenu(id,--g_menuPosition[id])
default:{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name2[32]
get_user_name(player,name2,31)
if (!is_user_alive(player))
{
client_print(id,print_chat,"That action can't be performed on dead client ^"%s^"",name2)
displaySlapMenu(id,g_menuPosition[id])
return PLUGIN_HANDLED
}
new authid[32],authid2[32], name[32]
get_user_authid(id,authid,31)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
if ( g_menuOption[id] ) {
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"",
name,get_user_userid(id),authid, g_menuSettings[id], name2,get_user_userid(player),authid2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: slap %s with %d damage",name,name2,g_menuSettings[id])
case 1: client_print(0,print_chat,"ADMIN: slap %s with %d damage",name2,g_menuSettings[id])
}
}
else {
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"",
name,get_user_userid(id),authid, name2,get_user_userid(player),authid2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: slay %s",name,name2)
case 1: client_print(0,print_chat,"ADMIN: slay %s",name2)
}
}
if ( g_menuOption[id])
user_slap(player, ( get_user_health(player) > g_menuSettings[id] ) ? g_menuSettings[id] : 0 )
else
user_kill( player )
displaySlapMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displaySlapMenu(id,pos){
if (pos < 0) return
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32], team[4]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\ySlap/Slay Menu\R%d/%d^n\w^n" : "Slap/Slay Menu %d/%d^n^n" ,
pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
new end = start + 7
new keys = (1<<9)|(1<<7)
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for(new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
get_user_team(i,team,3)
if ( !is_user_alive(i) || (get_user_flags(i)&ADMIN_IMMUNITY) )
{
++b
if ( g_cstrikeRunning )
len += format(menuBody[len],511-len,"\d%d. %s\R%s^n\w", b,name,team)
else
len += format(menuBody[len],511-len,"#. %s %s^n",name,team)
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len, g_cstrikeRunning ?
"%d. %s\y\R%s^n\w" : "%d. %s %s^n",++b,name,team)
}
}
if ( g_menuOption[id] )
len += format(menuBody[len],511-len,"^n8. Slap with %d damage^n",g_menuSettings[id] )
else
len += format(menuBody[len],511-len,"^n8. Slay^n")
if (end != g_menuPlayersNum[id])
{
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
public cmdSlapMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
g_menuOption[id] = 0
g_menuSettings[id] = 0
displaySlapMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Kick */
public actionKickMenu(id,key)
{
switch(key){
case 8: displayKickMenu(id,++g_menuPosition[id])
case 9: displayKickMenu(id,--g_menuPosition[id])
default:{
new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
new authid[32],authid2[32], name[32], name2[32]
get_user_authid(id,authid,31)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
get_user_name(player,name2,31)
new userid2 = get_user_userid(player)
log_to_file(g_logFile,"Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^"",
name,get_user_userid(id),authid, name2,userid2,authid2 )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: kick %s",name,name2)
case 1: client_print(0,print_chat,"ADMIN: kick %s",name2)
}
server_cmd("kick #%d",userid2)
server_exec()
displayKickMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayKickMenu(id,pos){
if (pos < 0) return
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 8
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\yKick Menu\R%d/%d^n\w^n" : "Kick Menu %d/%d^n^n",
pos+1,( g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0 )) )
new end = start + 8
new keys = (1<<9)
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for(new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if ( get_user_flags(i) & ADMIN_IMMUNITY )
{
++b
if ( g_cstrikeRunning )
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
else
len += format(menuBody[len],511-len,"#. %s^n",name)
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
}
}
if (end != g_menuPlayersNum[id])
{
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
public cmdKickMenu(id,level,cid)
{
if (cmd_access(id,level,cid,1))
displayKickMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Team menu */
public actionTeamMenu(id,key)
{
switch(key){
case 7:{
g_menuOption[id] = 1 - g_menuOption[id]
displayTeamMenu(id,g_menuPosition[id])
}
case 8: displayTeamMenu(id,++g_menuPosition[id])
case 9: displayTeamMenu(id,--g_menuPosition[id])
default:{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new authid[32],authid2[32], name[32], name2[32]
get_user_name(player,name2,31)
get_user_authid(id,authid,31)
get_user_authid(player,authid2,31)
get_user_name(id,name,31)
log_to_file(g_logFile,"Cmd: ^"%s<%d><%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")",
name,get_user_userid(id),authid, name2,get_user_userid(player),authid2, g_menuOption[id] ? "TERRORIST" : "CT" )
switch(get_cvar_num("amx_show_activity")) {
case 2: client_print(0,print_chat,"ADMIN %s: transfer %s to %s",name,name2,g_menuOption[id] ? "TERRORIST" : "CT" )
case 1: client_print(0,print_chat,"ADMIN: transfer %s to %s",name2,g_menuOption[id] ? "TERRORIST" : "CT" )
}
new limitt = get_cvar_num("mp_limitteams")
set_cvar_num("mp_limitteams",0)
user_kill(player,1)
engclient_cmd(player, "chooseteam")
engclient_cmd(player, "menuselect", g_menuOption[id] ? "1" : "2" )
engclient_cmd(player, "menuselect", "5")
client_cmd(player,"slot1")
set_cvar_num("mp_limitteams",limitt)
displayTeamMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayTeamMenu(id,pos){
if (pos < 0) return
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i, iteam
new name[32], team[4]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\yTeam Menu\R%d/%d^n\w^n" : "Team Menu %d/%d^n^n",
pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
new end = start + 7
new keys = (1<<9)|(1<<7)
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for(new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
iteam = get_user_team(i,team,3)
if ( (iteam == (g_menuOption[id] ? 1 : 2)) || (get_user_flags(i)&ADMIN_IMMUNITY) )
{
++b
if ( g_cstrikeRunning )
len += format(menuBody[len],511-len,"\d%d. %s\R%s^n\w",b,name,team)
else
len += format(menuBody[len],511-len,"#. %s %s^n",name,team)
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len, g_cstrikeRunning ?
"%d. %s\y\R%s^n\w" : "%d. %s %s^n",++b,name,team)
}
}
len += format(menuBody[len],511-len,"^n8. Transfer to %s^n",g_menuOption[id] ? "TERRORIST" : "CT" )
if (end != g_menuPlayersNum[id])
{
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
public cmdTeamMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
g_menuOption[id] = 0
displayTeamMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Client cmds menu */
public actionClcmdMenu(id,key)
{
switch(key){
case 7:{
++g_menuOption[id]
g_menuOption[id] %= g_menuSelectNum[id]
displayClcmdMenu(id,g_menuPosition[id])
}
case 8: displayClcmdMenu(id,++g_menuPosition[id])
case 9: displayClcmdMenu(id,--g_menuPosition[id])
default:{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new flags = g_clcmdMisc[g_menuSelect[id][g_menuOption[id]]][1]
if (is_user_connected(player)) {
new command[64], authid[32], name[32], userid[32]
copy(command,63,g_clcmdCmd[g_menuSelect[id][g_menuOption[id]]])
get_user_authid(player,authid,31)
get_user_name(player,name,31)
numtostr(get_user_userid(player),userid,31)
replace(command,63,"%userid%",userid)
replace(command,63,"%authid%",authid)
replace(command,63,"%name%",name)
if (flags & 1){
server_cmd(command)
server_exec()
}
else if (flags & 2)
client_cmd(id,command)
else if (flags & 4)
client_cmd(player,command)
}
if (flags & 8) displayClcmdMenu(id,g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayClcmdMenu(id,pos){
if (pos < 0) return
get_players(g_menuPlayers[id],g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_cstrikeRunning ?
"\yClient Cmds Menu\R%d/%d^n\w^n" : "Client Cmds Menu %d/%d^n^n",
pos+1,( g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )
new end = start + 7
new keys = (1<<9)|(1<<7)
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for(new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i,name,31)
if ( !g_menuSelectNum[id] || get_user_flags(i)&ADMIN_IMMUNITY )
{
++b
if ( g_cstrikeRunning )
len += format(menuBody[len],511-len,"\d%d. %s^n\w",b,name)
else
len += format(menuBody[len],511-len,"#. %s^n",name)
}
else
{
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b,name)
}
}
if ( g_menuSelectNum[id] )
len += format(menuBody[len],511-len,"^n8. %s^n", g_clcmdName[g_menuSelect[id][g_menuOption[id]]] )
else
len += format(menuBody[len],511-len,"^n8. No cmds available^n")
if (end != g_menuPlayersNum[id])
{
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menuBody)
}
public cmdClcmdMenu(id,level,cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new flags = get_user_flags(id)
g_menuSelectNum[id] = 0
for(new a = 0; a < g_clcmdNum; ++a)
if (g_clcmdMisc[a][0] & flags)
g_menuSelect[id][g_menuSelectNum[id]++] = a
g_menuOption[id] = 0
displayClcmdMenu(id,g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
load_settings( szFilename[] )
{
if ( !file_exists ( szFilename ) )
return 0
new text[256], szFlags[32], szAccess[32]
new a, pos = 0
while ( g_clcmdNum < MAX_CLCMDS && read_file (szFilename,pos++,text,255,a) )
{
if ( text[0] == ';' ) continue
if ( parse( text , g_clcmdName[g_clcmdNum] , 31 ,
g_clcmdCmd[g_clcmdNum] ,63,szFlags,31,szAccess,31 ) > 3 )
{
while ( replace( g_clcmdCmd[ g_clcmdNum ] ,63,"\'","^"") ) {
// do nothing
}
g_clcmdMisc[ g_clcmdNum ][1] = read_flags ( szFlags )
g_clcmdMisc[ g_clcmdNum ][0] = read_flags ( szAccess )
g_clcmdNum++
}
}
return 1
}

396
plugins/ppause.sma Executable file
View File

@ -0,0 +1,396 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Admin commads:
* amx_pausemenu - displays menu by which you can pause, unpause and stop plugins
* amx_plugin - displays help for all commands for that plugin
*
* WARNING: Stopped plugins won't work properly after activation
* (without mapchange) due to unactive status during plugins initialization
* and at players connections. For proper activation clear the file with
* stopped plugins (option #7 in menu) or unstop selected one then change the map.
*/
#include <amxmod>
#include <amxmisc>
// Uncomment if you want to have two new commands
// amx_off - pause plugins not registered in the unpauseable list
// amx_on - enable all plugins not registered in the unpauseable list
//#define DIRECT_ONOFF
#define MAX_PLGDATA 64
#define MAX_PLUGINS 192
enum {
PLG_ERROR,
PLG_ON,
PLG_OFF,
PLG_STOPPED
}
new g_pluginList[MAX_PLGDATA][32]
new g_pluginListNum
new g_menuPos[33]
new g_dontPause[MAX_PLGDATA]
new g_dontPauseNum
new g_pluginStatus[MAX_PLUGINS]
new bool:g_Modified
new g_fileToSave[64]
new g_cstrikeRunning
public plugin_init(){
register_plugin("Pause Plugins","0.9","default")
#if defined DIRECT_ONOFF
register_concmd("amx_off","cmdOFF",ADMIN_CFG,"- pause some plugins")
register_concmd("amx_on","cmdON",ADMIN_CFG,"- unpause some plugins")
#endif
register_concmd("amx_plugin","cmdPause",ADMIN_CFG,"- list cmds. for pause/unpause managment")
register_clcmd("amx_pausemenu","cmdMenu",ADMIN_CFG,"- pause or unpause plugins via menu")
register_menucmd(register_menuid("Pause/Unpause Plugins"),1023,"actionMenu")
get_localinfo( "amx_basedir", g_fileToSave , 31 )
format( g_fileToSave , 63, "%s/ppause.ini" , g_fileToSave )
loadSettings(g_fileToSave)
new mod_name[32]
get_modname(mod_name,31)
g_cstrikeRunning = equal(mod_name,"cstrike")
}
new g_addCmd[] = "amx_plugin add ^"%s^""
public plugin_cfg() {
/* Put here titles of plugins which you don't want to pause. */
server_cmd(g_addCmd , "Pause Plugins" )
server_cmd(g_addCmd , "Admin Commands" )
server_cmd(g_addCmd , "TimeLeft" )
server_cmd(g_addCmd , "Slots Reservation" )
server_cmd(g_addCmd , "Admin Chat" )
server_cmd(g_addCmd , "NextMap" )
server_cmd(g_addCmd , "Admin Menu" )
server_cmd(g_addCmd , "Admin Help" )
server_cmd(g_addCmd , "Admin Base" )
server_cmd(g_addCmd , "Welcome Message" )
server_cmd(g_addCmd , "Stats Settings" )
}
public actionMenu(id,key){
switch(key){
case 6:{
if (file_exists(g_fileToSave)){
delete_file(g_fileToSave)
client_print(id,print_chat,"* Configuration file cleared")
}
else
client_print(id,print_chat,"* Configuration was already cleared!")
displayMenu(id,g_menuPos[id])
}
case 7:{
if (saveSettings(g_fileToSave)){
g_Modified = false
client_print(id,print_chat,"* Configuration saved successfully")
}
else
client_print(id,print_chat,"* Configuration saving failed!!!")
displayMenu(id,g_menuPos[id])
}
case 8: displayMenu(id,++g_menuPos[id])
case 9: displayMenu(id,--g_menuPos[id])
default:{
new option = g_menuPos[id] * 6 + key
new filename[32],title[32],version[2],author[2],status[2]
get_plugin(option,filename,31,title,31,version,0,author,0,status,1)
if (status[0]=='r'){
pause("ac",filename)
g_pluginStatus[option]=PLG_OFF
}
else if ( g_pluginStatus[option]!=PLG_STOPPED && status[0]=='p' ){
g_pluginStatus[option]=PLG_STOPPED
g_Modified = true
}
else {
unpause("ac",filename)
g_pluginStatus[option]=PLG_ON
}
displayMenu(id,g_menuPos[id])
}
}
return PLUGIN_HANDLED
}
displayMenu(id, pos){
if (pos < 0) return
new filename[32],title[32],version[2],author[2],status[2]
new datanum = get_pluginsnum()
new menu_body[512], start = pos * 6, k = 0
if (start >= datanum) start = pos = g_menuPos[id] = 0
new len = format(menu_body,511,
g_cstrikeRunning ? "\yPause/Unpause Plugins\R%d/%d^n\w^n" : "Pause/Unpause Plugins %d/%d^n^n" ,
pos + 1,((datanum/6)+((datanum%6)?1:0)))
new end = start + 6, keys = (1<<9)|(1<<7)|(1<<6)
if (end > datanum) end = datanum
for(new a = start; a < end; ++a){
get_plugin(a,filename,31,title,31,version,0,author,0,status,1)
if (dontPause(a)||(status[0]!='r'&&status[0]!='p')) {
if (g_cstrikeRunning){
len += format(menu_body[len],511-len, "\d%d. %s\R%s^n\w",++k,
title, ( status[0]=='r' ) ? "ON" : ( ( status[0]=='p' ) ? "OFF" : "ERROR" ) )
}
else{
++k
len += format(menu_body[len],511-len, "#. %s %s^n",
title, ( status[0]=='r' ) ? "ON" : ( ( status[0]=='p' ) ? "OFF" : "ERROR" ) )
}
}
else{
keys |= (1<<k)
len += format(menu_body[len],511-len,g_cstrikeRunning ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n",++k,
title, ( status[0]=='r' ) ? "ON" : ((g_pluginStatus[a]==PLG_STOPPED)?"STOPPED":"OFF"))
}
}
len += format(menu_body[len],511-len,"^n7. Clear file with stopped^n")
len += format(menu_body[len],511-len,g_cstrikeRunning ? "8. Save stopped \y\R%s^n\w"
: "8. Save stopped %s^n" ,g_Modified ? "*" : "")
if (end != datanum){
format(menu_body[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menu_body[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menu_body)
}
public cmdMenu(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
if (g_dontPauseNum != g_pluginListNum) chkStatus()
displayMenu(id,g_menuPos[id] = 0)
return PLUGIN_HANDLED
}
pasueALL(id){
if (g_dontPauseNum != g_pluginListNum) chkStatus()
new filename[32],title[32],version[2],author[2],status[2]
new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){
get_plugin(a,filename,31,title,31,version,0,author,0,status,1)
if (dontPause(a)||status[0]!='r') continue
pause("ac",filename)
++count
console_print(id,"Pausing %s (file ^"%s^")",title,filename)
}
console_print(id,"Paused %d plugins",count)
}
unpauseALL(id){
if (g_dontPauseNum != g_pluginListNum) chkStatus()
new filename[32],title[32],version[2],author[2],status[2]
new count = 0, imax = get_pluginsnum()
for (new a=0;a<imax;++a){
get_plugin(a,filename,31,title,31,version,0,author,0,status,1)
if (dontPause(a)||status[0]!='p') continue
unpause("ac",filename)
++count
console_print(id,"Unpausing %s (file ^"%s^")",title,filename)
}
console_print(id,"Unpaused %d plugins",count)
}
#if defined DIRECT_ONOFF
public cmdOFF(id,level,cid){
if (cmd_access(id,level,cid,1))
pasueALL(id)
return PLUGIN_HANDLED
}
public cmdON(id,level,cid){
if (cmd_access(id,level,cid,1))
unpauseALL(id)
return PLUGIN_HANDLED
}
#endif
findPlugin(argument[32],&len){
new plugin[32],title[32],version[2],author[2],status[2]
new inum = get_pluginsnum()
for(new a = 0; a < inum; ++a){
get_plugin(a,plugin,31,title,31,version,0,author,0,status,1)
if ( equali(plugin,argument,len) && (status[0]=='r'||status[0]=='p') ){
len = copy(argument,31,plugin)
return a
}
}
return -1
}
public cmdPause(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new cmds[32]
read_argv(1,cmds,31)
if ( equal(cmds, "off" ) ){
pasueALL(id)
}
else if ( equal(cmds, "on" ) ){
unpauseALL(id)
}
else if ( equal(cmds, "save" ) ){
if (saveSettings(g_fileToSave)){
g_Modified = false
console_print(id,"Configuration saved successfully")
}
else
console_print(id,"Configuration saving failed!!!")
}
else if ( equal(cmds, "clear" ) ) {
if (file_exists(g_fileToSave)){
delete_file(g_fileToSave)
console_print(id,"Configuration file cleared")
}
else
console_print(id,"Configuration was already cleared!")
}
else if ( equal(cmds, "pause" ) ) {
new arg[32], len, a
if ( (len = read_argv(2,arg,31)) != 0 ){
if ( (a = findPlugin(arg,len)) != -1){
if (pause("ac",arg)) g_pluginStatus[a] = PLG_OFF
console_print(id,"Plugin matching ^"%s^" paused",arg)
}
}
if (!len || a==-1) console_print(id,"Couldn't find plugin matching ^"%s^"",arg)
}
else if ( equal(cmds, "unpause" ) ) {
new arg[32], len, a
if ( (len = read_argv(2,arg,31)) != 0 ){
if ( (a = findPlugin(arg,len)) != -1){
if (unpause("ac",arg)) g_pluginStatus[a] = PLG_ON
console_print(id,"Plugin matching ^"%s^" unpaused",arg)
}
}
if (!len || a==-1) console_print(id,"Couldn't find plugin matching ^"%s^"",arg)
}
else if ( equal(cmds, "stop" ) ) {
new arg[32], len, a
if ( (len = read_argv(2,arg,31)) != 0 ){
if ( (a = findPlugin(arg,len)) != -1){
pause("ac",arg)
g_pluginStatus[a] = PLG_STOPPED
g_Modified = true
console_print(id,"Plugin matching ^"%s^" stopped",arg)
}
}
if (!len || a==-1) console_print(id,"Couldn't find plugin matching ^"%s^"",arg)
}
else if ( equal(cmds, "list" ) ) {
new plugin[32],title[32],version[16],author[32],status[16]
new inum = get_pluginsnum()
console_print(id, "Currently loaded plugins:")
console_print(id, " name version author file status")
new running = 0, plugins = 0
for(new a = 0; a < inum; ++a){
plugins++
get_plugin(a,plugin,31,title,31,version,15,author,31,status,15)
if (status[0] == 'r') running++
console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s",plugins,
title,version,author,plugin, (g_pluginStatus[a] == PLG_STOPPED) ? "stopped" : status )
}
console_print(id, "%d plugins, %d running",plugins,running)
}
else if ( equal(cmds, "add" ) && read_argc() > 2 ) {
if ( g_pluginListNum < MAX_PLGDATA )
read_argv(2,g_pluginList[g_pluginListNum++],31)
else
console_print(id, "Can't add more plugins to the unpauseable list, limit reached!")
}
else {
console_print(id,"Usage: amx_plugin <command> [name]")
console_print(id,"Commands:")
console_print(id,"^toff - pause all plugins not in the list")
console_print(id,"^ton - unpause all plugins")
console_print(id,"^tstop <file> - stop plugin")
console_print(id,"^tpause <file> - pause plugin")
console_print(id,"^tunpause <file> - unpause plugin")
console_print(id,"^tsave - save list of stopped plugins")
console_print(id,"^tclear - clear list of stopped plugins")
console_print(id,"^tlist - list plugins")
console_print(id,"^tadd <title> - add plugin to the unpauseable plugins list")
}
return PLUGIN_HANDLED
}
chkStatus(){
new filename[32],title[32],version[2],author[2],status[2]
new imax = get_pluginsnum()
for (new a=0;a<imax;++a){
get_plugin(a,filename,31,title,31,version,0,author,0,status,1)
if (status[0]=='p'){
if (g_pluginStatus[a]!=PLG_STOPPED)g_pluginStatus[a] = PLG_OFF
}
else if (status[0]=='r')
g_pluginStatus[a] = PLG_ON
else
g_pluginStatus[a] = PLG_ERROR
if (dontPausePre(title))
g_dontPause[g_dontPauseNum++] = a
}
}
bool:dontPause(myid) {
for(new a=0;a<g_dontPauseNum;++a)
if (g_dontPause[a]==myid)
return true
return false
}
bool:dontPausePre(name[]) {
for(new a=0;a<g_pluginListNum;++a)
if (equali(g_pluginList[a],name))
return true
return false
}
saveSettings(filename[]){
if (file_exists(filename))
delete_file(filename)
new text[256], plugin[32],title[32],version[2],author[2],status[2]
new inum = get_pluginsnum()
if (!write_file(filename,";Generated by Pause Plugins Plugin. Do not modify!^n;Filename Description"))
return 0
for(new a = 0; a < inum; ++a){
if (g_pluginStatus[a]==PLG_STOPPED){
get_plugin(a,plugin,31,title,31,version,0,author,0,status,1)
format(text,255,"%s ;%s",plugin,title)
write_file(filename,text)
}
}
return 1
}
loadSettings(filename[]){
if (!file_exists(filename)) return 0
new text[256], len, pos = 0
while (read_file(filename,pos++,text,255,len)){
if ( text[0] == ';' ) continue // line is a comment
parse(text,g_pluginList[g_pluginListNum++],31)
}
new plugin[32],title[32],version[2],author[2],status[2]
new inum = get_pluginsnum()
for(new a = 0; a < inum; ++a){
get_plugin(a,plugin,31,title,31,version,0,author,0,status,1)
if (!dontPausePre(plugin)) continue
pause("ac",plugin)
g_pluginStatus[a] = PLG_STOPPED
}
g_pluginListNum = 0
return 1
}

613
plugins/restmenu.sma Executable file
View File

@ -0,0 +1,613 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Commands:
* amx_restmenu - displays restriction menu
* amx_restrict - displays help for restrict weapons command
*/
// Uncomment if you want to have seperate settings for each map
//#define MAPSETTINGS
#include <amxmod>
#include <amxmisc>
#if !defined NO_STEAM
#define MAXMENUPOS 34
#else
#define MAXMENUPOS 31
#endif
new g_Position[33]
new g_allowCheck[33]
new g_Modified
new g_blockPos[112]
new g_saveFile[64]
new g_Restricted[] = "* This item is restricted *"
new g_menusNames[7][] = {
"pistol",
"shotgun",
"sub",
"rifle",
"machine",
"equip",
"ammo"
}
new g_MenuTitle[7][] = {
"Handguns",
"Shotguns",
"Sub-Machine Guns",
"Assault & Sniper Rifles",
"Machine Guns",
"Equipment",
"Ammunition"
}
new g_menusSets[7][2] = {
#if !defined NO_STEAM
{0,6},{6,8},{8,13},{13,23},{23,24},{24,32},{32,34}
#else
{0,6},{6,8},{8,13},{13,21},{21,22},{22,29},{29,31}
#endif
}
#if !defined NO_STEAM
new g_AliasBlockNum
new g_AliasBlock[MAXMENUPOS]
#endif
// First position is a position of menu (0 for ammo, 1 for pistols, 6 for equipment etc.)
// Second is a key for TERRORIST (all is key are minus one, 1 is 0, 2 is 1 etc.)
// Third is a key for CT
// Position with -1 doesn't exist
new g_Keys[MAXMENUPOS][3] = {
#if !defined NO_STEAM
{1,1,1}, // H&K USP .45 Tactical
{1,0,0}, // Glock18 Select Fire
{1,3,3}, // Desert Eagle .50AE
{1,2,2}, // SIG P228
{1,4,-1}, // Dual Beretta 96G Elite
{1,-1,4}, // FN Five-Seven
{2,0,0}, // Benelli M3 Super90
{2,1,1}, // Benelli XM1014
{3,1,1}, // H&K MP5-Navy
{3,-1,0}, // Steyr Tactical Machine Pistol
{3,3,3}, // FN P90
{3,0,-1}, // Ingram MAC-10
{3,2,2}, // H&K UMP45
{4,1,-1}, // AK-47
{4,0,-1}, // Gali
{4,-1,0}, // Famas
{4,3,-1}, // Sig SG-552 Commando
{4,-1,2}, // Colt M4A1 Carbine
{4,-1,3}, // Steyr Aug
{4,2,1}, // Steyr Scout
{4,4,5}, // AI Arctic Warfare/Magnum
{4,5,-1}, // H&K G3/SG-1 Sniper Rifle
{4,-1,4}, // Sig SG-550 Sniper
{5,0,0}, // FN M249 Para
{6,0,0}, // Kevlar Vest
{6,1,1}, // Kevlar Vest & Helmet
{6,2,2}, // Flashbang
{6,3,3}, // HE Grenade
{6,4,4}, // Smoke Grenade
{6,-1,6}, // Defuse Kit
{6,5,5}, // NightVision Goggles
{6,-1,7}, // Tactical Shield
{0,5,5}, // Primary weapon ammo
{0,6,6} // Secondary weapon ammo
#else
{1,0,0}, // H&K USP .45 Tactical
{1,1,1}, // Glock18 Select Fire
{1,2,2}, // Desert Eagle .50AE
{1,3,3}, // SIG P228
{1,4,-1}, // Dual Beretta 96G Elite
{1,-1,5}, // FN Five-Seven
{2,0,0}, // Benelli M3 Super90
{2,1,1}, // Benelli XM1014
{3,0,0}, // H&K MP5-Navy
{3,-1,1}, // Steyr Tactical Machine Pistol
{3,2,2}, // FN P90
{3,3,-1}, // Ingram MAC-10
{3,4,4}, // H&K UMP45
{4,0,-1}, // AK-47
{4,1,-1}, // Sig SG-552 Commando
{4,-1,2}, // Colt M4A1 Carbine
{4,-1,3}, // Steyr Aug
{4,4,4}, // Steyr Scout
{4,5,5}, // AI Arctic Warfare/Magnum
{4,6,-1}, // H&K G3/SG-1 Sniper Rifle
{4,-1,7}, // Sig SG-550 Sniper
{5,0,0}, // FN M249 Para
{6,0,0}, // Kevlar Vest
{6,1,1}, // Kevlar Vest & Helmet
{6,2,2}, // Flashbang
{6,3,3}, // HE Grenade
{6,4,4}, // Smoke Grenade
{6,-1,5}, // Defuse Kit
{6,6,6}, // NightVision Goggles
{0,5,5}, // Primary weapon ammo
{0,6,6} // Secondary weapon ammo
#endif
}
new g_WeaponNames[MAXMENUPOS][] = {
"H&K USP .45 Tactical",
"Glock18 Select Fire",
"Desert Eagle .50AE",
"SIG P228",
"Dual Beretta 96G Elite",
"FN Five-Seven",
"Benelli M3 Super90",
"Benelli XM1014",
"H&K MP5-Navy",
"Steyr Tactical Machine Pistol",
"FN P90",
"Ingram MAC-10",
"H&K UMP45",
"AK-47",
#if !defined NO_STEAM
"Gali",
"Famas",
#endif
"Sig SG-552 Commando",
"Colt M4A1 Carbine",
"Steyr Aug",
"Steyr Scout",
"AI Arctic Warfare/Magnum",
"H&K G3/SG-1 Sniper Rifle",
"Sig SG-550 Sniper",
"FN M249 Para",
"Kevlar Vest",
"Kevlar Vest & Helmet",
"Flashbang",
"HE Grenade",
"Smoke Grenade",
"Defuse Kit",
"NightVision Goggles",
#if !defined NO_STEAM
"Tactical Shield",
#endif
"Primary weapon ammo",
"Secondary weapon ammo"
}
new g_MenuItem[MAXMENUPOS][] = {
"\yHandguns^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",
"\yShotguns^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",
"\ySub-Machine Guns^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",
"\yAssault Rifles^n\w^n%d. %s\y\R%s^n\w",
#if !defined NO_STEAM
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
#endif
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",
"\ySniper Rifles^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",
"\yMachine Guns^n\w^n%d. %s\y\R%s^n\w^n",
"\yEquipment^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w",
#if !defined NO_STEAM
"%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w^n",
#else
"%d. %s\y\R%s^n\w^n",
#endif
"\yAmmunition^n\w^n%d. %s\y\R%s^n\w",
"%d. %s\y\R%s^n\w"
}
new g_Aliases[MAXMENUPOS][] = {
"usp",//Pistols
"glock",
"deagle",
"p228",
"elites",
"fn57",
"m3",//Shotguns
"xm1014",
"mp5",//SMG
"tmp",
"p90",
"mac10",
"ump45",
"ak47",//Rifles
#if !defined NO_STEAM
"galil",
"famas",
#endif
"sg552",
"m4a1",
"aug",
"scout",
"awp",
"g3sg1",
"sg550",
"m249", //Machine Gun
"vest",//Equipment
"vesthelm",
"flash",
"hegren",
"sgren",
"defuser",
"nvgs",
#if !defined NO_STEAM
"shield",
#endif
"primammo",//Ammo
"secammo"
}
#if !defined NO_STEAM
new g_moreAliases[MAXMENUPOS][] = {
"km45",//Pistols
"9x19mm",
"nighthawk",
"228compact",
"elites",
"fiveseven",
"12gauge",//Shotguns
"autoshotgun",
"smg",//SMG
"mp",
"c90",
"mac10",
"ump45",
"cv47",//Rifles
//#if !defined NO_STEAM
"defender",
"clarion",
//#endif
"krieg552",
"m4a1",
"bullup",
"scout",
"magnum",
"d3au1",
"krieg550",
"m249", //Machine Gun
"vest",//Equipment
"vesthelm",
"flash",
"hegren",
"sgren",
"defuser",
"nvgs",
//#if !defined NO_STEAM
"shield",
//#endif
"primammo",//Ammo
"secammo"
}
#endif
public plugin_init(){
register_plugin("Restrict Weapons","0.9.6","default")
register_clcmd("buyammo1","ammoRest1")
register_clcmd("buyammo2","ammoRest2")
register_clcmd("amx_restmenu","cmdMenu",ADMIN_CFG,"- displays weapons restriction menu")
register_menucmd(register_menuid("#Buy", 1 ),511,"menuBuy")
register_menucmd(register_menuid("\yRestrict Weapons"),1023,"actionMenu")
register_menucmd(register_menuid("BuyPistol", 1 ),511,"menuPistol")
register_menucmd(register_menuid("BuyShotgun", 1 ),511,"menuShotgun")
register_menucmd(register_menuid("BuySub", 1 ),511,"menuSub")
register_menucmd(register_menuid("BuyRifle", 1 ),511,"menuRifle")
register_menucmd(register_menuid("BuyMachine", 1 ),511,"menuMachine")
register_menucmd(register_menuid("BuyItem", 1 ),511,"menuItem")
register_menucmd(-28,511,"menuBuy" )
register_menucmd(-29,511,"menuPistol" )
register_menucmd(-30,511,"menuShotgun")
register_menucmd(-32,511,"menuSub")
register_menucmd(-31,511,"menuRifle")
register_menucmd(-33,511,"menuMachine")
register_menucmd(-34,511,"menuItem")
register_concmd("amx_restrict","cmdRest",ADMIN_CFG,"- displays help for weapons restriction")
register_event("StatusIcon","buyZone","b","2&buy")
#if defined MAPSETTINGS
new mapname[32]
get_mapname(mapname,31)
build_path( g_saveFile , 63 , "$basedir/weaprest_%s.ini" ,mapname )
#else
build_path( g_saveFile , 63 , "$basedir/weaprest.ini" )
#endif
loadSettings(g_saveFile)
}
public buyZone(id)
g_allowCheck[ id ] = read_data(1)
setWeapon( a , action ){
new b, m = g_Keys[a][0] * 8
if (g_Keys[a][1] != -1) {
b = m + g_Keys[a][1]
if ( action == 2 )
g_blockPos[ b ] = 1 - g_blockPos[ b ]
else
g_blockPos[ b ] = action
}
if (g_Keys[a][2] != -1) {
b = m + g_Keys[a][2] + 56
if ( action == 2 )
g_blockPos[ b ] = 1 - g_blockPos[ b ]
else
g_blockPos[ b ] = action
}
#if !defined NO_STEAM
for(new i = 0; i < g_AliasBlockNum; ++i)
if ( g_AliasBlock[ i ] == a ){
if ( !action || action == 2 ) {
--g_AliasBlockNum
for(new j = i; j < g_AliasBlockNum; ++j )
g_AliasBlock[ j ] = g_AliasBlock[ j + 1 ]
}
return
}
if ( action && g_AliasBlockNum < MAXMENUPOS )
g_AliasBlock[ g_AliasBlockNum++ ] = a
#endif
}
findMenuId( name[] ){
for(new i = 0; i < 7 ; ++i)
if( equal( name , g_menusNames[i] ) )
return i
return -1
}
findAliasId( name[] ){
for(new i = 0; i < MAXMENUPOS ; ++i)
if( equal( name , g_Aliases[i] ) )
return i
return -1
}
switchCommand( id, action ){
new c = read_argc()
if ( c < 3 ){
for(new a = 0; a < MAXMENUPOS; ++a)
setWeapon( a , action )
console_print( id , "Equipment and weapons have been %srestricted" , action ? "" : "un" )
g_Modified = true
}
else {
new arg[32], a
new bool:found = false
for(new b = 2; b < c; ++b){
read_argv(b,arg,31)
if ( (a = findMenuId( arg )) != -1 ){
c = g_menusSets[a][1]
for(new i = g_menusSets[a][0]; i < c; ++i)
setWeapon( i , action )
console_print( id , "%s %s been %srestricted" , g_MenuTitle[a], (a<5) ? "have" : "has" , action ? "" : "un" )
g_Modified = found = true
}
else if ( (a = findAliasId( arg )) != -1 ){
g_Modified = found = true
setWeapon( a , action )
console_print( id , "%s has been %srestricted" , g_WeaponNames[a], action ? "" : "un" )
}
}
if ( !found )
console_print( id , "Couldn't find such equipment or weapon" )
}
}
positionBlocked( a ) {
new m = g_Keys[a][0] * 8
new d = ( g_Keys[a][1]==-1) ? 0 : g_blockPos[ m + g_Keys[a][1] ]
d += ( g_Keys[a][2]==-1) ? 0 : g_blockPos[ m + g_Keys[a][2] + 56 ]
return d
}
public cmdRest(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new cmd[8]
read_argv(1,cmd,7)
if ( equali( "on" , cmd ) )
switchCommand( id, 1 )
else if ( equali( "off" , cmd ) )
switchCommand( id, 0 )
else if ( equali( "list" , cmd ) ) {
new arg1[8]
new start = read_argv(2,arg1,7) ? strtonum(arg1) : 1
if (--start < 0) start = 0
if (start >= MAXMENUPOS) start = MAXMENUPOS - 1
new end = start + 10
if (end > MAXMENUPOS) end = MAXMENUPOS
console_print(id, "^n----- Weapons Restriction: -----")
console_print(id, " %-32.31s %-10.9s %-9.8s","name","value","status")
if ( start != -1 ) {
for(new a = start; a < end; ++a){
console_print(id, "%3d: %-32.31s %-10.9s %-9.8s",a + 1,
g_WeaponNames[a], g_Aliases[a], positionBlocked(a) ? "ON" : "OFF")
}
}
console_print(id,"----- Entries %i - %i of %i -----",start+1,end,MAXMENUPOS)
if (end < MAXMENUPOS)
console_print(id,"----- Use 'amx_restrict list %i' for more -----",end+1)
else
console_print(id,"----- Use 'amx_restrict list 1' for begin -----")
}
else if ( equali( "save" , cmd ) ) {
if ( saveSettings( g_saveFile ) ){
console_print( id , "Configuration has been saved (file ^"%s^")" , g_saveFile )
g_Modified = false
}
else console_print( id , "Couldn't save configuration (file ^"%s^")" , g_saveFile )
}
else if ( equali( "load" , cmd ) ) {
for(new a = 0; a < MAXMENUPOS; ++a)
setWeapon( a , 0 ) // Clear current settings
new arg1[64]
if ( read_argv(2, arg1 , 63 ) ) build_path( arg1 , 63, "$basedir/%s", arg1 )
else copy( arg1, 63, g_saveFile )
if ( loadSettings( arg1 ) ){
console_print( id , "Configuration has been loaded (file ^"%s^")" , arg1 )
g_Modified = true
}
else console_print( id , "Couldn't load configuration (file ^"%s^")" , arg1 )
}
else {
console_print(id,"Usage: amx_restrict <command> [value]")
console_print(id,"Commands:")
console_print(id,"^ton - set restriction on whole equipment")
console_print(id,"^toff - remove restriction from whole equipment")
console_print(id,"^ton <value> [...] - set specified restriction")
console_print(id,"^toff <value> [...] - remove specified restriction")
console_print(id,"^tlist - display list of available equipment and weapons")
console_print(id,"^tsave - save restriction")
console_print(id,"^tload [file] - load restriction [from a file]")
console_print(id,"Available values to restrict are:^nammo, equip, pistol, shotgun, sub, rifle, machine")
console_print(id,"Type 'amx_restrict list' for more specified values")
}
return PLUGIN_HANDLED
}
displayMenu(id,pos){
if (pos < 0) return
new menubody[512], start = pos * 7
if (start >= MAXMENUPOS) start = pos = g_Position[id] = 0
new len = format(menubody,511,"\yRestrict Weapons\R%d/5^n\w^n",pos+1)
new end = start + 7, keys = (1<<9)|(1<<7), k = 0
if (end > MAXMENUPOS) end = MAXMENUPOS
for(new a = start; a < end; ++a){
keys |= (1<<k)
len += format(menubody[len],511-len,g_MenuItem[a],++k,g_WeaponNames[a],
positionBlocked(a) ? "ON" : "OFF" )
}
len += format(menubody[len],511-len,"^n8. Save settings \y\R%s^n\w",g_Modified?"*":"")
if (end != MAXMENUPOS){
format(menubody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
keys |= (1<<8)
}
else format(menubody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
show_menu(id,keys,menubody)
}
public actionMenu(id,key){
switch(key){
case 7: {
if (saveSettings(g_saveFile)){
g_Modified = false
client_print(id,print_chat,"* Configuration saved successfully")
}
else client_print(id,print_chat,"* Configuration saving failed!!!")
displayMenu(id,g_Position[id])
}
case 8: displayMenu(id,++g_Position[id])
case 9: displayMenu(id,--g_Position[id])
default: {
setWeapon( g_Position[id] * 7 + key , 2 )
g_Modified = true
displayMenu(id,g_Position[id])
}
}
return PLUGIN_HANDLED
}
#if !defined NO_STEAM
public client_command( id ){
if ( g_AliasBlockNum && g_allowCheck[ id ] ) {
new arg[16]
read_argv( 0, arg , 15 )
new a = 0
do {
if ( equal( g_Aliases[g_AliasBlock[ a ]] , arg ) || equal( g_moreAliases[g_AliasBlock[ a ]] , arg ) ) {
client_print(id,print_center,g_Restricted )
return PLUGIN_HANDLED
}
} while( ++a < g_AliasBlockNum )
}
return PLUGIN_CONTINUE
}
#endif
public cmdMenu(id,level,cid){
if (cmd_access(id,level,cid,1))
displayMenu(id, g_Position[id] = 0 )
return PLUGIN_HANDLED
}
checkRest(id,menu,key){
if ( g_blockPos[ (menu * 8 + key) + (get_user_team(id) - 1) * 56 ] ){
engclient_cmd(id,"menuselect","10")
//client_cmd(id,"slot10")
client_print(id,print_center, g_Restricted )
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public ammoRest1(id) return checkRest(id,0,5)
public ammoRest2(id) return checkRest(id,0,6)
public menuBuy(id,key) return checkRest(id,0,key)
public menuPistol(id,key) return checkRest(id,1,key)
public menuShotgun(id,key) return checkRest(id,2,key)
public menuSub(id,key) return checkRest(id,3,key)
public menuRifle(id,key) return checkRest(id,4,key)
public menuMachine(id,key) return checkRest(id,5,key)
public menuItem(id,key) return checkRest(id,6,key)
saveSettings(filename[]){
if (file_exists(filename))
delete_file(filename)
if (!write_file(filename,"; Generated by Restrict Weapons Plugin. Do not modify!^n; value name"))
return 0
new text[64]
for(new a = 0; a < MAXMENUPOS; ++a){
if ( positionBlocked( a ) ) {
format(text,63,"%-16.15s ; %s", g_Aliases[a] , g_WeaponNames[a])
write_file(filename,text)
}
}
return 1
}
loadSettings(filename[]){
if (!file_exists(filename)) return 0
new text[16]
new a, pos = 0
while (read_file(filename,pos++,text,15, a )){
if ( text[0] == ';' || !a ) continue // line is a comment
parse( text, text , 15 )
if ( (a = findAliasId( text )) != -1 )
setWeapon( a , 1 )
}
return 1
}

BIN
plugins/sc Executable file

Binary file not shown.

BIN
plugins/sc.exe Executable file

Binary file not shown.

84
plugins/scrollmsg.sma Executable file
View File

@ -0,0 +1,84 @@
/* AMX Mod script.
*
* (c) 2003, OLO
* This file is provided as is (no warranties).
*
* Server command:
* amx_scrollmsg <msg> <freq. in sec.>
*/
#include <amxmod>
#include <amxmisc>
#define SPEED 0.3
new g_startPos
new g_endPos
new g_scrollMsg[384]
new g_displayMsg[384]
new Float:g_xPos
new g_Length
new g_Frequency
public plugin_init(){
register_plugin("Scrolling Message","0.9","default")
register_srvcmd("amx_scrollmsg","setMessage")
}
public showMsg(){
new a = g_startPos, i = 0
while( a < g_endPos )
g_displayMsg[i++] = g_scrollMsg[a++]
g_displayMsg[i] = 0
if (g_endPos < g_Length)
g_endPos++
if (g_xPos > 0.35)
g_xPos -= 0.0063
else
{
g_startPos++
g_xPos = 0.35
}
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
show_hudmessage(0,g_displayMsg)
}
public msgInit(){
g_endPos = 1
g_startPos = 0
g_xPos = 0.65
set_task( SPEED , "showMsg",123,"",0,"a", g_Length + 48)
client_print(0,print_console,g_scrollMsg)
}
public setMessage(id,level,cid) {
if (!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED
remove_task(123) /* remove current messaging */
read_argv(1,g_scrollMsg,380)
new hostname[64]
get_cvar_string("hostname",hostname,63)
replace(g_scrollMsg,380,"%hostname%",hostname)
g_Length = strlen(g_scrollMsg)
new mytime[32]
read_argv(2,mytime,31)
g_Frequency = strtonum(mytime)
if (g_Frequency > 0) {
new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
if (g_Frequency < minimal) {
console_print(id,"Minimal frequency for this message is %d seconds",minimal)
g_Frequency = minimal
}
console_print(id,"Scrolling message displaying frequency: %d:%02d minutes",
g_Frequency/60,g_Frequency%60)
set_task(float(g_Frequency),"msgInit",123,"",0,"b")
}
else
console_print(id,"Scrolling message disabled")
return PLUGIN_HANDLED
}

Some files were not shown because too many files have changed in this diff Show More