Bilal135 Posted November 17, 2014 Share Posted November 17, 2014 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
Perfect Posted November 17, 2014 Share Posted November 17, 2014 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
Bilal135 Posted November 18, 2014 Author Share Posted November 18, 2014 You added one extra end, i removed it, it didn't show any errors. The script is still not working. Link to comment
Anubhav Posted November 18, 2014 Share Posted November 18, 2014 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
Bilal135 Posted November 18, 2014 Author Share Posted November 18, 2014 @Anubhav You also added one extra end, I removed it, got no errors in debug script, but this ain't working. Link to comment
xeon17 Posted November 18, 2014 Share Posted November 18, 2014 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
Perfect Posted November 18, 2014 Share Posted November 18, 2014 If it's a type in type or you don't put type, it take's it as server. What you meant by that ? Link to comment
xeon17 Posted November 18, 2014 Share Posted November 18, 2014 I think he mean, if type of script isn't definied in meta then the script will be server side. Link to comment
Perfect Posted November 18, 2014 Share Posted November 18, 2014 Well, I know that, that's why i ask if he put the script server side ( which consists of both type="server" or empty). So again, @Bilal did you put the script server side ? Link to comment
Bilal135 Posted November 19, 2014 Author Share Posted November 19, 2014 Well, I know that, that's why i ask if he put the script server side ( which consists of both type="server" or empty).So again, @Bilal did you put the script server side ? Yes.. Link to comment
Perfect Posted November 19, 2014 Share Posted November 19, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now