Jump to content

Weapon Ammo


itHyperoX

Recommended Posts

HeyGuys. 

 

I'm trying to make a script, which is very simple.

Example:

If player only have 1 ammo in his weapon , he can't shoot the last ammo ..

 

 

gMe = getLocalPlayer() 
  

addEventHandler('onClientPlayerWeaponSwitch',gMe,function(prevSlot,currSlot) 
    if(getPedTotalAmmo(prevSlot) == 1) then 
        toggleControl('fire',true) 
    end 
    if(getPedTotalAmmo(currSlot) == 1) then 
        toggleControl('fire',false) 
    end

 

Whats the problem?

Edited by TheMOG
forgot
Link to comment
local aNotToDisable = { [0]=true;[1]=true;[2]=true;[3]=true;[4]=true;[5]=true;
					[6]=true;[7]=true;[8]=true;[9]=true;[10]=true;[11]=true;[12]=true;[14]=true;
					[15]=true;[44]=true;[45]=true;[46]=true;[40]=true };

aDisableLastShoot = function (  )
	if aNotToDisable[getPedWeapon(source)] then return false end;
	if getPedTotalAmmo ( source ) == 1 then
			toggleControl( 'fire',false );
			outputChatBox ('You can not shoot now get more ammo!');
	else
			toggleControl( 'fire',true );
		end
	end
addEventHandler ( 'onClientPlayerWeaponSwitch',localPlayer,aDisableLastShoot );
addEventHandler ( 'onClientPlayerWeaponFire',localPlayer,aDisableLastShoot );

 

You can try with this .

@TheMOG

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...