08.05.2011, 05:02
That is not the problem.
You have problems with the code..
EDIT: you need strtok:
I don't know much about strtok() but it should work
You have problems with the code..
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/god", cmdtext, true, 10) == 0) {
new cmd[128],idx,tmp[128];
cmd = strtok(cmdtext,idx);
tmp = strtok(cmd,idx);
if(IsPlayerAdmin(playerid)) {
if(!strlen(tmp)) return SendClientMessage(playerid,white,"USAGE: /god [on | off]");
if(strcmp(tmp,"on",true) == 0) {
SendClientMessage(playerid, SERVER," .Godmode Activated. ");
SetPlayerHealth(playerid, GOD_HEALTH);
GivePlayerWeapon(playerid, GOD_WEAPON,GOD_AMMO);
} else if(strcmp(tmp,"on",true) == 0) {
SendClientMessage(playerid,SERVER,".Godmode Deactivated.");
} else {
return SendClientMessage(playerid,red,"USAGE: /god [on | off]");
}
} else {
return SendClientMessage(playerid, SERVER,"ERROR: This command is only avaible for RCON Administrators.");
}
return 1;
}
return SendClientMessage(playerid,white,"Unknown Command. Please type /help to see avaible commands.");
}
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}