Count bullets?
#1

How count bullets that player shots?
Reply
#2

Quote:
Originally Posted by whitedragon
Посмотреть сообщение
How count bullets that player shots?
With using timers & GetPlayerAmmo i think.
Reply
#3

You will need to keep a close track on each player, so I guess the first step would be to decide how to do that. You could do it through a timer that constantly calls a function, or perhaps better through a callback like OnPlayerUpdate.
Within that function/callback, you will have to track the player's weapon information: weapons held, amount of ammo currently held for each weapon. If you keep track of these in global variables, you will be able to compare their current information with the information stored at the previous check to see if they differ. You can then store the results wherever you like, most likely into a global variable that is keeping track of the amount of bullets shot.
Reply
#4

When i take timer.... it not help... when i shot it not work...
Reply
#5

Any Examples?
Reply
#6

Create a timer that stores GetPlayerWeaponData for all weapon slots for a player. An interval of 1000ms should be enough. At first put them in temporary variables, so you can compare the current ammo with the ones you stored before. The difference of the old and new ammo is the amount of fired bullets
GetPlayerAmmo and (i think) GetPlayerWeaponData does not update for every shot, but in a specific interval (about 500ms) so you do not have to use OnPlayerUpdate, a timer will be good enough.
Reply
#7

Test it first... before you right.... i have tried but i get it but i get 1 number behind that...
I have lag problem from server side
Reply
#8

I think you need these
pawn Код:
GetPlayerWeaponState(playerid);  // Returns state as integer
/*
WEAPONSTATE_UNKNOWN         -1
WEAPONSTATE_NO_BULLETS          0
WEAPONSTATE_LAST_BULLET         1
WEAPONSTATE_MORE_BULLETS        2
WEAPONSTATE_RELOADING           3*/
Reply
#9

I see that you not relays what seems to be my problem I make picture of my debug system

Like you see on the picture Variable have 1 number behind
PI[playerid][M4Ammo] = ammo;
Reply
#10

I guess you using GetPlayerWeaponData cos its have a big bug with ammo
Use GetPlayerAmmo(playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)