27.07.2011, 17:11
Try this, not tested.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/freeze", true) == 0)
{
new tmp[32];
tmp = strtok(cmdtext, idx);
TogglePlayerControllable( strval(tmp), false );
GameTextForPlayer( strval(tmp), "~r~Frozen!", 2000, 3);
return 1;
}
if(strcmp(cmd, "/unfreeze", true) == 0)
{
new tmp[32];
tmp = strtok(cmdtext, idx);
TogglePlayerControllable( strval(tmp), true );
GameTextForPlayer( strval(tmp), "~g~Unfrozen!", 2000, 3);
return 1;
}
return 0;
}
//Place this at the end of your script.
//If you have one, no need then.
stock 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;
}