SA-MP Forums Archive
Weapon skills - 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 skills (/showthread.php?tid=502804)



Weapon skills - Steve1312 - 26.03.2014

Hello all i dont know if this is the right section to post this but this is only question.
So i want to make skill system based on that how much bullets have been shot lets say for example if player shoots 100 bullets incrase hes skill level by 1 but if he shoots 100 bullets in amunations shoting range incrase skill by 2 o know how to do almoust everything for this except how to count how many bullet have been shoot.
Thanks for advice


Re: Weapon skills - Beckett - 26.03.2014

If you wanna count the bullets then OnPlayerKeyStateChange callback will do it.
1- Check if the player has pressed KEY_FIRE ( left click)
2- If he pressed it then check if he has a weapon in his hand (GetPlayerWeapon).
3- Set a variable, each KEY_FIRE pressed increase it (Note: a variable/array must be set for each weapon)
4- OnPlayerUpdate check if the variable is 100 = then SetPlayerWeaponSkill, ETC..
However there still might be a bug since if you keep your hand on Left Click it will shoot many bullets but it will be counted as 1 bullet, so..

EDIT:
Maybe you can set a variable if the player is kept pressing KEY_FIRE then keep increasing the variable OnPlayerUpdate.
Example:
Код:
new is_shooting[MAX_PLAYERS] = 0;

OnPlayerUpdate
{
	if(is_shooting[MAX_PLAYERS] = 1)
	{
	  //  Increase the Bullet Variable.
 	}
}



Re: Weapon skills - Steve1312 - 26.03.2014

yea that isnt going to work because everyone holds that button.
BTW this will be for RP gamemode that way i need this if it would be TDM i would just count player kills
Anyway any help will be apriciated
Thanks.