new id, weapon[32];
if(sscanf(params, "rs[32])) return SendClientMessage(playerid, red, "USAGE: /giveweapon [player name/id] [weapon name]");
GetPlayerID(name[]);
#include <a_samp> #include "../include/sscanf.inc" public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256], params[256]; sscanf(cmdtext, "ss", cmd, params); // Give a weapon to a player if(!strcmp(cmd, "/giveweapon", true)) // Give a weapon to a player { if(IsPlayerAdmin(playerid)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN {FFFF00}: You are not an admin."); new target; new weapon; new ammo; if(sscanf(params, "ddd", target, weapon, ammo)) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Usage: {FF4040}/GIVEGUN [player id] [weapon id] [ammo]{FFFF00}."); if(IsPlayerConnected(target)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEWEAPON{FFFF00}: Invalid player ID."); if(weapon < 1 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 44 || weapon == 45 || weapon == 47) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid weapon ID."); if(ammo <= 0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid ammo amount."); GivePlayerWeapon(target,weapon,ammo); new targetname[MAX_PLAYER_NAME]; GetPlayerName(target,targetname,sizeof(targetname)); new sendername[MAX_PLAYER_NAME]; GetPlayerName(playerid,sendername,sizeof(sendername)); new string[128]; if(target == playerid) { format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave yourself {0080FF}weapon %d{FFFF00}.", weapon); SendClientMessage(playerid,0xFFFFFFFF,string); return 1; } format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave {0080FF}weapon %d {FFFF00}to {FF40FF}%s{FFFF00}.",weapon,targetname); SendClientMessage(playerid,0xFFFFFFFF,string); format(string,sizeof(string),"{FF40FF}%s {FFFF00}gave you {0080FF}weapon %d{FFFF00}.", sendername, weapon); SendClientMessage(target,0xFFFFFFFF,string); return 1; } return 0; }
Here, have mine.
Код:
#include <a_samp> #include "../include/sscanf.inc" public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256], params[256]; sscanf(cmdtext, "ss", cmd, params); // Give a weapon to a player if(!strcmp(cmd, "/giveweapon", true)) // Give a weapon to a player { if(IsPlayerAdmin(playerid)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN {FFFF00}: You are not an admin."); new target; new weapon; new ammo; if(sscanf(params, "ddd", target, weapon, ammo)) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Usage: {FF4040}/GIVEGUN [player id] [weapon id] [ammo]{FFFF00}."); if(IsPlayerConnected(target)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEWEAPON{FFFF00}: Invalid player ID."); if(weapon < 1 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 44 || weapon == 45 || weapon == 47) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid weapon ID."); if(ammo <= 0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid ammo amount."); GivePlayerWeapon(target,weapon,ammo); new targetname[MAX_PLAYER_NAME]; GetPlayerName(target,targetname,sizeof(targetname)); new sendername[MAX_PLAYER_NAME]; GetPlayerName(playerid,sendername,sizeof(sendername)); new string[128]; if(target == playerid) { format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave yourself {0080FF}weapon %d{FFFF00}.", weapon); SendClientMessage(playerid,0xFFFFFFFF,string); return 1; } format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave {0080FF}weapon %d {FFFF00}to {FF40FF}%s{FFFF00}.",weapon,targetname); SendClientMessage(playerid,0xFFFFFFFF,string); format(string,sizeof(string),"{FF40FF}%s {FFFF00}gave you {0080FF}weapon %d{FFFF00}.", sendername, weapon); SendClientMessage(target,0xFFFFFFFF,string); return 1; } return 0; } |