Jump to content

[HELP] Zombie Vaccination.


Bilal135

Recommended Posts

As you may know that I've released the first version of Zombie Apocalypse Gamemode, so I decided that there should be some vaccination against zombies so players can get some type of godmode on marker hit. I'm not getting any error in debugscript or console.

My Code:

local theMarker = createMarker(-292.40191650391, 1170.1153564453, 20.00,"cylinder",1.3, 255, 255, 255) 
addEventHandler( "onMarkerHit",theMarker, 
function (Player,mD) 
    if getElementType (Player) == "player" and mD then 
if isPedInVehicle (Player) then 
return false 
end 
    setElementData(Player, "invincible", true) 
    outputChatBox("You're Now Vaccinated Against Zombies!", Player)     
end 
end) 
  
function onWasted(Player) 
         if getElementData(Player, "invincible", true) then 
         setElementData(Player, "invincible", false) 
end 
end 
addEventHandler("onPlayerWasted", root, onWasted) 
addEventHandler("onPlayerSpawn", root, onWasted) 

I've tried this too in the code but it doesnt work too...

if getElementData(Player, "invincible", false) then 
    setElementData(Player, "invincible", true) -- Near line 9 & 10 in upper code 

Please can anybody tell me what I'm doing wrong?

Link to comment

Put it server-side in meta, if you already didn't.

Then try this code:-

local theMarker = createMarker(-292.40191650391, 1170.1153564453, 20.00,"cylinder",1.3, 255, 255, 255) 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "invincible", false) 
end 
  
function VaccineMeh(Player,mD) 
    if (getElementType (Player) == "player") and mD then 
        if isPedInVehicle (Player) then 
            return false 
        end 
            setElementData(Player, "invincible", true) 
            outputChatBox("You're Now Vaccinated Against Zombies!", Player)   
        end 
    end 
end 
  
function onWasted(Player) 
    if getElementData(Player, "invincible", true) then 
         setElementData(Player, "invincible", false) 
    end 
end 
  
addEventHandler( "onMarkerHit", theMarker, VaccineMeh) 
addEventHandler("onPlayerWasted", root, onWasted) 
addEventHandler("onPlayerSpawn", root, onWasted) 

I just put script in order as some people STRICTLY do.

And added a for-loop.

Link to comment
Put it server-side in meta, if you already didn't.

Then try this code:-

local theMarker = createMarker(-292.40191650391, 1170.1153564453, 20.00,"cylinder",1.3, 255, 255, 255) 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "invincible", false) 
end 
  
function VaccineMeh(Player,mD) 
    if (getElementType (Player) == "player") and mD then 
        if isPedInVehicle (Player) then 
            return false 
        end 
            setElementData(Player, "invincible", true) 
            outputChatBox("You're Now Vaccinated Against Zombies!", Player)   
        end 
    end 
end 
  
function onWasted(Player) 
    if getElementData(Player, "invincible", true) then 
         setElementData(Player, "invincible", false) 
    end 
end 
  
addEventHandler( "onMarkerHit", theMarker, VaccineMeh) 
addEventHandler("onPlayerWasted", root, onWasted) 
addEventHandler("onPlayerSpawn", root, onWasted) 

I just put script in order as some people STRICTLY do.

And added a for-loop.

If it's a type in type or you don't put type, it take's it as server.

  
local theMarker = createMarker(-292.40191650391, 1170.1153564453, 20.00,"cylinder",1.3, 255, 255, 255) 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "invincible", false) 
end 
  
function VaccineMeh(Player,mD) 
    if (getElementType (Player) == "player") and mD then 
        if isPedInVehicle (Player) then 
            return false 
        end 
            setElementData(Player, "invincible", true) 
            outputChatBox("You're Now Vaccinated Against Zombies!", Player)   
        end 
    end 
end 
  
function onWasted(Player) 
    if getElementData(source, "invincible", true) then 
         setElementData(source, "invincible", false) 
    end 
end 
  
addEventHandler( "onMarkerHit", theMarker, VaccineMeh) 
addEventHandler("onPlayerWasted", root, onWasted) 
addEventHandler("onPlayerSpawn", root, onWasted) 
  
addEventHandler("onPlayerDamage", root, 
     function() 
          if getElementData(source, "invincible") then 
                cancelEvent() 
          end 
     end 
) 
  

Link to comment
  
local theMarker = createMarker(-292.40191650391, 1170.1153564453, 20.00,"cylinder",1.3, 255, 255, 255) 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "invincible", false) 
end 
  
function VaccineMeh(Player,mD) 
    if ( getElementType (Player) == "player") and mD then 
        if isPedInVehicle (Player) then return 
          outputChatBox("", Player)   
             end 
            setElementData(Player, "invincible", true) 
            outputChatBox("You're Now Vaccinated Against Zombies!", Player)   
        end 
    end 
end 
  
function onWasted() 
    if getElementData(source, "invincible", true) then 
         setElementData(source, "invincible", false) 
    end 
end 
  
addEventHandler( "onMarkerHit", theMarker, VaccineMeh) 
addEventHandler("onPlayerWasted", root, onWasted) 
addEventHandler("onPlayerSpawn", root, onWasted) 
  
addEventHandler("onPlayerDamage", root, 
     function() 
          if getElementData(source, "invincible") then 
                cancelEvent() 
          end) 
  

Link to comment

Try the following script and say what does it says in chat:-

local theMarker = createMarker(-292.40191650391, 1170.1153564453, 20.00,"cylinder",1.3, 255, 255, 255) 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "invincible", false) 
end 
  
function VaccineMeh(Player,mD) 
    if (getElementType (Player) == "player") and mD then 
        if isPedInVehicle (Player) then 
            outputChatBox("You are in a vehicle.", Player) 
        end 
            setElementData(Player, "invincible", true) 
            outputChatBox("You're Now Vaccinated Against Zombies!", Player)  
    else 
        outputChatBox("Element is not a player.", Player) 
    end 
end 
  
function onWasted(Player) 
    if getElementData(source, "invincible", true) then 
        setElementData(source, "invincible", false) 
        outputChatBox("Invincible data is set to 'false'.", Player) 
    else 
        outputChatBox("Invincible data is already set to 'false' or some other value.", Player) 
    end 
end 
  
addEventHandler( "onMarkerHit", theMarker, VaccineMeh) 
addEventHandler("onPlayerWasted", root, onWasted) 
addEventHandler("onPlayerSpawn", root, onWasted) 
  
addEventHandler("onPlayerDamage", root, 
     function() 
          if getElementData(source, "invincible") then 
                cancelEvent() 
                outputChatBox("Element data is set to 'invincible'.", source) 
          else 
                outputChatBox("Element data is not set to 'invincible'.", source) 
          end 
     end 
) 

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