Problem with cmdtext in DCMD - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with cmdtext in DCMD (
/showthread.php?tid=147020)
Problem with cmdtext in DCMD -
Jochemd - 10.05.2010
Hello,
pawn Код:
dcmd_ooc(playerid,params[])
{
if(OocChatEnable == 1)
{
if ((strlen(cmdtext) >= 1)&&(strlen(cmdtext) <= 4)) { SendClientMessage(playerid,0x6495EDAAA, "Syntax Error: /ooc [Message]"); return 1;}
GetPlayerName(playerid,oocname,sizeof(oocname)); format(string,sizeof(string),".:: [OOC] %s: %s",oocname,cmdtext[5]); SendClientMessageToAll(COLOR_OOC, string);
}
else
SendClientMessage(playerid,0xDCDCDCFF," The OOC chat has been disabled.");
return true;
}
Why am I not able to use it? It gives error: 'Undefinied symbol: cmdtext'. I created dcmd(ooc,3,cmdtext). What could be the problem?
Regards, Jochem
Re: Problem with cmdtext in DCMD -
mansonh - 10.05.2010
because you don't have cmdtext inside the dcmd function.
your dcmd(ooc,3,cmdtext) is correct.
Inside your dcmd_ooc function you have the variables, playerid, and params[].
So no more cmdtext, instead use params.
Heres a tutorial that may help:
http://forum.sa-mp.com/index.php?topic=75000.0
And if you want to do it even better, i would suggest also learning sscanf, it makes parameter matching really simple:
http://forum.sa-mp.com/index.php?topic=145539.0
Re: Problem with cmdtext in DCMD -
Jochemd - 10.05.2010
I don't get it. Can you give me an example with my ooc snippet? Maybe?
Re: Problem with cmdtext in DCMD -
mansonh - 10.05.2010
Here is your code in dcmd.
pawn Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext){
dcmd(ooc, 3, cmdtext);
return 0;
}
dcmd_ooc(playerid,params[])
{
if(OocChatEnable == 1)
{
if ((strlen(params) < 1)) return SendClientMessage(playerid,0x6495EDAAA, "Syntax Error: /ooc [Message]");
new oocname[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid,oocname,MAX_PLAYER_NAME);
format(string,sizeof(string),".:: [OOC] %s: %s",oocname,params);
SendClientMessageToAll(COLOR_OOC, string);
}
else
SendClientMessage(playerid,0xDCDCDCFF," The OOC chat has been disabled.");
return 1;
}