Defined wont work ( dcmd and more ) -
Kovacs_Richard - 13.03.2011
Hello, i tried define any codes what make my script better but wont work :S i tried DCMD and dont work too
(I use strtok)
pawn Код:
#define CMD(%1) !strcmp(cmd, %1, true)
AND THIS IS UNDER OnPlayerCommandText:
pawn Код:
if (CMD("/gop"))
{
if(GetPlayerAdmin(playerid) < 2){ return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SyntaxFormat(cmd,"[PlayerID]",tmp); ChatMessage(playerid,0, tmp,"p"); return 1;
}
giveplayerid = ReturnUser(tmp);
if(!IsPlayerConnected(giveplayerid)){ return 1; }
TelePlayerToPlayer(playerid,giveplayerid);
return 1;
}
DCMD TRIED:
pawn Код:
#define dcmd(%1,%2,%3) if ((strcmp(%3, "/%1", true, %2+1) == 0)&&(((%3[%2+1]==0)&&(dcmd_%1(playerid,"")))||((%3[%2+1]==32)&&(dcmd_%1(playerid,%3[%2+2]))))) return 1
forward dcmd_help();
public dcmd_help()
{
print("HELP");
return 1;
}
AND THIS IS UNDER OnPlayerCommandText:
AND I GOT THIS:
pawn Код:
warning 202: number of arguments does not match definition
Whats the problem ? i use Pawno
and when i printf it:
pawn Код:
#define CMD(%1) "!strcmp(cmd, %1, true)"
its show %1 as %1
Re : Defined wont work ( dcmd and more ) -
Vukilore - 13.03.2011
use [/pawn] [/pawn] in forum please
Re: Defined wont work ( dcmd and more ) -
Pangea - 13.03.2011
You don't create a public for the dcmd commands.
pawn Код:
dcmd_help(playerid, params[])
{
// do stuff here.
print("HELP");
return 1;
}
As I recall you should use it like this.
Re: Defined wont work ( dcmd and more ) -
Kovacs_Richard - 13.03.2011
pawn Код:
warning 202: number of arguments does not match definition
Re: Defined wont work ( dcmd and more ) -
Pangea - 13.03.2011
In which lines do you get that warning?
Re: Defined wont work ( dcmd and more ) -
Kovacs_Richard - 13.03.2011
Re: Defined wont work ( dcmd and more ) -
xir - 13.03.2011
DCMD define
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
pawn Код:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
dcmd(help, 4, cmdtext); // 4 chars. because help is 4 char long.
return 0;
}
dcmd_help(playerid, params[])
{
SendClientMessage(playerid, COLOR_WHITE, "Hello, welcome to my server");
return 1;
}
That is how it works, you don't create publics for it
Re: Defined wont work ( dcmd and more ) -
ricardo178 - 13.03.2011
omg... To create dcmd cmd do like this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(setmyhealth,11,cmdtext);
return 0;
}
dcmd_setmyhealth(playerid, params[])
{
SetPlayerHealth(playerid, 50);
SendClientMessage(playerid, 0x0259EAAA, "Your Health Has Been Setted To 50");
return 1;
}
Re: Defined wont work ( dcmd and more ) -
xir - 13.03.2011
That is incorrect Ricardo.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(setmyhealth,11,cmdtext);
return 0;
}
dcmd_setmyhealth(playerid, params[])
{
SetPlayerHealth(playerid, 50);
SendClientMessage(playerid, 0x0259EAAA, "Your Health Has Been Setted To 50%%");
return 1;
}
Re: Defined wont work ( dcmd and more ) -
ricardo178 - 13.03.2011
Yeah, i done wrong

My Fault and thanks for tell, post edited