07.08.2009, 22:18
The commando is:
And it adds at the end of gamemode or filterscript:
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256]; new idx; cmd = strtok(cmdtext, idx); if (strcmp(cmd, "/BuyGrenades", true) == 0) { new tmp[20], amount; if (strlen(tmp)) { amount = strval(tmp); if (IsPlayerConnected(amount)) { GivePlayerWeapon(playerid,16,342); GivePlayerMoney(playerid,- 1000); } else { SendClientMessage(playerid, 0xFF0000AA, "You Don't Have enough Money!"); } } else { SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/buygrenades <amount>\""); } return 1; } return 0; }
Код:
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; }