more cleaned-up code

This commit is contained in:
Borja Ferrer 2005-09-10 20:09:14 +00:00
parent 612a86dbef
commit 76760b221d
20 changed files with 1537 additions and 1155 deletions

View File

@ -111,8 +111,7 @@ CmdMngr::Command* CmdMngr::getCmd(long int id, int type, int access)
while (buf_cmdptr)
{
if ((*buf_cmdptr).gotAccess(access) && (*buf_cmdptr).getPlugin()->isExecutable((*buf_cmdptr).getFunction())
&& (*buf_cmdptr).isViewable())
if ((*buf_cmdptr).gotAccess(access) && (*buf_cmdptr).getPlugin()->isExecutable((*buf_cmdptr).getFunction()) && (*buf_cmdptr).isViewable())
{
if (id-- == 0)
return &(*buf_cmdptr);

View File

@ -556,10 +556,12 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
} else {
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
}
} else if (*pAmxLangName == LANG_SERVER) // LANG_SERVER
}
else if (*pAmxLangName == LANG_SERVER) // LANG_SERVER
{
cpLangName = g_vault.get("server_language");
} else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) // Direct Client Id
}
else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) // Direct Client Id
{
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
{
@ -629,7 +631,6 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
cell *tmpCell = get_amxaddr(amx, params[parm++]);
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
*tmpPtr++ = static_cast<char>(*tmpCell++);
*tmpPtr = 0;
_snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString);
ZEROTERM(outbuf);
@ -815,10 +816,12 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
} else {
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
}
} else if (pAmxLangName == (const char *)LANG_SERVER) // LANG_SERVER
}
else if (pAmxLangName == (const char *)LANG_SERVER) // LANG_SERVER
{
cpLangName = g_vault.get("server_language");
} else if (pAmxLangName >= (const char *)1 && pAmxLangName <= (const char *)32) // Direct Client Id
}
else if (pAmxLangName >= (const char *)1 && pAmxLangName <= (const char *)32) // Direct Client Id
{
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
{
@ -1126,6 +1129,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
} // if !multiline
} //if - main
}
// merge last section
if (!Defq.empty())
{
@ -1170,6 +1174,7 @@ const char *CLangMngr::GetDef(const char *langName, const char *key)
CLang *lang = GetLangR(langName);
if (lang)
return lang->GetDef(key);
return "ML_NOTFOUND(LANG)";
}

View File

@ -35,7 +35,8 @@
// *****************************************************
// class MenuMngr
// *****************************************************
MenuMngr::MenuCommand::MenuCommand( CPluginMngr::CPlugin *a, int mi, int k, int f ) {
MenuMngr::MenuCommand::MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f)
{
plugin = a;
keys = k;
menuid = mi;
@ -50,10 +51,12 @@ MenuMngr::~MenuMngr()
int MenuMngr::findMenuId(const char* name, AMX* amx)
{
for( MenuIdEle* b = headid; b ; b = b->next) {
for (MenuIdEle* b = headid; b; b = b->next)
{
if ((!amx || !b->amx || amx == b->amx) && strstr(name,b->name.c_str()))
return b->id;
}
return 0;
}
@ -62,8 +65,10 @@ int MenuMngr::registerMenuId(const char* n, AMX* a )
int id = findMenuId(n, a);
if (id) return id;
headid = new MenuIdEle(n, a, headid);
if (!headid)
return 0; // :TODO: Better error report
return headid->id;
}

View File

@ -55,7 +55,8 @@ void CPlayer::Init( edict_t* e , int i )
team.clear();
}
void CPlayer::Disconnect() {
void CPlayer::Disconnect()
{
ingame = false;
initialized = false;
authorized = false;
@ -64,8 +65,10 @@ void CPlayer::Disconnect() {
{
ClientCvarQuery_Info *pQuery = cvarQueryQueue.front();
unregisterSPForward(pQuery->resultFwd);
if (pQuery->params)
delete [] pQuery->params;
delete pQuery;
cvarQueryQueue.pop();
}
@ -73,11 +76,14 @@ void CPlayer::Disconnect() {
bot = 0;
}
void CPlayer::PutInServer() {
void CPlayer::PutInServer()
{
playtime = gpGlobals->time;
ingame = true;
}
bool CPlayer::Connect(const char* connectname,const char* ipaddress) {
bool CPlayer::Connect(const char* connectname, const char* ipaddress)
{
name.assign(connectname);
ip.assign(ipaddress);
time = gpGlobals->time;
@ -90,18 +96,16 @@ bool CPlayer::Connect(const char* connectname,const char* ipaddress) {
const char* authid = GETPLAYERAUTHID(pEdict);
if ( (authid == 0) || (*authid == 0)
|| (strcmp( authid , "STEAM_ID_PENDING") == 0) )
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;
@ -118,30 +122,33 @@ 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 ) {
while (*a)
{
if ((*a)->time > gpGlobals->time)
{
if ((*a)->grenade == enemy)
{
found = true;
(*p) = (*a)->player;
type = (*a)->type;
}
}
else {
} else {
Obj* b = (*a)->next;
delete *a;
*a = b;
continue;
}
a = &(*a)->next;
}
return found;
}
void Grenades::clear()
{
while(head){
while (head)
{
Obj* a = head->next;
delete head;
head = a;
@ -151,7 +158,9 @@ void Grenades::clear()
// *****************************************************
// class XVars
// *****************************************************
void XVars::clear() {
void XVars::clear()
{
delete[] head;
head = 0;
num = 0;
@ -160,7 +169,8 @@ void XVars::clear() {
int XVars::put(AMX* p, cell* v)
{
for(int a = 0; a < num; ++a) {
for (int a = 0; a < num; ++a)
{
if ((head[a].amx == p) && (head[a].value == v))
return a;
}
@ -176,23 +186,31 @@ int XVars::put( AMX* p, cell* v )
int XVars::realloc_array(int nsize)
{
XVarEle* me = new XVarEle[nsize];
if ( me ){
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 ) {
TeamIds::~TeamIds()
{
while (head)
{
TeamEle* a = head->next;
delete head;
head = a;
@ -202,16 +220,22 @@ TeamIds::~TeamIds() {
void TeamIds::registerTeam(const char* n, int s)
{
TeamEle** a = &head;
while( *a ){
if ( strcmp((*a)->name.c_str(),n) == 0 ){
if (s != -1){
while (*a)
{
if (strcmp((*a)->name.c_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);
@ -220,24 +244,29 @@ void TeamIds::registerTeam( const char* n ,int s )
int TeamIds::findTeamId(const char* n)
{
TeamEle* a = head;
while( a ){
while (a)
{
if (!stricmp(a->name.c_str(), n))
return a->id;
a = a->next;
}
return -1;
}
int TeamIds::findTeamIdCase(const char* n)
{
TeamEle* a = head;
while( a ){
while (a)
{
if (!strcmp(a->name.c_str(), n))
return a->id;
a = a->next;
}
return -1;
}
char TeamIds::TeamEle::uid = 0;

View File

@ -67,6 +67,7 @@ void CModule::clear(bool clearFilename)
m_Metamod = false;
m_Handle = NULL;
m_Status = MODULE_NONE;
if (clearFilename)
m_Filename.assign("unknown");
@ -114,6 +115,7 @@ bool CModule::attachModule()
if (!AttachFunc_New)
return false;
g_ModuleCallReason = ModuleCall_Attach;
g_CurrentlyCalledModule = this;
int retVal = (*AttachFunc_New)(Module_ReqFnptr);
@ -163,6 +165,7 @@ bool CModule::queryModule()
// Try new interface first
QUERYMOD_NEW queryFunc_New = (QUERYMOD_NEW)DLPROC(m_Handle, "AMXX_Query");
if (queryFunc_New)
{
m_Amxx = true;
@ -172,6 +175,7 @@ bool CModule::queryModule()
int retVal = (*queryFunc_New)(&ifVers, &m_InfoNew);
g_CurrentlyCalledModule = NULL;
g_ModuleCallReason = ModuleCall_NotCalled;
switch (retVal)
{
case AMXX_PARAM:
@ -201,9 +205,7 @@ bool CModule::queryModule()
m_Status = MODULE_QUERY;
return true;
}
else
{
} else {
m_Status = MODULE_NOQUERY;
m_Amxx = false;
return false;
@ -218,6 +220,7 @@ bool CModule::detachModule()
if (m_Amxx)
{
DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach");
if (detachFunc_New)
{
g_ModuleCallReason = ModuleCall_Detach;
@ -227,14 +230,17 @@ bool CModule::detachModule()
g_ModuleCallReason = ModuleCall_NotCalled;
}
}
#ifndef FAKEMETA
if (IsMetamod())
{
UnloadMetamodPlugin(m_Handle);
}
#endif
DLFREE(m_Handle);
clear();
return true;
}
@ -247,8 +253,10 @@ void CModule::CallPluginsLoaded()
return;
PLUGINSLOADED_NEW func = (PLUGINSLOADED_NEW)DLPROC(m_Handle, "AMXX_PluginsLoaded");
if (!func)
return;
func();
}
@ -270,5 +278,6 @@ const char* CModule::getStatus() const
case MODULE_NOT64BIT: return "not 64bit";
default: break;
}
return "unknown";
}

View File

@ -33,6 +33,7 @@
#include "CTask.h"
/*********************** CTask ***********************/
int CTaskMngr::CTask::getTaskId() const
{
return m_iId;
@ -57,10 +58,13 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
{
m_bLoop = true;
m_iRepeat = -1;
} else if (iFlags & 1) {
}
else if (iFlags & 1)
{
m_bLoop = true;
m_iRepeat = iRepeat;
}
m_bAfterStart = (iFlags & 4) ? true : false;
m_bBeforeEnd = (iFlags & 8) ? true : false;
@ -125,6 +129,7 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
{
bool execute = false;
bool done = false;
if (m_bAfterStart)
{
if (fCurrentTime - fTimeLeft + 1.0f >= m_fBase)
@ -134,7 +139,9 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
{
if (fTimeLimit != 0.0f && (fTimeLeft + fTimeLimit * 60.0f) - fCurrentTime - 1.0f <= m_fBase)
execute = true;
} else if (m_fNextExecTime <= fCurrentTime) {
}
else if (m_fNextExecTime <= fCurrentTime)
{
execute = true;
}
@ -199,6 +206,7 @@ CTaskMngr::CTask::~CTask()
}
/*********************** CTaskMngr ***********************/
CTaskMngr::CTaskMngr()
{
m_pTmr_CurrentTime = NULL;
@ -222,17 +230,18 @@ void CTaskMngr::registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlag
{
// first, search for free tasks
TaskListIter iter = m_Tasks.find(CTaskDescriptor(0, NULL, true));
if (iter)
{
// found: reuse it
iter->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
}
else
{
} else {
// not found: make a new one
CTask *pTmp = new CTask;
if (!pTmp)
return;
pTmp->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
m_Tasks.put(pTmp);
}
@ -243,12 +252,14 @@ int CTaskMngr::removeTasks(int iId, AMX *pAmx)
CTaskDescriptor descriptor(iId, pAmx);
TaskListIter iter = m_Tasks.find(descriptor);
int i = 0;
while (iter)
{
iter->clear();
++i;
iter = m_Tasks.find(++iter, descriptor);
}
return i;
}
@ -257,6 +268,7 @@ int CTaskMngr::changeTasks(int iId, AMX *pAmx, float fNewBase)
CTaskDescriptor descriptor(iId, pAmx);
TaskListIter iter = m_Tasks.find(descriptor);
int i = 0;
while (iter)
{
iter->changeBase(fNewBase);
@ -264,6 +276,7 @@ int CTaskMngr::changeTasks(int iId, AMX *pAmx, float fNewBase)
++i;
iter = m_Tasks.find(++iter, descriptor);
}
return i;
}

View File

@ -39,6 +39,7 @@
// *****************************************************
// class Vault
// *****************************************************
bool Vault::exists(const char* k)
{
if (*k == 0) return false;
@ -65,10 +66,10 @@ void Vault::put( const char* k, const char* v )
}
else
*a = new Obj(k, v);
}
Vault::Obj::Obj( const char* k, const char* v): key(k) , value(v) , next(0) {
Vault::Obj::Obj(const char* k, const char* v): key(k), value(v), next(0)
{
number = atoi(v);
}
@ -136,7 +137,6 @@ void Vault::setSource( const char* n )
path.assign(n);
}
bool Vault::loadVault()
{
if (path.empty()) return false;

View File

@ -105,7 +105,8 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
m_pFile = NULL;
return;
} else if (magic == MAGIC_HEADER2)
}
else if (magic == MAGIC_HEADER2)
{
DATAREAD(&m_Bh.version, sizeof(int16_t), 1);
@ -155,7 +156,8 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
pe = &(m_Bh.plugins[m_Entry]);
m_SectionLength = pe->disksize;
} else if (magic == MAGIC_HEADER)
}
else if (magic == MAGIC_HEADER)
{
// try to find the section
mint8_t numOfPlugins;
@ -274,7 +276,8 @@ size_t CAmxxReader::GetBufferSize()
DATAREAD(&hdr, sizeof(hdr), 1);
fseek(m_pFile, save, SEEK_SET);
return hdr.stp;
} else if (m_AmxxFile)
}
else if (m_AmxxFile)
{
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
@ -321,7 +324,8 @@ CAmxxReader::Error CAmxxReader::GetSection(void *buffer)
m_Status = Err_None;
return m_Status;
} else if (m_AmxxFile)
}
else if (m_AmxxFile)
{
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
char *tempBuffer = new char[m_SectionLength + 1];

View File

@ -58,7 +58,9 @@ WeaponsVault g_weaponsData[MAX_WEAPONS];
void Client_VGUIMenu(void* mValue)
{
if (!mPlayer) return;
switch (mState++){
switch (mState++)
{
case 0:
mPlayer->menu = -(*(int*)mValue);
break;
@ -70,7 +72,9 @@ void Client_VGUIMenu(void* mValue)
void Client_ShowMenu(void* mValue)
{
if (!mPlayer) return;
switch (mState++){
switch (mState++)
{
case 0:
mPlayer->keys = *(int*)mValue;
break;
@ -83,7 +87,9 @@ void Client_TeamInfo(void* mValue)
{
if (mPlayer) return;
static int index;
switch (mState++) {
switch (mState++)
{
case 0:
index = *(int*)mValue;
break;
@ -98,44 +104,57 @@ void Client_TeamInfo(void* mValue)
void Client_TextMsg(void* mValue)
{
if (mPlayer) return;
switch (mState++) {
case 1:{
switch (mState++)
{
case 1:
{
char * msg = (char*)mValue;
if (!msg) break;
if ( !strncmp("#Game_C", msg , 7) ) {
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) ) {
else if (!strncmp("#Game_w", msg, 7))
{
g_game_timeleft = -2;
}
else if ( !strncmp("#game_clan_s", msg , 12) ){
else if (!strncmp("#game_clan_s", msg, 12))
{
g_game_timeleft = -3;
}
break;
}
case 2:{
case 2:
{
char * msg = (char*)mValue;
if (!msg) break;
if (g_game_timeleft == -2 ){
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.0f;
break;
}
case 3:{
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)
@ -144,7 +163,9 @@ void Client_WeaponList(void* mValue)
//static int wpnList2;
static int iSlot;
static const char* wpnName;
switch (mState++) {
switch (mState++)
{
case 0:
wpnName = (char*)mValue;
break;
@ -159,7 +180,6 @@ void Client_WeaponList(void* mValue)
g_weaponsData[iId].iId = iId;
g_weaponsData[iId].ammoSlot = iSlot;
g_weaponsData[iId].fullName.assign(wpnName);
}
}
@ -167,7 +187,9 @@ void Client_CurWeapon(void* mValue)
{
static int iState;
static int iId;
switch (mState++){
switch (mState++)
{
case 0:
iState = *(int*)mValue;
break;
@ -186,9 +208,10 @@ void Client_CurWeapon(void* mValue)
void Client_AmmoX(void* mValue)
{
static int iAmmo;
switch (mState++){
switch (mState++)
{
case 0:
iAmmo = *(int*)mValue;
break;
@ -203,7 +226,9 @@ void Client_AmmoX(void* mValue)
void Client_AmmoPickup(void* mValue)
{
static int iSlot;
switch (mState++){
switch (mState++)
{
case 0:
iSlot = *(int*)mValue;
break;
@ -219,7 +244,9 @@ void Client_ScoreInfo(void* mValue)
{
static int index;
static int deaths;
switch (mState++){
switch (mState++)
{
case 0:
index = *(int*)mValue;
break;
@ -261,24 +288,21 @@ void Client_DeathMsg(void* mValue)
static int victim_id;
static int hs;
switch (mState++){
switch (mState++)
{
case 0:
killer_id = *(int*)mValue;
killer = (killer_id > 0 && killer_id < 33) ?
GET_PLAYER_POINTER_I(killer_id) : 0;
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;
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.assign((char*)mValue);
victim->death_headshot = hs;
@ -313,4 +337,3 @@ void Client_ResetHUD(void* mValue)
}
*/

View File

@ -5,7 +5,7 @@
*
*
* 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
* 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.
*
@ -63,11 +63,13 @@ class AutoFilePtr
public:
AutoFilePtr(FILE *fp) : m_FP(fp)
{ }
~AutoFilePtr()
{
if (m_FP)
fclose(m_FP);
}
operator FILE* ()
{
return m_FP;
@ -82,18 +84,23 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
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 ) {
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
} else
a = 0;
closedir (dp);
return a;
#else
int tmp;
char *dirname = build_pathname("%s/*", get_amxstring(amx, params[1], 0, tmp));
@ -101,10 +108,12 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
_finddata_t fd;
intptr_t handle = _findfirst(dirname, &fd);
if (handle < 0)
return 0;
++tmp;
for (int i = 0; i < tmp; ++i)
{
if (_findnext(handle, &fd) < 0)
@ -113,6 +122,7 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
break;
}
}
// current data in fd
cell *length = get_amxaddr(amx, params[5]); // pointer to the outLen parameter
*length = set_amxstring(amx, params[3], fd.name, params[4]); // set output and outLen parameters
@ -127,16 +137,22 @@ 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) {
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){
if (i > iLine)
{
int len = strlen(buffor);
if (buffor[len - 1] == '\n')
buffor[--len] = 0;
@ -146,6 +162,7 @@ static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */
*length = set_amxstring(amx, params[3], buffor, params[4]);
return i;
}
return 0;
}
@ -158,11 +175,14 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
int iLine = params[3];
// apending to the end
if (iLine < 0) {
if ( (pFile = fopen( sFile ,"a")) == NULL ){
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);
@ -170,13 +190,17 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
}
// creating a new file with a line in a middle
if ( (pFile = fopen(sFile,"r")) == NULL ) {
if ( (pFile = fopen(sFile,"w")) == NULL ){
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);
@ -187,21 +211,26 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
FILE* pTemp;
char buffor[2048];
if ( (pTemp = tmpfile()) == NULL ){
if ((pTemp = tmpfile()) == NULL)
{
amx_RaiseError(amx, AMX_ERR_NATIVE);
return 0;
}
for(i=0;;++i){
if ( i == iLine ){
for (i = 0; ; ++i)
{
if (i == iLine)
{
fgets(buffor, 2047, pFile);
fputs(sText, pTemp);
fputc('\n', pTemp);
}
else if ( fgets(buffor,2047,pFile) ){
else if (fgets(buffor, 2047, pFile))
{
fputs(buffor, pTemp);
}
else if ( i < iLine ) {
else if (i < iLine)
{
fputc('\n', pTemp);
}
else break;
@ -211,7 +240,8 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
rewind(pTemp);
// now rewrite because file can be now smaller...
if ( (pFile = fopen(sFile,"w")) == NULL ){
if ((pFile = fopen(sFile, "w")) == NULL)
{
amx_RaiseError(amx, AMX_ERR_NATIVE);
return 0;
}
@ -221,6 +251,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
fclose(pTemp);
fclose(pFile);
return 1;
}
@ -236,6 +267,7 @@ static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
int iLen;
char *sFile = get_amxstring(amx, params[1], 0, iLen);
char *file = build_pathname("%s", sFile);
#if defined WIN32 || defined _WIN32
DWORD attr = GetFileAttributes(file);
if (attr == INVALID_FILE_ATTRIBUTES)
@ -258,6 +290,7 @@ static cell AMX_NATIVE_CALL dir_exists(AMX *amx, cell *params) /* 1 param */
int iLen;
char *sFile = get_amxstring(amx, params[1], 0, iLen);
char *file = build_pathname("%s", sFile);
#if defined WIN32 || defined _WIN32
DWORD attr = GetFileAttributes(file);
if (attr == INVALID_FILE_ATTRIBUTES)
@ -280,6 +313,7 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
int iLen;
char* sFile = get_amxstring(amx, params[1], 0, iLen);
AutoFilePtr fp(fopen(build_pathname("%s", sFile), "r"));
if (fp != NULL)
{
if (params[0] < 2 || params[2] == 0)
@ -291,11 +325,11 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
else if (params[2] == 1)
{
int a = 0,lines = 0;
while (a != EOF)
{
++lines;
while ( (a = fgetc(fp)) != '\n' && a != EOF )
;
while ((a = fgetc(fp)) != '\n' && a != EOF);
}
//int a, b = '\n';
//while( (a = fgetc(fp)) != EOF ){
@ -307,13 +341,16 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
// ++lines;
return lines;
}
else if ( params[2] == 2 ){
else if (params[2] == 2)
{
fseek(fp, -1, SEEK_END);
if (fgetc(fp) == '\n')
return 1;
return 0;
}
}
return -1;
}
@ -327,7 +364,8 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
char *flags = get_amxstring(amx, params[2], 0, len);
FILE *fp = fopen(file, flags);
if (fp == NULL) {
if (fp == NULL)
{
// Failed
return 0;
}
@ -340,6 +378,7 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
break;
}
}
if (j == -1)
{
FileList.push_back(fp);
@ -354,10 +393,13 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return fclose(fp);
} else {
return -1;
@ -367,17 +409,22 @@ static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
char *buffer;
if (fp) {
if (fp)
{
buffer = new char[params[3]]; // SLOW!!! :TODO: Find a better way (auto pointers?)
fread(buffer, sizeof(char), params[3], fp);
set_amxstring(amx, params[2], buffer, params[3]);
delete [] buffer;
return 1;
}
return -1;
}
@ -385,10 +432,13 @@ static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return fgetc(fp);
} else {
return -1;
@ -398,89 +448,111 @@ static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_fwrite(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
char *buf;
int len;
if (fp) {
if (fp)
{
buf = format_amxstring(amx, params, 2, len);
return fwrite(buf, sizeof(char), strlen(buf), fp);
}
return -1;
}
static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (feof(fp)) {
if (fp)
{
if (feof(fp))
{
return 1;
}
return 0;
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return fseek(fp, (long)params[2], params[3]);
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fputc(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return fputc(params[2], fp);
}
return -1;
}
static cell AMX_NATIVE_CALL amx_rewind(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
rewind(fp);
return 1;
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return fflush(fp);
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
@ -488,7 +560,9 @@ static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
char *buf;
int len;
buf = format_amxstring(amx, params, 2, len);
if (fp) {
if (fp)
{
return fscanf(fp, "%s", buf);
}
@ -498,13 +572,16 @@ static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_ftell(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return ftell(fp);
}
return -1;
}
#endif //UNUSED
@ -515,11 +592,14 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
long size;
AutoFilePtr fp(fopen(file, "rb"));
if (fp) {
if (fp)
{
fseek(fp, 0, SEEK_END);
size = ftell(fp);
return size;
}
return -1;
}
@ -527,116 +607,148 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
long t;
if (fp) {
if (fp)
{
fread(&t, sizeof(long), 1, fp);
return t;
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
int t;
if (fp) {
if (fp)
{
fread(&t, sizeof(int), 1, fp);
return t;
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
short t;
if (fp) {
if (fp)
{
fread(&t, sizeof(short), 1, fp);
return t;
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
short size = params[2];
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(short), 1, fp);
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fputl(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
long size = params[2];
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(long), 1, fp);
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
int size = params[2];
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(int), 1, fp);
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
float t;
if (fp) {
if (fp)
{
fread(&t, sizeof(float), 1, fp);
return *(cell*)&t;
}
return -1;
}
static cell AMX_NATIVE_CALL amx_fputf(AMX *amx, cell *params)
{
unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL)
return 0;
FILE *fp = FileList.at(id);
float size = *(float *)((void *)&params[2]);
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(float), 1, fp);
}
return -1;
}
#endif //UNUSED
@ -657,22 +769,28 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
char *dirname = build_pathname("%s\\*", path);
WIN32_FIND_DATA fd;
HANDLE hFile = FindFirstFile(dirname, &fd);
if (hFile == INVALID_HANDLE_VALUE)
return 0;
set_amxstring(amx, params[2], fd.cFileName, params[3]);
return (DWORD)hFile;
#else
char *dirname = build_pathname("%s", path);
DIR *dp = opendir(dirname);
if (!dp)
return NULL;
struct dirent *ep = readdir(dp);
if (!ep)
{
closedir(dp);
return NULL;
}
set_amxstring(amx, params[2], ep->d_name, params[3]);
return (cell)dp;
#endif
}
@ -681,14 +799,18 @@ static cell AMX_NATIVE_CALL amx_close_dir(AMX *amx, cell *params)
{
#if defined WIN32 || defined _WIN32
HANDLE hFile = (HANDLE)((DWORD)params[1]);
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
return 0;
FindClose(hFile);
return 1;
#else
DIR *dp = (DIR *)params[1];
if (!dp)
return 0;
closedir(dp);
return 1;
#endif
@ -698,26 +820,33 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
{
#if defined WIN32 || defined _WIN32
HANDLE hFile = (HANDLE)((DWORD)params[1]);
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
return 0;
WIN32_FIND_DATA fd;
if (!FindNextFile(hFile, &fd))
return 0;
set_amxstring(amx, params[2], fd.cFileName, params[3]);
return 1;
#else
DIR *dp = (DIR *)params[1];
if (!dp)
return 0;
struct dirent *ep = readdir(dp);
if (!ep)
return 0;
set_amxstring(amx, params[2], ep->d_name, params[3]);
return 1;
#endif
}
AMX_NATIVE_INFO file_Natives[] = {
AMX_NATIVE_INFO file_Natives[] =
{
{"delete_file", delete_file},
{"file_exists", file_exists},
{"file_size", file_size},
@ -754,8 +883,5 @@ AMX_NATIVE_INFO file_Natives[] = {
{"open_dir", amx_open_dir},
{"close_dir", amx_close_dir},
{"next_file", amx_get_dir},
{NULL, NULL}
};

View File

@ -718,16 +718,19 @@ void C_ClientCommand(edict_t *pEntity)
ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item);
if (ret & 2) result = MRES_SUPERCEDE;
else if (ret & 1) RETURN_META(MRES_SUPERCEDE);
else
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
else
{
if (item == MENU_BACK)
{
pMenu->Display(pPlayer->index, pPlayer->page-1);
} else if (item == MENU_MORE)
}
else if (item == MENU_MORE)
{
pMenu->Display(pPlayer->index, pPlayer->page + 1);
} else if (item == MENU_EXIT)
}
else if (item == MENU_EXIT)
{
//nothing
}
@ -1119,11 +1122,13 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
{
LOG_ERROR(PLID, "metamod version is too old for this plugin; update metamod");
return (FALSE);
} else if (pmajor < mmajor)
}
else if (pmajor < mmajor)
{
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
return (FALSE);
} else if (pmajor == mmajor)
}
else if (pmajor == mmajor)
{
#ifdef FAKEMETA
if (mminor == 10)
@ -1138,14 +1143,17 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
{
g_NeedsP = true;
#endif
} else if (mminor >= 11)
}
else if (mminor >= 11)
{
g_IsNewMM = true;
} else if (pminor > mminor)
}
else if (pminor > mminor)
{
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
return FALSE;
} else if (pminor < mminor)
}
else if (pminor < mminor)
{
LOG_MESSAGE(PLID, "WARNING: metamod version is newer than expected; consider finding a newer version of this plugin");

View File

@ -1,3 +1,33 @@
/* AMX Mod X
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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
*
* 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 "amxmodx.h"
#include "newmenus.h"
@ -86,10 +116,14 @@ int Menu::PagekeyToItem(page_t page, item_t key)
return MENU_MORE;
else
return MENU_EXIT;
} else if (key == rem+1) {
}
else if (key == rem + 1)
{
return MENU_EXIT;
}
} else if (page == pages - 1) {
}
else if (page == pages - 1)
{
//find number of remaining items
//for example, 11 items on page 1... means start=7, 11-7=4
item_t rem = numItems - start;
@ -97,14 +131,18 @@ int Menu::PagekeyToItem(page_t page, item_t key)
if (key == rem)
{
return MENU_EXIT;
} else if (key == rem+1) {
}
else if (key == rem + 1)
{
return MENU_BACK;
}
} else {
if (key == 7)
{
return MENU_MORE;
} else if (key == 8) {
}
else if (key == 8)
{
return MENU_BACK;
}
}

View File

@ -31,34 +31,28 @@
#include "amxmodx.h"
void amx_command(){
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");
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() );
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;
}
@ -75,7 +69,6 @@ void amx_command(){
}
print_srvconsole("%d plugins, %d running\n", plugins, running);
}
else if (!strcmp(cmd, "pause") && CMD_ARGC() > 2)
{
@ -88,8 +81,8 @@ void amx_command(){
plugin->pausePlugin();
print_srvconsole("Paused plugin \"%s\"\n", plugin->getName());
}
else print_srvconsole("Couldn't find plugin matching \"%s\"\n",sPlugin);
else
print_srvconsole("Couldn't find plugin matching \"%s\"\n", sPlugin);
}
else if (!strcmp(cmd, "unpause") && CMD_ARGC() > 2)
{
@ -101,38 +94,34 @@ void amx_command(){
{
plugin->unpausePlugin();
print_srvconsole("Unpaused plugin \"%s\"\n", plugin->getName());
} else if (!plugin) {
}
else if (!plugin)
{
print_srvconsole("Couldn't find plugin matching \"%s\"\n", sPlugin);
} else {
print_srvconsole("Plugin %s can't be unpaused right now.", sPlugin);
}
}
else if (!strcmp(cmd, "cvars"))
{
print_srvconsole("Registered cvars:\n");
print_srvconsole( " %-24.23s %-24.23s %-16.15s\n",
"name","value","plugin");
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(" [%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");
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);
@ -140,8 +129,7 @@ void amx_command(){
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());
print_srvconsole(" [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n", ++ammount, (*a).getCmdLine(), access, (*a).getCmdType(), (*a).getPlugin()->getName());
++a;
}
@ -149,7 +137,6 @@ void amx_command(){
}
else if (!strcmp(cmd, "version"))
{
print_srvconsole("%s %s\n", Plugin_info.name, Plugin_info.version);
print_srvconsole("Authors: %s (%s)\n", "Felix \"SniperBeamer\" Geyer, David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Jonny \"Got His Gun\" Bergstrom, and Lukasz \"SidLuke\" Wlasinski.", Plugin_info.url);
print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__);
@ -166,8 +153,7 @@ void amx_command(){
else if (!strcmp(cmd, "modules"))
{
print_srvconsole("Currently loaded modules:\n");
print_srvconsole( " %-23.22s %-8.7s %-20.19s %-11.10s\n",
"name", "version", "author", "status");
print_srvconsole(" %-23.22s %-8.7s %-20.19s %-11.10s\n", "name", "version", "author", "status");
int running = 0;
int modules = 0;
@ -178,17 +164,15 @@ void amx_command(){
{
if ((*a).getStatusValue() == MODULE_LOADED)
++running;
++modules;
print_srvconsole( " [%2d] %-23.22s %-8.7s %-20.19s %-11.10s\n", modules,
(*a).getName(), (*a).getVersion(), (*a).getAuthor() , (*a).getStatus() );
print_srvconsole(" [%2d] %-23.22s %-8.7s %-20.19s %-11.10s\n", modules, (*a).getName(), (*a).getVersion(), (*a).getAuthor(), (*a).getStatus());
++a;
}
print_srvconsole("%d modules, %d correct\n", modules, running);
} else if (!strcmp(cmd, "gpl"))
}
else if (!strcmp(cmd, "gpl"))
{
print_srvconsole("AMX Mod X\n");
print_srvconsole("\n");
@ -245,11 +229,7 @@ void amx_command(){
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x78\x78\x24\x40\x4E\x4E\x4D\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x3E\x3E\x3F\x3E\x3E\x3E\x3E\x3B\x3B\x3B\x3A\x3A\x3F\x3E\x3A\x2E\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2E\x45\x4D\x40\x45\x78\x5E\x33\x68\x33\x2B\n");
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x24\x48\x45\x48\x78\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x4E\x40\x2B\x66\x33\x78\x20\x20\n");
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x2C\x20\x3A\x20\x20\n");
}
else
{
} else {
print_srvconsole("Usage: amxx < command > [ argument ]\n");
print_srvconsole("Commands:\n");
print_srvconsole(" version - display amxx version info\n");
@ -260,11 +240,9 @@ void amx_command(){
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;
@ -274,8 +252,7 @@ void plugin_srvcmd()
while (a)
{
if ( (*a).matchCommand( cmd ) &&
(*a).getPlugin()->isExecutable( (*a).getFunction() ) )
if ((*a).matchCommand(cmd) && (*a).getPlugin()->isExecutable((*a).getFunction()))
{
cell ret = executeForwards((*a).getFunction(), g_srvindex, (*a).getFlags(), (*a).getId());
if (ret) break;

View File

@ -38,13 +38,14 @@ const char* stristr(const char* str,const char* substr)
register char *prevloc = (char *)str;
register char *haystack = (char *)str;
while (*haystack) {
if (tolower(*haystack) == tolower(*needle)) {
while (*haystack)
{
if (tolower(*haystack) == tolower(*needle))
{
haystack++;
if (!*++needle)
return prevloc;
}
else {
} else {
haystack = ++prevloc;
needle = (char *)substr;
}
@ -77,9 +78,12 @@ 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;
}
@ -89,9 +93,11 @@ char* get_amxstring(AMX *amx,cell amx_addr,int id, int& len)
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++)))
;
while ((*dest++=(char)(*source++)));
len = --dest - start;
return start;
}
@ -107,26 +113,36 @@ char* parse_arg(char** line,int& state)
static char arg[3072];
char* dest = arg;
state = 0;
while(**line) {
if ( isspace(**line) ) {
while (**line)
{
if (isspace(**line))
{
if (state == 1)
break;
else if (!state) {
else if (!state)
{
(*line)++;
continue;
}
}
else if (state != 2)
state = 1;
if (**line=='"') {
if (**line == '"')
{
(*line)++;
if (state == 2)
break;
state = 2;
continue;
}
*dest++ = *(*line)++;
}
*dest = '\0';
return arg;
}
@ -141,23 +157,32 @@ static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
int iWhat = amxstring_len(b);
int iWith = amxstring_len(c);
int iPot = iMain + iWith - iWhat;
if (iPot>=params[2]){
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){
while (*a)
{
if (*a == *b)
{
x = a + 1;
y = b + 1;
p = 1;
if (!*y) break;
while(*x==*y){
while (*x == *y)
{
x++; y++; p++;
if (!*y) break;
}
if (!*y) break;
p = 0;
*d++ = (char)*a++;
@ -165,7 +190,9 @@ static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
}
*d++ = (char)*a++;
}
if (p){
if (p)
{
while (*c) *d++ = (char)*c++;
a += p;
while (*a) *d++ = (char)*a++;
@ -175,6 +202,7 @@ static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
*z = 0;
return (z - l);
}
return 0;
}
@ -185,17 +213,20 @@ static cell AMX_NATIVE_CALL contain(AMX *amx, cell *params) /* 2 param */
register cell *c = b;
cell* str = b;
cell* substr = a;
while (*c) {
if (*c == *a) {
while (*c)
{
if (*c == *a)
{
c++;
if (!*++a)
return b - str;
}
else {
} else {
c = ++b;
a = substr;
}
}
return -1;
}
@ -206,17 +237,20 @@ static cell AMX_NATIVE_CALL containi(AMX *amx, cell *params) /* 2 param */
register cell *c = b;
cell* str = b;
cell* substr = a;
while (*c) {
if (tolower(*c) == tolower(*a)) {
while (*c)
{
if (tolower(*c) == tolower(*a))
{
c++;
if (!*++a)
return b - str;
}
else {
} else {
c = ++b;
a = substr;
}
}
return -1;
}
@ -255,6 +289,7 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
++str;
break;
}
if (*str < '0' || *str > '9')
{
REAL fl = neg ? -static_cast<REAL>(part1) : static_cast<REAL>(part1);
@ -269,6 +304,7 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
unsigned long part2 = 0;
unsigned long div = 1;
while (*str)
{
if (*str < '0' || *str > '9')
@ -281,8 +317,10 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
}
REAL fl = static_cast<REAL>(part1) + (static_cast<REAL>(part2) / div);
if (neg)
fl = -fl;
return amx_ftoc(fl);
}
@ -299,17 +337,23 @@ static cell AMX_NATIVE_CALL add(AMX *amx, cell *params) /* 4 param */
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
int c = params[2], d = params[4];
while (*dest && c--)
++dest;
if (d){
if (d)
{
while (c-- && d-- && *src)
*dest++ =* src++;
*dest = 0;
return (dest - start);
}
while (c-- && *src)
*dest++ =* src++;
*dest = 0;
return (dest-start);
}
@ -319,9 +363,11 @@ static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
int c = params[2];
while (c-- && *src)
*dest++ =* src++;
*dest = 0;
return (dest - start);
}
@ -332,9 +378,11 @@ static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */
cell *start = dest;
int c = params[2];
cell ch = params[4];
while (c-- && *src && *src != ch)
*dest++ =* src++;
*dest = 0;
return (dest - start);
}
@ -343,8 +391,10 @@ 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;
}
@ -353,14 +403,19 @@ 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) {
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;
}
@ -369,18 +424,24 @@ 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 {
if (c)
{
do
{
f = tolower(*a++);
l = tolower(*b++);
}
while (--c &&l&&f&& f==l);
} while (--c && l && f && f == l);
return (f - l) ? 0 : 1;
}
do {
do
{
f = tolower(*a++);
l = tolower(*b++);
} while (f && f == l);
return (f - l) ? 0 : 1;
}
@ -396,13 +457,19 @@ static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
char* arg, *parse = get_amxstring(amx, params[1], 0, c);
cell *cptr;
int state;
while(*parse){
while (*parse)
{
arg = parse_arg(&parse,state);
if (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;
@ -416,10 +483,13 @@ static cell AMX_NATIVE_CALL strtolower(AMX *amx, cell *params) /* 1 param */
{
cell *cptr = get_amxaddr(amx, params[1]);
cell *begin = cptr;
while(*cptr){
while (*cptr)
{
*cptr = tolower(*cptr);
cptr++;
}
return cptr - begin;
}
@ -427,10 +497,13 @@ static cell AMX_NATIVE_CALL strtoupper(AMX *amx, cell *params) /* 1 param */
{
cell *cptr = get_amxaddr(amx, params[1]);
cell *begin = cptr;
while(*cptr){
while (*cptr)
{
*cptr = toupper(*cptr);
cptr++;
}
return cptr - begin;
}
@ -464,7 +537,9 @@ char* fo_getargstr(AMX *amx, int swap, int pos)
static char buffer[2][3072];
char* b = buffer[swap];
int a = 0;
do {
do
{
value = src_value + a++ * sizeof(cell);
value = *(cell *)(data + (int)value);
*b++ = static_cast<char>(value);
@ -480,31 +555,42 @@ char* format_arguments(AMX *amx, int parm,int& len)
char *ptr, *arg, *dest = *buffer;
char *src = fo_getargstr(amx, 0, parm++);
int numparam = fo_numargs(amx);
while(*src) {
if (*src=='%'&&*(src+1)) {
while (*src)
{
if (*src == '%' && *(src + 1))
{
ptr = format;
*ptr++ = *src++;
if (*src=='%'){
if (*src == '%')
{
*dest++ = *src++;
continue;
}
while (!isalpha(*ptr++=*src++))
;
while (!isalpha(*ptr++ = *src++));
*ptr='\0';
if (numparam < parm) continue;
arg = buffer[1];
switch(*(ptr-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;
}
@ -531,6 +617,7 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
char token = static_cast<char>(params[6]);
//trim
int trim = params[7];
for (i = 0; i < (unsigned int)len; i++)
{
if (trim && !done_flag)
@ -541,11 +628,13 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
done_flag = true;
}
}
if (!done_flag && string[i] == token)
{
done_flag = true;
i++;
}
if (done_flag)
{
right[right_pos++] = string[i];
@ -553,12 +642,14 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
left[left_pos++] = string[i];
}
}
right[right_pos] = 0;
left[left_pos] = 0;
set_amxstring(amx, params[2], left, leftMax);
set_amxstring(amx, params[4], right, rightMax);
delete [] left;
delete [] right;
return 1;
}
@ -581,36 +672,53 @@ static cell AMX_NATIVE_CALL strbreak(AMX *amx, cell *params) /* 5 param */
int LeftMax = params[3];
int RightMax = params[5];
for (i=0; i<(unsigned int)l; i++) {
if (string[i] == '"' && !quote_flag) {
for (i = 0; i < (unsigned int)l; i++)
{
if (string[i] == '"' && !quote_flag)
{
quote_flag = true;
} else if (string[i] == '"' && quote_flag) {
}
else if (string[i] == '"' && quote_flag)
{
quote_flag = false;
}
if (isspace(string[i]) && !quote_flag && !done_flag) {
if (isspace(string[i]) && !quote_flag && !done_flag)
{
done_flag = true;
i++;
}
if (!done_flag && string[i]!='"') {
if (left_pos < LeftMax) {
if (!done_flag && string[i]!='"')
{
if (left_pos < LeftMax)
{
left[left_pos] = string[i];
if (left[left_pos] == '\'') {
if (left[left_pos] == '\'')
{
left[left_pos] = hold;
}
left_pos++;
} else {
done_flag = true;
}
} else {
if (right_pos < RightMax && string[i]!='"') {
if (right_pos < RightMax && string[i]!='"')
{
right[right_pos] = string[i];
if (right[right_pos] == '\'') {
if (right[right_pos] == '\'')
{
right[right_pos] = hold;
}
right_pos++;
}
}
}
left[left_pos] = '\0';
right[right_pos] = '\0';
set_amxstring(amx, params[2], left, params[3]);
@ -625,10 +733,13 @@ static cell AMX_NATIVE_CALL format_args(AMX *amx, cell *params)
{
int len;
int pos = params[3];
if (pos < 0){
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]);
}
@ -657,9 +768,11 @@ static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params)
{
int len = 0;
cell *str = get_amxaddr(amx, params[1]);
if (!isalpha((char)str[0]) || !(str[0] & (1<<5)))
return 0;
str[0] &= ~(1<<5);
return 1;
}
@ -679,6 +792,7 @@ static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
while (*cptr++) len++;
int flag = 0, incr = 0;
register int i = 0;
for (i = len - 1; i >= 0; i--)
{
if (!isspace(asdf[i]))
@ -716,13 +830,16 @@ static cell AMX_NATIVE_CALL n_strcat(AMX *amx,cell *params)
cdest = get_amxaddr(amx, params[1]);
csrc = get_amxaddr(amx, params[2]);
int num = params[3];
while (*cdest && num)
{
cdest++;
num--;
}
if (!num)
return 0;
while (*csrc && num)
{
*cdest++ = *csrc++;
@ -754,6 +871,7 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
bool found = false;
bool igcase = params[3] ? true : false;
if (igcase)
{
for (int i = 0; i < len; i++)
@ -767,8 +885,10 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
str[i] &= ~(1<<5);
}
}
if (params[4] > len)
return -1;
char *pos = &(str[params[4]]);
char *find = strstr(str, sub);
@ -778,7 +898,8 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
return (find - str);
}
AMX_NATIVE_INFO string_Natives[] = {
AMX_NATIVE_INFO string_Natives[] =
{
{"add", add},
{"contain", contain},
{"containi", containi},
@ -811,6 +932,5 @@ AMX_NATIVE_INFO string_Natives[] = {
{"strcmp", n_strcmp},
{"str_to_float", str_to_float},
{"float_to_str", float_to_str},
{NULL, NULL }
};

View File

@ -30,7 +30,6 @@
*/
#include <time.h>
#include "amxmodx.h"
#ifdef __linux__
@ -52,16 +51,21 @@ char *UTIL_VarArgs(const char *fmt, ...)
int UTIL_ReadFlags(const char* c)
{
int flags = 0;
while (*c) flags |= ( 1 << ( *c++ - 'a' ) );
while (*c)
flags |= (1<<(*c++ - 'a'));
return flags;
}
void UTIL_GetFlags(char* f, int a)
{
for(int i='a';i<='z';++i){
for (int i = 'a'; i <= 'z'; ++i)
{
if (a & 1) *f++ = i;
a >>= 1;
}
*f = 0;
}
@ -75,12 +79,14 @@ void UTIL_ShowMenu( edict_t* pEdict, int slots, int time, char *menu, int mlen )
if (!gmsgShowMenu)
return; // some games don't support ShowMenu (Firearms)
while ( *n ) {
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);
@ -109,12 +115,14 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
char c = 0;
int a;
while ( *n ) {
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);
@ -133,32 +141,42 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
void UTIL_IntToString(int value, char *output)
{
static const char *words[] = {"zero ","one ","two ","three ","four ",
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){
if (tho)
{
aaa += sprintf(&output[aaa], words[tho]);
aaa += sprintf(&output[aaa], words[29]);
value = value % 1000;
}
int hun = value / 100;
if (hun) {
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]);
}
@ -168,27 +186,34 @@ 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 ] == ' ' ) {
while (src[d] && e < 480)
{
if (src[d] == ' ')
{
c = e;
}
else if ( src[ d ] == '\n' ) {
else if (src[d] == '\n')
{
c = -1;
b = 0;
}
message[e++] = src[d++];
if ( ++b == 69 ) {
if ( c == -1 ) {
if (++b == 69)
{
if (c == -1)
{
message[e++] = '\n';
b = 0;
}
else {
} else {
message[c] = '\n';
b = e - c - 1;
c = -1;
}
}
}
message[e] = 0;
return message;
}
@ -240,8 +265,10 @@ void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pM
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();
}
@ -255,10 +282,12 @@ 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();

View File

@ -47,7 +47,6 @@ static cell AMX_NATIVE_CALL set_vaultdata(AMX *amx,cell *params)
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])
@ -69,11 +68,11 @@ static cell AMX_NATIVE_CALL remove_vaultdata(AMX *amx,cell *params)
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[] = {
AMX_NATIVE_INFO vault_Natives[] =
{
{"set_vaultdata", set_vaultdata},
{"get_vaultdata", get_vaultdata},
{"remove_vaultdata", remove_vaultdata},
@ -81,5 +80,3 @@ AMX_NATIVE_INFO vault_Natives[] = {
{"vaultdata_exists", vaultdata_exists},
{0, 0}
};