Jump to content

[HELP] Greenzone godmode not working


ville

Recommended Posts

Hi, i have greenzone setted up right, but people can be killed from explosion and from long distance shooting.. Do i miss something.. Dont laugh at me i'm noob who tries to learn scripting

x, y, size = -1997, 239, 120 
local greenzone = createColRectangle ( -1997, 239, 110, 80 ) 
local greenzonemaparea = createRadarArea (-1997, 239, 110, 80, 0, 255, 0, 120) 
  
function greenzoneEnter ( thePlayer, matchingDimension ) 
if getElementType( thePlayer ) ~= "player" then return end 
toggleControl ( thePlayer, "fire", false ) 
toggleControl ( thePlayer, "next_weapon", false ) 
toggleControl ( thePlayer, "previous_weapon", false ) 
setPedWeaponSlot ( thePlayer, 0 ) 
toggleControl ( thePlayer, "aim_weapon", false ) 
toggleControl ( thePlayer, "vehicle_fire", false ) 
toggleControl ( thePlayer, "vehicle_secondary_fire", false ) 
end 
addEventHandler ( "onColShapeHit", greenzone, greenzoneEnter ) 
  
function greenzoneExit ( thePlayer, matchingDimension ) 
if getElementType( thePlayer ) ~= "player" then return end 
toggleControl ( thePlayer, "fire", true ) 
toggleControl ( thePlayer, "next_weapon", true ) 
toggleControl ( thePlayer, "previous_weapon", true ) 
toggleControl ( thePlayer, "aim_weapon", true ) 
toggleControl ( thePlayer, "vehicle_fire", true ) 
toggleControl ( thePlayer, "vehicle_secondary_fire", true ) 
end 
  
addEventHandler ( "onColShapeLeave", greenzone, greenzoneExit ) 

Link to comment

try this;

-- SERVER.LUA 
local greenzone = createColRectangle ( -1997, 239, 110, 80 ) 
local greenzonemaparea = createRadarArea (-1997, 239, 110, 80, 0, 255, 0, 120) 
  
function greenzoneEnter ( thePlayer, matchingDimension ) 
if getElementType( thePlayer ) ~= "player" then return end 
toggleControl ( thePlayer, "fire", false ) 
toggleControl ( thePlayer, "next_weapon", false ) 
toggleControl ( thePlayer, "previous_weapon", false ) 
setPedWeaponSlot ( thePlayer, 0 ) 
toggleControl ( thePlayer, "aim_weapon", false ) 
toggleControl ( thePlayer, "vehicle_fire", false ) 
toggleControl ( thePlayer, "vehicle_secondary_fire", false ) 
triggerClienEvent( thePlayer, "onPlayerGodmodeEnable", thePlayer ) 
end 
addEventHandler ( "onColShapeHit", greenzone, greenzoneEnter ) 
  
function greenzoneExit ( thePlayer, matchingDimension ) 
if getElementType( thePlayer ) ~= "player" then return end 
toggleControl ( thePlayer, "fire", true ) 
toggleControl ( thePlayer, "next_weapon", true ) 
toggleControl ( thePlayer, "previous_weapon", true ) 
toggleControl ( thePlayer, "aim_weapon", true ) 
toggleControl ( thePlayer, "vehicle_fire", true ) 
toggleControl ( thePlayer, "vehicle_secondary_fire", true ) 
triggerClienEvent( thePlayer, "onPlayerGodmodeDisable", thePlayer ) 
end 
addEventHandler ( "onColShapeLeave", greenzone, greenzoneExit ) 

-- CLIENT.LUA 
addEvent("onPlayerGodmodeEnable", true) 
addEvent("onPlayerGodmodeDisable", true) 
  
function setGodmode() 
   cancelEvent() 
end 
  
addEventHandler("onPlayerGodmodeEnable", getLocalPlayer(),  
function()  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), setGodmode) 
end) 
  
addEventHandler("onPlayerGodmodeDisable", getLocalPlayer(),  
function()  
removeEventHandler("onClientPlayerDamage", getLocalPlayer(), setGodmode) 
end) 

Link to comment

just use this as client side:

  
local greenzone = createColRectangle ( -1997, 239, 110, 80 ) 
local greenzonemaparea = createRadarArea (-1997, 239, 110, 80, 0, 255, 0, 120) 
addEventHandler('onClientPlayerDamage',root, 
function () 
if isElementWithinColshape(source,greenzone) then 
cancelEvent() 
end 
) 
  

you don't need anything else

Link to comment

My wrong, sorry. replace server-side to:

-- SERVER.LUA 
local greenzone = createColRectangle ( -1997, 239, 110, 80 ) 
local greenzonemaparea = createRadarArea (-1997, 239, 110, 80, 0, 255, 0, 120) 
  
function greenzoneEnter ( thePlayer, matchingDimension ) 
if getElementType( thePlayer ) ~= "player" then return end 
toggleControl ( thePlayer, "fire", false ) 
toggleControl ( thePlayer, "next_weapon", false ) 
toggleControl ( thePlayer, "previous_weapon", false ) 
setPedWeaponSlot ( thePlayer, 0 ) 
toggleControl ( thePlayer, "aim_weapon", false ) 
toggleControl ( thePlayer, "vehicle_fire", false ) 
toggleControl ( thePlayer, "vehicle_secondary_fire", false ) 
triggerClientEvent( thePlayer, "onPlayerGodmodeEnable", thePlayer ) 
end 
addEventHandler ( "onColShapeHit", greenzone, greenzoneEnter ) 
  
function greenzoneExit ( thePlayer, matchingDimension ) 
if getElementType( thePlayer ) ~= "player" then return end 
toggleControl ( thePlayer, "fire", true ) 
toggleControl ( thePlayer, "next_weapon", true ) 
toggleControl ( thePlayer, "previous_weapon", true ) 
toggleControl ( thePlayer, "aim_weapon", true ) 
toggleControl ( thePlayer, "vehicle_fire", true ) 
toggleControl ( thePlayer, "vehicle_secondary_fire", true ) 
triggerClientEvent( thePlayer, "onPlayerGodmodeDisable", thePlayer ) 
end 
addEventHandler ( "onColShapeLeave", greenzone, greenzoneExit ) 

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