Weapon Ammo Textdraw
#1

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.
Reply
#2

I have got an idea to do it,if you need it reply.
Reply
#3

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 :/
Reply
#4

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;
}
Reply
#5

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)