AGENT_STEELMEAT Posted April 28, 2011 Share Posted April 28, 2011 Hey all, was wondering of anyone had any idea on how to set up "ghostmode" feature for players (rather than vehicles). I tried setElementCollisionsEnabled, and wasn't getting the results I expected. In my last attempt below, I wanted to make a player a "ghost"" to other player when he enters the colshape, and make him normal again when he exits. Any ideas? --[[ SERVERSIDE - not many issues here. ]] local hospitalDoorCuboid = createColRectangle( 115.0, 268.0, 3.0, 3.0) --local hospitalDoorCuboid = createColCubiod( 115.0, 268.0, 1000.0, 3.0, 3.0, 4.0) --Functions to tell the client when it has entered or left the zombie missions area. function doorwayEnter(hitElement, matchingDimension) if getElementType( hitElement ) == "player" then local elementDimension = getElementDimension(hitElement) if (elementDimension == 1008 or elementDimension == 1009 or elementDimension == 1010 or elementDimension == 1011 or elementDimension == 1012) then triggerClientEvent(hitElement, "doorwayStatusChange", hitElement, true) end end end addEventHandler ( "onColShapeHit", hospitalDoorCuboid, doorwayEnter) function doorwayExit(hitElement, matchingDimension) if (getElementType ( hitElement )) == "player" then triggerClientEvent(hitElement, "doorwayStatusChange", hitElement, false) end end addEventHandler ( "onColShapeLeave", hospitalDoorCuboid, doorwayExit) --[[ CLIENTSIDE - Shitstorm begins here. ]] addEvent("doorwayStatusChange", true) --Triggered by above event via server, displays a notification when a player enters or exits the hospital doorway. local localPed = getLocalPlayer() function setElementCollisions(exitOrEnter) --TRUE for has entered, FALSE is exit. if exitOrEnter == true then setElementCollisionsEnabled ( localPed, false ) else if exitOrEnter == false then setElementCollisionsEnabled ( localPed, true ) end end end addEventHandler("doorwayStatusChange", getRootElement(), setElementCollisions) --addEventHandler("doorwayStatusChange", _local, setElementCollisions) Link to comment
Wojak Posted April 28, 2011 Share Posted April 28, 2011 to turn off collisions for a player you need to turn off colisions for every player except the player who hit the colshape clientside on a client who hit the colshape, and turn off the colisions for player who hit the colshape on every other client, this may be a little confusing, but read my post over and over until you understand it Link to comment
Castillo Posted April 28, 2011 Share Posted April 28, 2011 This function should do what you want, https://wiki.multitheftauto.com/wiki/Set ... idableWith i think? Link to comment
Wojak Posted April 28, 2011 Share Posted April 28, 2011 using setElementCollidableWith you must: on a client who hit the colshape- turn off colision between local player and all other players on other all clients- turn off colision between local player and the player who hit the colshape Link to comment
AGENT_STEELMEAT Posted April 28, 2011 Author Share Posted April 28, 2011 So, in other words, create a serverside setElementCollisionsEnabled / setElementCollidableWith? Got it. Almost worth waiting for 1.1 tho. Link to comment
Wojak Posted April 28, 2011 Share Posted April 28, 2011 oh, sorry for the unnecessary information, if you want to disable colisions within one colshape, you only need the "client who hit/leave the colshape part", that is: -turn off colisions for every player except the local player on a client who hit the colshape using setElementCollisionsEnabled or - turn off colision between local player and all other players using setElementCollidableWith whole thing may be clientside (onClientColshapeHit/leave) you need to play around with the other clients only if you for example want to disable using one colshape and enable using other... 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