Display weapon id/name and ammo in /spec? - 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: Display weapon id/name and ammo in /spec? (
/showthread.php?tid=550323)
Display weapon id/name and ammo in /spec? -
MythicalMarauder - 12.12.2014
I have tried this, but it showed [] (blank)
I really need this urgently, and I have no clue how to do that. It would be better if I can get weapon name and not ID:
pawn Код:
new weapons[13][2];
new weapdata[MAX_PLAYERS];
for (new i = 0; i <= 12; i++)
{
weapdata[player] = GetPlayerWeaponData(player, i, weapons[i][0], weapons[i][1]);
}
format(tdstring,sizeof(tdstring),"[~r~%s~w~]", weapdata[player]);
Re: Display weapon id/name and ammo in /spec? -
Matess - 12.12.2014
Well GetPlayerWeaponData isn't returning any string so your code is wrong. All your info is stored in weapons.
So you should do something like this:
pawn Код:
format(tdstring,sizeof(tdstring),"[~r~WepID:%d, Ammo: %d~w~]", weapons[1][0],weapons[1][1]);//...
Re: Display weapon id/name and ammo in /spec? -
MythicalMarauder - 12.12.2014
Is it possible to get weapon name instead of ID?
Re: Display weapon id/name and ammo in /spec? -
Write - 12.12.2014
pawn Код:
stock wepName(weaponid)
{
new name[32];
GetWeaponName(weaponid, name, sizeof(name));
if(weaponid == 0) format(name, sizeof(name), "None");
return name;
}
format(tdstring,sizeof(tdstring),"[~r~WepID:%s, Ammo: %d~w~]", wepName(weapons[1][0]),weapons[1][1]);
Re: Display weapon id/name and ammo in /spec? -
MythicalMarauder - 12.12.2014
I think I've got another solution, but thank you guys!