givegun - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: givegun (
/showthread.php?tid=581574)
givegun -
025Tadija - 14.07.2015
PHP код:
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.
Re: givegun -
SickAttack - 14.07.2015
https://sampwiki.blast.hk/wiki/GetWeaponName
Re: givegun -
025Tadija - 14.07.2015
Quote:
Originally Posted by SickAttack
|
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?
Re : givegun -
KillerDVX - 14.07.2015
Try this out :
PHP код:
CMD:givegun(playerid, params[])
{
new
userid,
ammo,
weapon
wname[24]
new string[128]
pname[24];
GetWeaponName(GetPlayerWeapon(playerid),wname,sizeof(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;
}
Re: givegun -
025Tadija - 14.07.2015
It works, thanks.