05.11.2009, 07:45
Код:
if(strcmp("/givescore",cmdtext,true,10) == 0) { if(IsPlayerAdmin(playerid)) { new score = GetPlayerScore(playerid); SetPlayerScore(playerid,score+1); } return 1; }
if(strcmp("/givescore",cmdtext,true,10) == 0) { if(IsPlayerAdmin(playerid)) { new score = GetPlayerScore(playerid); SetPlayerScore(playerid,score+1); } return 1; }
cmd(givescore, playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new id;
if(sscanf(params,"i",id)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /givescore [id]");
else SetPlayerScore(id,GetPlayerScore(id)+1);
return 1;
}
return 0;
}
Originally Posted by CrαcK
I suggest you to use zcmd and sscanf
It will look like: pawn Код:
|
#include <zcmd> //at the top
//copy and paste sscanf function and givescore command somewhere in your script (outside any callback!)
//for example
public OnPlayerCommandText(playerid, cmdtext[]) // < callback
{
//you probably have something here
return 0;
}
//paste sscanf and givescore command here
if(strcmp("/givescore",cmdtext,true,10) == 0)
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /givescore [id]");
return 1;
}
new pl = strval(tmp);
new score = GetPlayerScore(pl);
SetPlayerScore(pl,score+1);
return 1;
}
}
return 1;
}