11.02.2011, 17:54
you will need strtok include for this command...the command is /giveweapon [weaponid] [ammo])
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/giveweapon", true) == 0) {
new tmp[256],tmp2[256],tmp3[256];
tmp = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);
tmp3 = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOUR_ORANGE, "Usage : /giveweapon [playerid] [weaponid] [amount]");
return 1;
}
if(!strlen(tmp2)) {
SendClientMessage(playerid, COLOUR_ORANGE, "Usage : /giveweapon [playerid] [weaponid] [amount]");
return 1;
}
if(!strlen(tmp3)) {
SendClientMessage(playerid, COLOUR_ORANGE, "Usage : /giveweapon [playerid] [weaponid] [amount]");
return 1;
}
new victim, weaponid, ammo;
victim = strval(tmp);
weaponid = strval(tmp2);
ammo = strval(tmp3);
new string[128];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
new playername2[MAX_PLAYER_NAME];
GetPlayerName(victim, playername2, sizeof(playername2));
format(string, sizeof(string), "The admin %s gave you a weapon.", playername);
SendClientMessage(victim, COLOUR_YELLOW, string);
GivePlayerWeapon(victim, weaponid, ammo);
format(string, sizeof(string), "you gave %s a weapon.", playername2);
SendClientMessage(playerid, COLOUR_YELLOW, string);
return 1;
}