UTurn Posted April 27, 2014 Share Posted April 27, 2014 (edited) I wrote a spawn-protection script, it makes the player partially transparent so players know they're under spawn-protection. It also makes them unable to use weapons until they are no longer under spawn-protection, but it's missing one thing. I need to make it so that when a player is under spawn protection, there is no collision-detection when they intersect with another player. When two players spawn at the same hospital at once, they get stuck in each other, how can I prevent this? I've seen other servers that allow you move right out of players who are standing on the spawnpoint. I saw an event named 'onPlayerContact', it might be useful but I don't know how to continue from there. Would I handle this event, check if the 'currentElement' argument is another player, check if one of the players is spawn-protected and if so, cancel the event? Here is what I'm working with: hospitals_s.lua [server-Side] ... -- Spawns the player at the nearest hospital. function spawnAtHospital(thePlayer) -- Spawn-protect the player for 8 seconds. startSpawnProtection(thePlayer) -- Spawn at the nearest hospital. local xx,yy,zz,rr = findNearestHostpital(thePlayer) spawnPlayer(thePlayer, xx,yy,zz,rr) fadeCamera(thePlayer, true, 3.0) end -- Spawn-protect the player for 8 seconds. function startSpawnProtection(thePlayer) -- Spawn-protect the player for 8 seconds. setElementData(thePlayer, "spawnProtected", true) setElementAlpha(thePlayer, 150) setTimer( function() setElementData(thePlayer, "spawnProtected", false) setElementAlpha(thePlayer, 255) -- Load weapon and skin data. if (SAVE_DATA[thePlayer]) then setElementModel(thePlayer, SAVE_DATA[thePlayer].skin) if SAVE_DATA[thePlayer].weapons then for weapon, ammo in pairs (SAVE_DATA[thePlayer].weapons) do giveWeapon(thePlayer, weapon, ammo, true) end end end end, 8000, 1 ) end hospitals_c.lua [Client-Side] function onClientPlayerDamage(attacker, weapon, bodypart) if (getElementData(localPlayer, "spawnProtected") == true) then cancelEvent() end end addEventHandler("onClientPlayerDamage", localPlayer, onClientPlayerDamage) Edited April 27, 2014 by Guest Link to comment
Castillo Posted April 27, 2014 Share Posted April 27, 2014 Disable the collisions with the function: setElementCollidableWith Link to comment
UTurn Posted April 27, 2014 Author Share Posted April 27, 2014 Disable the collisions with the function: setElementCollidableWith Thanks alot man, I appreciate it. 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