checking if spray can is used?
#1

Hello all i have a gamemode i develop but im stuck with something.

I made players like they can only have 3 items on themselves at most. like Weaponslot1 weaponslot2 and weaponslot3.

When someone gets parachute, it occupies SGUN slot but here is the thing.
when someone uses it, it seems ammo goes down but not scriptwise because i am using OnPlayerWeaponShot like:
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	new GunID=GetPlayerWeapon(playerid);
	if(GunID==USER[playerid][GUN2])
	{
	    USER[playerid][AMMO2]--;
	}
	if(GunID==USER[playerid][GUN1])
	{
	    USER[playerid][AMMO1]--;
	}
	if(GunID==USER[playerid][SGUN])
	{
	    USER[playerid][SGUNAMMO]--;
	}
	wepcheat(playerid);
	return 1;
}
Also its same for parachute andsome other weapon types player can have too.

anyone has any idea?
Reply
#2

There's no reason for a new variable when weaponid is right there. Parachutes don't really use ammo so what're you referring to? IIRC, they go away when you land.
Reply
#3

i have a spraycan it has 100ammo(like it shows 100 over weapon icon on right up corner.). When i use spray, USER[playerid][SGUNAMMO] is still showing 100. but on top right corner spraycan is used. Also i want to check if parachute is used so its ammo value(actually how many he has value) will go down, so if its 0 i will remove it from player and also i cant remove it from player when he opens the parachute too. I hope you get me
Reply
#4

I'd start up a timer, and check if the player is pressing the attack button while holding a spray can, if so, decrease the spray can's ammo script-wisely USER[playerid][SGUNAMMO]--
Reply
#5

makes sense didnt think about that. Thank you so much. Still doesnt help me with parachutes tho. Is there a way i can block to give player a parachute when player leaves an aircraft in midair? aside from onplayerstatechange i mean.

Also what are you going to do if player uses "e,q,or middle mouse wheel" to change weapons while still pressing KEY_FIRE?
Reply
#6

Quote:
Originally Posted by grymtn
Посмотреть сообщение
Also i want to check if parachute is used so its ammo value(actually how many he has value) will go down, so if its 0 i will remove it from player and also i cant remove it
You don't need to remove it because when you get out from a plane you get a free parachute, when you open it and you land it gets removed automatically.
Reply
#7

yeah but its scriptwise there if they get the parachute before they got in to plane. ever thoughtabout that? and if they press key fire in mid air antiweaponcheat will get in process and player will have 1 weaponitem on them(parachute) and they still dont have it scriptwise. still its a lose because he will get ban from having nonscriptwise item.

And evenmore they can even just get the plane lower to ground and jump and get parachute and survive without opening them. Theres that too.
Reply
#8

Quote:
Originally Posted by grymtn
Посмотреть сообщение
Also what are you going to do if player uses "e,q,or middle mouse wheel" to change weapons while still pressing KEY_FIRE?
That's when checking if the player is equipping a spray can or not comes into play.
Reply
#9

Man you are amazing! Giving me awesome ideas. But still i did a full check through already like if
Код:
oldkeys==keyfire
{
    ///loopthru all weapons and if one guns id is ==SGUN make SGUNAMMO=loopedgunsammo of SGUN
}
Reply
#10

Quote:
Originally Posted by grymtn
Посмотреть сообщение
Man you are amazing! Giving me awesome ideas. But still i did a full check through already like if
Код:
oldkeys==keyfire
{
    ///loopthru all weapons and if one guns id is ==SGUN make SGUNAMMO=loopedgunsammo of SGUN
}
just something simplistic,
PHP код:
if(((newkeys & (KEY_FIRE)) == (KEY_FIRE)) && GetPlayerWeapon(playerid) == WEAPON_SPRAYCAN
Reply
#11

Yeah i get you but still it just does when keypress only happens on first press if im not wrong. As i said i want to do that "--" part when key is released and even if they just switch weapons thru my loop will still be going on to do its job no matter when the key is released. But if i were to be sure they wont be doing gun scrolls, i would use your other posts methods. I dont like to use loops myself, but this is the only clear answer to me right now.

"Explanation is clearly for purposes of someone who can seach on internet and see this post. Im sure you already got me way before lol"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)