08.12.2010, 00:10
Hello everybody. I was working on a admin script for my current work San Fierro Harbor. Well, I tested it with my brother and I have an awful error.. Every command with extra parameters like /slap [ID] or /makeadmin [ID] are returning Invalid Command error.
Examples:
It always returns SERVER: Unknown Command (in this case as I edited it, [ERROR]: Invalid command) if the command has extra parameters. If I type just /slap it will return a Client Message but if I do /slap [any id] it returns Unknown Command.
P.S: I know the tmp strings are 256 cells and its a waste, dont remind it to me.
P.S: Any improvement is really appreciated.
Examples:
pawn Код:
if(strcmp(cmdtext, "/slap", true)==0)
{
new tmp[256];
tmp = strtok( cmdtext, idx );
if (!strlen(tmp))
{
return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /slap");
}
if(PlayerInfo[playerid][pAdminLevel] > 0)
{
new string[50], string2[50], adminname[MAX_PLAYER_NAME], slapname[MAX_PLAYER_NAME];
GetPlayerName(playerid, adminname, sizeof(adminname));
GetPlayerName(playerid, slapname, sizeof(slapname));
format(string, sizeof(string), " Administrator %s has slapped you", adminname);
format(string2, sizeof(string2), " Player %s has been slapped by administrator %s", slapname, adminname);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(strval(tmp), X,Y,Z);
SetPlayerPos(strval(tmp),X,Y,Z+10);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
SendClientMessageToAll(COLOR_LIGHTBLUE,string2);
return 1;
}
else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
if(strval(tmp) == playerid) SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot do this on yourself!");
if(strval(tmp) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid ID.");
return 1;
}
pawn Код:
if(strcmp(cmdtext, "/makegolden", true)==0)
{
new tmp[256];
tmp = strtok( cmdtext, idx );
if (!strlen(tmp))
{
return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /makegolden");
}
if(PlayerInfo[playerid][pAdminLevel] == 2)
{
new string[50], string2[50], adminname[MAX_PLAYER_NAME], givename[MAX_PLAYER_NAME];
GetPlayerName(playerid, adminname, sizeof(adminname));
GetPlayerName(playerid, givename, sizeof(givename));
format(string, sizeof(string), " Administrator %s has made you a Golden User. Thanks for donating!", adminname);
format(string2, sizeof(string2), " You have made %s a Golden User. He was kicked so he can relog and changes will take effect.", givename);
SendClientMessage(playerid,COLOR_YELLOW,string2);
SendClientMessage(strval(tmp),COLOR_YELLOW,string);
SendClientMessage(strval(tmp),COLOR_YELLOW,"Please relog for the changes to take effect.");
PlayerInfo[strval(tmp)][pIsGolden] = 1;
Kick(strval(tmp));
return 1;
}
else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
if(strval(tmp) == playerid) SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot do this on yourself!");
if(strval(tmp) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid ID.");
return 1;
}
P.S: I know the tmp strings are 256 cells and its a waste, dont remind it to me.
P.S: Any improvement is really appreciated.