kieran Posted July 4, 2017 Share Posted July 4, 2017 Hey, so another broken script I made... Wow, a lot gone wrong today anyway.... Tried making a sort of script for players spawning so if say 10 players spawn at once they won't all be stuck in each other, here's the simple stuff I tried. function Ghost() setTimer(setElementCollisionsEnabled, 20000, 1, source, false) setTimer(setElementCollisionsEnabled, 1000, 1, source, true) end addEventHandler("onPlayerSpawn", getRootElement(), Ghost) Basically it freezes him is the problem maybe I have it server and not client side? Link to comment
kikos500 Posted July 4, 2017 Share Posted July 4, 2017 function Ghost() setElementCollisionsEnabled(source, true) setTimer(setElementCollisionsEnabled, 20000, 1, source, false) end addEventHandler("onClientPlayerSpawn", getRootElement(), Ghost) try this client side Link to comment
kieran Posted July 4, 2017 Author Share Posted July 4, 2017 (edited) it freezes him then lets him run..... I am trying to set a peds collisions, is that maybe the problem...? function Ghost() setElementCollisionsEnabled(source, false) setTimer(setElementCollisionsEnabled, 20000, 1, source, true) end addEventHandler("onClientPlayerSpawn", getRootElement(), Ghost) Changed your false and trues, basically he is frozen 20 secs, then he moves. Edit Okay, so this works for vehicles, but how can I get players? just a simple getElementPosition? addEventHandler("onClientVehicleEnter", getRootElement(), function () local v = getPedOccupiedVehicle(localPlayer) -- Get her's Vehicle ID for index,vehicle in ipairs(getElementsByType("vehicle")) do --LOOP through all Vehicles setElementCollidableWith(vehicle, v, false) -- Set the Collison off with the Other vehicles. end end ) Edited July 4, 2017 by kieran Link to comment
DNL291 Posted July 4, 2017 Share Posted July 4, 2017 Try this: addEvent("enableSpawnProtection", true) addEventHandler("enableSpawnProtection", root, function (bool) for _,v in pairs( getElementsByType("player") ) do setElementCollidableWith(v, source, not bool) end setTimer( function() for _,v in pairs( getElementsByType("player") ) do setElementCollidableWith(v, localPlayer, bool) end end, 10000, 1 ) end) addEventHandler( "onPlayerSpawn", root, function () triggerClientEvent(source, "enableSpawnProtection", source, true) end ) 1 Link to comment
kieran Posted July 4, 2017 Author Share Posted July 4, 2017 Thanks @DNL291 and @kikos500, it works! tried the script with vehicles DNL, I assume it would work with players too! 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