11.06.2011, 13:05
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx, tmp[256];
cmd = strtok(cmdtext, idx);
}
if(strcmp(cmd, "/giveweapon", true)==0)
{
new otherplayerid, weaponid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
otherplayerid = strval(tmp);
if(!IsPlayerConnected(otherplayerid))
{
SendClientMessage(playerid, COLOR_ORANGE, "The player took off without a piece!");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
weaponid = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
if(weaponid < 1 && weaponid > 46)
{
SendClientMessage(playerid, COLOR_ORANGE, "Use a weaponid between 1 and 46!");
return 1;
}
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ORANGE, "Use /giveweapon [playerid] [weaponid] [amount]!");
return 1;
}
if(strlen(tmp)< 1)
{
SendClientMessage(playerid, COLOR_ORANGE, "Please enter a valid amount of bullets!");
return 1;
}
GivePlayerWeapon(otherplayerid, weaponid, amount);
SendClientMessage(otherplayerid, COLOR_ORANGE, "You've been given a weapon!");
SendClientMessage(playerid, COLOR_ORANGE, "You've successfully given a weapon to the player!");
return 1;
}