dcmd_giveweapon(playerid, params[]) { if(adminlevel[playerid] == 0) { SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR,"You are not an Admin!"); return 1; } new giveplayerid, weaponID, ammo; if(!strlen(params)) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: /giveplayerweapon [id] [weaponid] [ammo]"); return 1; } giveplayerid = strval(params); if(!strlen(params)) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: /giveplayerweapon [id] [weaponid] [ammo]"); return 1; } weaponID = strval(params); if(!strlen(params)) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: /giveplayerweapon [id] [weaponid] [ammo]"); return 1; } ammo = strval(params); if(!IsPlayerConnected(giveplayerid)) { SendClientMessage(playerid, 0xFF0000AA, "That player is offline."); return 1; } if(weaponID < 1 || weaponID > 46) { SendClientMessage(playerid, 0xFF0000AA, "Use an correct weaponid! [0-46]"); return 1; } if(ammo < 1) { SendClientMessage(playerid, 0xFF0000AA, "You must give at least ammo 1."); return 1; } new string[256]; new string2[256]; GetPlayerName(giveplayerid, gname, sizeof (gname)); GivePlayerWeapon(giveplayerid, weaponID, ammo); format(string,sizeof(string),"Admin %s has given you weapon %d with %d ammo!",pname,weaponID,ammo); format(string2,sizeof(string2),"You have given weapon %d to player %s",weaponID,gname); SendClientMessage(giveplayerid, ADMINFS_MESSAGE_COLOR, string); SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, string2); return 1; }
new giveplayer,weapon; if(!sscanf(params,"ii",giveplayer,weapon))return SendClientMessage(...); GivePlayerWeapon(giveplayer,weapon,30);
Originally Posted by BlackFoX_UD_
strval has no Effect... use sscanf to extract all parameters
https://sampwiki.blast.hk/wiki/Sscanf Код:
new giveplayer,weapon; if(!sscanf(params,"ii",giveplayer,weapon))return SendClientMessage(...); GivePlayerWeapon(giveplayer,weapon,30); |
if(sscanf(params,"ii",giveplayer,weapon))return SendClientMessage(...);