Bullet Count -
No Fear - 01.02.2012
Hi, is there anyway to count how many bullets did player(s) shoot?
Re: Bullet Count -
MP2 - 01.02.2012
Not exactly, but you could create an array of how many bullets are in a magazine for each weapon, then detect WEAPON_STATE_RELOADING or weapon switches.
https://sampwiki.blast.hk/wiki/GetPlayerWeaponState
I made this array a while ago:
pawn Код:
new weapon_capacity[] = { // 0-no ammo 1-any ammo else-min ammo
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
-1,
-1,
-1,
34,
17,
7,
1,
4,
7,
100,
30,
30,
50,
100,
1,
1,
1,
1,
50,
500,
1,
0,
500,
500,
36,
0,
0,
0
};
-1 means that weapon is invalid
0 means it doesn't have ammo i.e. a baseball bat
1 means it has 1 ammo, such as grenades or RPGs
anything above that is the magazine size.
NOTE: I think ammo will be different depending on skill, you'll have to check.
Re: Bullet Count -
2KY - 01.02.2012
Whipped this up in a few seconds. Not sure if it will work correctly, or even compile, but this should give you some sort of idea.
pawn Код:
#define KEY_AIM (128)
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(HOLDING(KEY_AIM)) && PRESSED(KEY_FIRE) || HOLDING(KEY_AIM) && HOLDING(KEY_FIRE))
{
if(GetPlayerWeapon(playerid) == 24)
{
//They shot their Desert Eagle.
}
}
return true;
}
Re: Bullet Count -
No Fear - 03.02.2012
Your idea don't work. But i made
pawn Код:
if((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
{
if(GetPlayerWeapon( playerid ) == 38 )
{
print("Key");
}
return true;
}
But it's counting only one time when i hold. I need to make it work, that it would count every bullet.
Re: Bullet Count - T0pAz - 03.02.2012
Quote:
Originally Posted by No Fear
Your idea don't work. But i made
pawn Код:
if((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) { if(GetPlayerWeapon( playerid ) == 38 ) { print("Key"); } return true; }
But it's counting only one time when i hold. I need to make it work, that it would count every bullet.
|
I don't think it will be achieved using GetPlayerKey because it will not be accurate.
Re: Bullet Count -
wups - 03.02.2012
Quote:
Originally Posted by No Fear
Your idea don't work. But i made
pawn Код:
if((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) { if(GetPlayerWeapon( playerid ) == 38 ) { print("Key"); } return true; }
But it's counting only one time when i hold. I need to make it work, that it would count every bullet.
|
Use onplayerupdate
pawn Код:
new PlayerAmmo[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
new ammo = GetPlayerAmmo(playerid);
if(ammo < PlayerAmmo[playerid])
{
new BulletsShot = (PlayerAmmo[playerid]-ammo);
}
PlayerAmmo[playerid]=ammo;
return 1;
}
This is just the idea, you might wanna check for the weapon etc.
Re: Bullet Count -
No Fear - 03.02.2012
i see, so maybe there is any other way?
Wups: thanks i''ll try
Re: Bullet Count -
No Fear - 03.02.2012
Sorry not working :/
Re: Bullet Count -
wups - 03.02.2012
Quote:
Originally Posted by No Fear
Sorry not working :/
|
What's not working? Show me your code.
Re: Bullet Count -
No Fear - 03.02.2012
It's the same as you given i printed it to show it's showing 2.... I just need a code that server could count how many bullets players shoot.
"Total bullets players shoot: 1300000000000000" like
something