本文整理汇总了C++中MF_GetAmxString函数的典型用法代码示例。如果您正苦于以下问题:C++ MF_GetAmxString函数的具体用法?C++ MF_GetAmxString怎么用?C++ MF_GetAmxString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MF_GetAmxString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: regex_replace
//native regex_replace(Regex:pattern, string[], maxLen, const replace[], flags = REGEX_FORMAT_DEFAULT, &errcode = 0);
static cell AMX_NATIVE_CALL regex_replace(AMX *amx, cell *params)
{
int id = params[1] - 1;
if (id >= (int)PEL.length() || id < 0 || PEL[id]->isFree())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid regex handle %d", id);
return 0;
}
int textLen, replaceLen;
char *text = MF_GetAmxString(amx, params[2], 0, &textLen);
const char *replace = MF_GetAmxString(amx, params[4], 1, &replaceLen);
cell *erroCode = MF_GetAmxAddr(amx, params[6]);
RegEx *x = PEL[id];
int e = x->Replace(text, params[3] + 1, replace, replaceLen, params[5]);
if (e == -1)
{
*erroCode = x->mErrorOffset;
x->ClearMatch();
return -2;
}
else if (e == 0)
{
*erroCode = 0;
x->ClearMatch();
return 0;
}
MF_SetAmxString(amx, params[2], text, params[3]);
return e;
}
示例2: find_ent_by_model
static cell AMX_NATIVE_CALL find_ent_by_model(AMX *amx, cell *params) {
int iStart = params[1];
int iLength, iLength2;
char *szClass = MF_GetAmxString(amx, params[2], 0, &iLength);
char *szModel = MF_GetAmxString(amx, params[3], 1, &iLength2);
edict_t *pStart;
if (iStart == -1)
{
pStart = NULL;
} else {
if (!is_ent_valid(iStart))
pStart = NULL;
else
pStart = INDEXENT2(iStart);
}
edict_t *pEdict = FIND_ENTITY_BY_STRING(pStart, "classname", szClass);
const char *check;
while (pEdict && !FNullEnt(pEdict))
{
check = STRING(pEdict->v.model);
if (!check || strcmp(check, szModel))
pEdict = FIND_ENTITY_BY_STRING(pEdict, "classname", szClass);
else
return ENTINDEX(pEdict);
}
return 0;
}
示例3: socket_listen_t
// native socket_listen_t( rc, hostname, port, protocol, recvhandler ) // Give access to iMaxConnections also ?
static cell AMX_NATIVE_CALL socket_listen_t(AMX *amx, cell *params) /* 5 param */
{
if( !params[1] )
return -1;
// Get SocketThread form param[1]
CThreadedSocketItem* SocketThread = (CThreadedSocketItem *)params[1];
int len;
char* szTempHostnam = MF_GetAmxString(amx,params[2],0,&len);
if( SocketThread->Hostname != NULL )
{
delete [] SocketThread->Hostname;
SocketThread->Hostname = NULL;
}
SocketThread->Hostname = new char [len+1];
// Copy Hostname
strcpy( SocketThread->Hostname, szTempHostnam );
SocketThread->Hostname[len] = '\0';
SocketThread->port = params[3];
SocketThread->protocol = params[4];
// Register Forward and save fwdID in fid array
SocketThread->fIDs[FID_LISTEN] = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[5], 0, &len), FP_CELL, FP_CELL, FP_DONE);
if( SocketThread->fIDs[FID_LISTEN] < 0 )
{
return -2; // Could not find Public CallBack function to register it
}
// Since all the required data is set, Run the thread in required state
SocketThread->ThreadState(STATE_LISTEN);
return 0;
}
示例4: register_touch
static cell AMX_NATIVE_CALL register_touch(AMX *amx, cell *params)
{
int len;
char *Toucher = MF_GetAmxString(amx, params[1], 0, &len);
char *Touched = MF_GetAmxString(amx, params[2], 1, &len);
Touch *p = new Touch;
if (!strlen(Toucher) || strcmp(Toucher, "*")==0) {
p->Toucher.assign("");
} else {
p->Toucher.assign(Toucher);
}
if (!strlen(Touched) || strcmp(Touched, "*")==0) {
p->Touched.assign("");
} else {
p->Touched.assign(Touched);
}
p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[3], 2, &len), FP_CELL, FP_CELL, FP_DONE);
Touches.push_back(p);
if (!g_pFunctionTable->pfnTouch)
g_pFunctionTable->pfnTouch=pfnTouch;
return p->Forward;
}
示例5: register_cwpn
// name,logname,melee=0
static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params)
{
int i;
bool bFree = false;
for(i = DODMAX_WEAPONS - DODMAX_CUSTOMWPNS; i < DODMAX_WEAPONS; i++)
{
if(!weaponData[i].needcheck)
{
bFree = true;
break;
}
}
if(!bFree)
return 0;
int iLen;
char *szName = MF_GetAmxString(amx, params[1], 0, &iLen);
char *szLogName = MF_GetAmxString(amx, params[3], 0, &iLen);
strcpy(weaponData[i].name,szName);
strcpy(weaponData[i].logname,szLogName);
weaponData[i].needcheck = true;
weaponData[i].melee = params[2] ? true:false;
return i;
}
示例6: set_kvd
static cell AMX_NATIVE_CALL set_kvd(AMX *amx, cell *params)
{
KVD_Wrapper *kvdw;
KeyValueData *kvd;
if (params[1] == 0)
kvdw = &g_kvd_glb;
else
kvdw = reinterpret_cast<KVD_Wrapper *>(params[1]);
kvd = kvdw->kvd;
if (*params / sizeof(cell) < 3)
{
MF_LogError(amx, AMX_ERR_NATIVE, "No data passed");
return 0;
}
cell *ptr = MF_GetAmxAddr(amx, params[3]);
int len;
switch (params[2])
{
case KV_fHandled:
{
kvd->fHandled = (int)*ptr;
return 1;
break;
}
case KV_ClassName:
{
kvdw->cls = MF_GetAmxString(amx, params[3], 0, &len);
kvd->szClassName = const_cast<char *>(kvdw->cls.chars());
return 1;
break;
}
case KV_KeyName:
{
kvdw->key = MF_GetAmxString(amx, params[3], 0, &len);
kvd->szKeyName = const_cast<char *>(kvdw->key.chars());
return 1;
break;
}
case KV_Value:
{
kvdw->val = MF_GetAmxString(amx, params[3], 0, &len);
kvd->szValue = const_cast<char *>(kvdw->val.chars());
return 1;
break;
}
}
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid KeyValueData member: %d", params[2]);
return 0;
}
示例7: Call_Int_Str_Str
cell Call_Int_Str_Str(AMX* amx, cell* params)
{
SETUP(2);
char *sz3=MF_GetAmxString(amx, params[3], 0, NULL);
char *sz4=MF_GetAmxString(amx, params[4], 1, NULL);
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, const char *, const char *)>(__func)(pv, 0, sz3, sz4);
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, const char *, const char *)>(__func)(pv, sz3, sz4);
#endif
}
示例8: set_lights
// SetLights, this sets the lights for the map.
//(vexd)
static cell AMX_NATIVE_CALL set_lights(AMX *amx, cell *params) {
int iLength;
char *szLights = MF_GetAmxString(amx, params[1], 0, &iLength);
if (FStrEq(szLights, "#OFF")) {
glinfo.bCheckLights = false;
g_pFunctionTable_Post->pfnStartFrame = NULL;
memset(glinfo.szLastLights, 0x0, 128);
(g_engfuncs.pfnLightStyle)(0, glinfo.szRealLights);
return 1;
}
g_pFunctionTable_Post->pfnStartFrame = StartFrame_Post;
glinfo.bCheckLights = true;
//Reset LastLights
memset(glinfo.szLastLights, 0x0, 128);
//Store the previous lighting.
memcpy(glinfo.szLastLights, szLights, strlen(szLights));
(g_engfuncs.pfnLightStyle)(0, szLights);
// These make it so that players/weaponmodels look like whatever the lighting is
// at. otherwise it would color players under the skybox to these values.
SERVER_COMMAND("sv_skycolor_r 0\n");
SERVER_COMMAND("sv_skycolor_g 0\n");
SERVER_COMMAND("sv_skycolor_b 0\n");
return 1;
}
示例9: SQL_QuoteString
static cell AMX_NATIVE_CALL SQL_QuoteString(AMX *amx, cell *params)
{
int len;
char *str = MF_GetAmxString(amx, params[4], 0, &len);
size_t newsize;
static char buffer[8192];
if (params[1] != 0)
{
IDatabase *pDb = (IDatabase *)GetHandle(params[1], Handle_Database);
if (!pDb)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid database handle: %d", params[1]);
return 0;
}
if (pDb->QuoteString(str, buffer, sizeof(buffer)-1, &newsize) == 0)
{
MF_SetAmxString(amx, params[2], buffer, params[3]);
return newsize;
} else {
return -1;
}
} else {
if (g_Sqlite.QuoteString(str, buffer, sizeof(buffer)-1, &newsize) == 0)
{
MF_SetAmxString(amx, params[2], buffer, params[3]);
return newsize;
} else {
return -1;
}
}
}
示例10: SQL_MakeDbTuple
static cell AMX_NATIVE_CALL SQL_MakeDbTuple(AMX *amx, cell *params)
{
SQL_Connection *sql = new SQL_Connection;
int len;
sql->port = 0;
sql->host = strdup("");
sql->user = strdup("");
sql->pass = strdup("");
char *db = MF_GetAmxString(amx, params[4], 0, &len);
char path[255];
FILE *fp;
MF_BuildPathnameR(path, sizeof(path)-1, "%s", db);
if ((fp=fopen(path, "rb")))
{
fclose(fp);
sql->db = strdup(path);
} else {
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3/%s.sq3",
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
db);
sql->db = strdup(path);
}
unsigned int num = MakeHandle(sql, Handle_Connection, FreeConnection);
return num;
}
示例11: ns_giveitem
// ns_giveiteM(id,"item");
static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
{
CreatePlayerPointer(amx,params[1]);
char *classname = MF_GetAmxString(amx,params[2],0,NULL);
if (!player->IsConnected())
{
return 0;
}
if (player->GetPev()->deadflag > 0)
{
return 0;
}
edict_t *object=CREATE_NAMED_ENTITY(ALLOC_STRING2(classname));
if (!object)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Error creating entity \"%s\"", classname);
return 0;
}
SET_ORIGIN(object,player->GetPev()->origin); // move to player
gpGamedllFuncs->dllapi_table->pfnSpawn(object); // emulate spawn
object->v.flags |= FL_ONGROUND; // make it think it's touched the ground
gpGamedllFuncs->dllapi_table->pfnThink(object); //
gpGamedllFuncs->dllapi_table->pfnTouch(object,player->GetEdict()); // give it to the player
return 1;
}
示例12: Call_Void_Str_Str_Int
cell Call_Void_Str_Str_Int(AMX *amx, cell *params)
{
SETUP(3);
char *sz3=MF_GetAmxString(amx, params[3], 0, NULL);
char *sz4=MF_GetAmxString(amx, params[4], 1, NULL);
int i5=*MF_GetAmxAddr(amx, params[5]);
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, const char *, const char *, int)>(__func)(pv, 0, sz3, sz4, i5);
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, const char *, const char *, int)>(__func)(pv, sz3, sz4, i5);
#endif
return 1;
}
示例13: SQL_FieldNameToNum
static cell AMX_NATIVE_CALL SQL_FieldNameToNum(AMX *amx, cell *params)
{
AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query);
if (!qInfo)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]);
return 0;
}
IResultSet *rs = qInfo->info.rs;
if (!rs)
{
MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
return 0;
}
int len;
char *namewa = MF_GetAmxString(amx, params[2], 0, &len);
unsigned int columnId;
if (!rs->FieldNameToNum(namewa, &columnId))
{
return -1;
}
return columnId;
}
示例14: csdm_reload_cfg
static cell AMX_NATIVE_CALL csdm_reload_cfg(AMX *amx, cell *params)
{
char file[255];
file[0] = '\0';
if (params[0] / sizeof(cell) != 0)
{
int len;
char *str = MF_GetAmxString(amx, params[1], 0, &len);
if (str[0] != '\0')
{
MF_BuildPathnameR(file, sizeof(file)-1, "%s/%s", LOCALINFO("amxx_configsdir"), str);
}
}
if (file[0] == '\0')
{
MF_BuildPathnameR(file, sizeof(file)-1, "%s/csdm.cfg", LOCALINFO("amxx_configsdir"));
}
if (g_Config.ReadConfig(file) != Config_Ok)
{
MF_Log("Could not read config file: %s", file);
return 0;
}
return 1;
}
示例15: fm_return
static cell AMX_NATIVE_CALL fm_return(AMX *amx, cell *params)
{
int len;
switch (params[1])
{
case FMV_STRING:
{
mStringResult = STRING(ALLOC_STRING(MF_GetAmxString(amx, params[2], 0 ,&len)));
break;
}
case FMV_FLOAT:
{
mFloatResult = amx_ctof(*(MF_GetAmxAddr(amx,params[2])));
break;
}
case FMV_CELL:
{
mCellResult = *(MF_GetAmxAddr(amx,params[2]));
break;
}
default:
{
return 0;
break;
}
}
retType = params[1];
return 1;
}