PDA

View Full Version : givegun


025Tadija
14/07/2015, 12:09 AM
CMD:givegun(playerid, params[])
{
new
userid,
ammo,
weapon;

if (pInfo[playerid][pAdmin] < 1)
return SendClientMessage(playerid, COLOR_RED, "[Server] Nemas dozvolu da koristis ovu komandu.");

if (sscanf(params, "uii", userid, weapon, ammo))
return SendClientMessage(playerid, -1, "Koristenje: /givegun [playerid / deo imena] [weapon id] [ammo]");

if (userid == INVALID_PLAYER_ID)
return SendClientMessage(playerid, COLOR_RED,"[Server] Igrac nije konektovan.");

GivePlayerWeapon(userid, weapon, ammo);

pInfo[userid][pWeapon] = weapon;
pInfo[userid][pAmmo] = ammo;



return 1;
}


That is my givegun command, and it works, but what I want here is to make

format like this, so if you can see there is "Deagle" but I don't know how to write it in code, so when I type weaponid 24 (that is Deagle) it shows in format Deagle instead of 24.
[AdmCmd] You have recieved 10 bullets of Deagle from Name_Surname
So if you translate it into code it would be like this

format(string, sizeof(string),"[AdmCmd] You have recieved %d bullets of %s from %s", ammo, DontKnowWhatToTypeHere, PlayerName(playerid);
SCM(.....);

I used ****** but I can't find good explanation for that.

SickAttack
14/07/2015, 12:14 AM
http://wiki.sa-mp.com/wiki/GetWeaponName

025Tadija
14/07/2015, 12:15 AM
http://wiki.sa-mp.com/wiki/GetWeaponName

I used it already but I guess on wrong way. I don't know how to throw that GetWeaponName into format...I guess you can help me with it?

KillerDVX
14/07/2015, 01:08 AM
Try this out :

CMD:givegun(playerid, params[])
{
new
userid,
ammo,
weapon
wname[24]
new string[128]
pname[24];

GetWeaponName(GetPlayerWeapon(playerid),wname,size of(wname));
GetPlayerName(playerid,pname,24);

if (pInfo[playerid][pAdmin] < 1)
return SendClientMessage(playerid, COLOR_RED, "[Server] Nemas dozvolu da koristis ovu komandu.");

if (sscanf(params, "uii", userid, weapon, ammo))
return SendClientMessage(playerid, -1, "Koristenje: /givegun [playerid / deo imena] [weapon id] [ammo]");

if (userid == INVALID_PLAYER_ID)
return SendClientMessage(playerid, COLOR_RED,"[Server] Igrac nije konektovan.");

format(string,sizeof(string),"You have received an %s from %s.",wname,playerid);
SendClientMessage(ID,COLOR_YELLOW,string);

GivePlayerWeapon(userid, weapon, ammo);

pInfo[userid][pWeapon] = weapon;
pInfo[userid][pAmmo] = ammo;

return 1;
}

025Tadija
14/07/2015, 12:34 PM
It works, thanks.