Weapon Ammo Textdraw - 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: Weapon Ammo Textdraw (
/showthread.php?tid=570624)
Weapon Ammo Textdraw -
De4dpOol - 12.04.2015
Hello, I am creating a textdraw of weapon ammo but I want it to show me ammo in "currently loaded - left" format.
For example: if I have a combat shotgun with 8 ammo, I want to show 7 - 1. Please give me a example to start with.
Re: Weapon Ammo Textdraw -
R0 - 12.04.2015
I have got an idea to do it,if you need it reply.
Re: Weapon Ammo Textdraw -
De4dpOol - 12.04.2015
Quote:
Originally Posted by R0
I have got an idea to do it,if you need it reply.
|
Yes, I need it. That's why I started this thread :/
Re: Weapon Ammo Textdraw -
R0 - 12.04.2015
Here is what you can use:
pawn Код:
new currentammo[MAX_PLAYERS];
new gunammo[MAX_PLAYERS];
public OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
{
if(newweapon == 27) // taking spas for example
{
currentammo[playerid] = 7;
gunammo[playerid] = GetPlayerAmmo(playerid)-currentammo[playerid];
}
return 1;
}
and:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(weaponid == 27)
{
currentammo[playerid] -= 1;
}
return 1;
}
Re: Weapon Ammo Textdraw -
Gammix - 12.04.2015
Just this is enough:
pawn Код:
public OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
{
new clipsize = 0, string[7], leftammo = 0;
switch(newweapon)//set the value according to the guns clipsizes!
{
case 27: clipsize = 7;//for spas12
}
if((GetPlayerAmmo(playerid) - clipsize) >= clipsize)//if the ammo is more than or equal that of clipsize
{
leftammo = (GetPlayerAmmo(playerid) - clipsize);
format(string, sizeof(string), "%d - %d", clipsize, leftammo);
}
else//if the ammo is less than clip size
{
format(string, sizeof(string), "%d", GetPlayerAmmo(playerid));
leftammo = 0;
}
PlayerTextDrawSetString(playerid, txt[playerid], string);
return 1;
}