Jump to content

takeWeapon


Gravestone

Recommended Posts

My script enables god mode for the players who are not wanting to deathmatch. This code is supposed to take away weapons and allow the weapons which are in the allowed table. Need help in takeWeapon.

ocal allowed = { 
[10] = true, 
[11] = true, 
[12] = true, 
[13] = true, 
[14] = true, 
[15] = true, 
[44] = true, 
[45] = true, 
[46] = true, 
[43] = true, 
} 
  
  
function disableWeaponOnGodMod (prev,new) 
    if getElementData(localPlayer, "invincible") and not allowed[getPedWeapon(localPlayer)]  then 
       takeWeapon(localPlayer, not allowed[getPedWeapon(localPlayer)]) 
    end 
 end 
addEventHandler ( "onClientRender", root, disableWeaponOnGodMod ) 

Link to comment
local allowed = { 
[10] = true, 
[11] = true, 
[12] = true, 
[13] = true, 
[14] = true, 
[15] = true, 
[44] = true, 
[45] = true, 
[46] = true, 
[43] = true, 
} 
  
  
function disableWeaponOnGodMod (prev,new) 
    if getElementData(source, "invincible") and not allowed[getPedWeapon(source)]  then 
       takeWeapon(source, not allowed[getPedWeapon(source)]) 
    end 
 end 
addEventHandler ( "onPlayerWeaponSwitch", root, disableWeaponOnGodMod ) 

Why do you use onClientRender? By the handler arguments you are using, prev and new, it seems you want to use onPlayerWeaponSwitch.

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...