new bool: actived[MAX_PLAYERS] = true; CMD:example(id, params[]) { if (!actived[id]) return 1; //....... return 1; }
Код:
new bool: actived[MAX_PLAYERS] = true; CMD:example(id, params[]) { if (!actived[id]) return 1; //....... return 1; } |
new bool:active[MAX_PLAYERS]; public OnPlayerCommandReceived(...) { if(!active[playerid]) return (false); // REST OF THE CODE }
CMD:fakecmd(playerid, params[]) { //[...] new sCMD[30]; if(sscanf(params, "ds[30]", id, sCMD)) return SendClientMessage(playerid, COLOR_ERRO, "[ x ] Uso correto: /FakeCMD [ ID ] [ Comando ]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ERRO, "[ x ] Ninguйm online com esse ID!"); PC_EmulateCommand(id, sCMD); return 1; }
public OnPlayerCommandText(playerid, cmdtext[])
{
new HelpCMD[20];
format(HelpCMD, sizeof(HelpCMD), "/aide");
if(strcmp(HelpCMD, cmdtext, true, 10) == 0)
{
// My Code
return 1;
}
return 1;
}
cmd:HelpCMD(playerid, param[]) return 1;
Thank you.
I would like to know how PAWN.CMD used for irregular use. Here is my code with strcmp Resume PHP код:
PHP код:
Thanks.. (Bad English) |
CMD:aide(playerid, params[])
{
// ton code... / your code ...
return 1;
}
[00:26:55]---------- Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3.7-R2, ©2005-2015 SA-MP Team [00:26:50] [00:26:50] Server Plugins [00:26:50] -------------- [00:26:50] Loading plugin: crashdetect [00:26:50] CrashDetect v4.13.1 is OK. [00:26:50] Loaded. [00:26:50] Loading plugin: mysql_static [00:26:50] Failed. [00:26:50] Loading plugin: mysql [00:26:50] >> plugin.mysql: R39-3 successfully loaded. [00:26:50] Loaded. [00:26:50] Loading plugin: sscanf [00:26:50] [00:26:50] =============================== [00:26:50] sscanf plugin loaded. [00:26:50] Version: 2.8.1 [00:26:50] © 2012 Alex "Y_Less" Cole [00:26:50] =============================== [00:26:50] Loaded. [00:26:50] Loading plugin: streamer [00:26:50] Failed. [00:26:50] Loading plugin: pawncmd [00:26:50] Pawn.CMD plugin v3.1.2 by urShadow loaded [00:26:50] Loaded. [00:26:50] Loading plugin: nativechecker [00:26:50] Loaded. [00:26:50] Loaded 5 plugins. [00:26:50] [00:26:50] Filterscripts [00:26:50] --------------- [00:26:50] Loaded 0 filterscripts. [00:26:55] [debug] Server crashed due to an unknown error [00:26:56] [debug] Native backtrace: [00:26:56] [debug] #0 012922f7 in ?? () from plugins\pawncmd.dll [00:26:56] [debug] #1 012945fb in ?? () from plugins\pawncmd.dll [00:26:56] [debug] #2 00469ab5 in ?? () from samp-server.exe [00:26:56] [debug] #3 65646f6d in ?? () from samp-server.exe
PHP код:
Tu peux retirer "params[]" si tu n'as pas besoin de mettre de paramиtre. Si ta commande est juste "/aide" sans paramиtre (ex: "/aide 1" oщ 1 est un paramиtre de la commande), tu peux retirer "params[]". |
Код:
public OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags) { if(result == -1) { SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command."); return 0; } return 1; } |
CMD:ajetpack(playerid)
{
if(pInfo[playerid][AdminLvl] < 2) return 0; // this will send result value as 0.
if(!AdmDuty{playerid}) return SendClientMessage(playerid, COLOR_RED, "ERROR: "COL_GREY"You must be on admin duty to use this command."), 0; // this will send result value as 0 as well.
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
SendClientMessage(playerid, COLOR_PINK, "* Spawned Jetpack.");
return 1; // this will send result value as 1.
}
public OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags)
{
if(!result) // if result is zero
return SendClientMessage(playerid, COLOR_RED, "ERROR: You're not permitted to use this command.");
return 1;
}
Is PC_EmulateCommand supposed not to call "OnPlayerCommandPerformed"? Because it doesn't calls for me.
|
What if in command return -1;? so in callback if(result == -1) will do check?
|
---------- Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3.7-R2, ©2005-2015 SA-MP Team [22:17:36] filterscripts = "" (string) [22:17:36] [22:17:36] Server Plugins [22:17:36] -------------- [22:17:36] Loading plugin: crashdetect.so [22:17:36] CrashDetect v4.18.1 is OK. [22:17:36] Loaded. [22:17:36] Loading plugin: streamer.so [22:17:36] *** Streamer Plugin v2.9.1 by Incognito loaded *** [22:17:36] Loaded. [22:17:36] Loading plugin: sscanf.so [22:17:36] [22:17:36] =============================== [22:17:36] sscanf plugin loaded. [22:17:36] Version: 2.8.2 [22:17:36] © 2012 Alex "******" Cole [22:17:36] =============================== [22:17:36] Loaded. [22:17:36] Loading plugin: mysql.so [22:17:36] >> plugin.mysql: R41-3 successfully loaded. [22:17:36] Loaded. [22:17:36] Loading plugin: MapAndreas.so [22:17:36] Loaded. [22:17:36] Loading plugin: SKY.so [22:17:36] Loaded. [22:17:36] Loading plugin: pawncmd.so [22:17:36] Pawn.CMD plugin v3.1.3 by urShadow loaded [22:17:36] Loaded. [22:17:36] Loaded 7 plugins. [22:17:36] [22:17:36] Filterscripts [22:17:36] --------------- [22:17:36] Loaded 0 filterscripts. [22:17:36] [22:17:36] [22:17:36] [22:17:36] ======================================= [22:17:36] | | [22:17:36] | YSI version 4.00.0001 | [22:17:36] | By Alex "******" Cole | [22:17:36] | | [22:17:36] ======================================= [22:17:36] [22:17:37] Succesfully connected. [22:17:37] Number of vehicle models: 12 [22:18:03] [join] Hydra has joined the server [22:23:47] [chat] [Hydra]: /base [22:23:49] [debug] Server crashed while executing Test.amx [22:23:49] [debug] AMX backtrace: [22:23:49] [debug] #0 00000074 in ?? (... <28 arguments>) at <unknown file>:0 [22:23:49] [debug] #1 00000074 in public pc_cmd_base () at <unknown file>:0