H5N1 Posted July 8, 2011 Share Posted July 8, 2011 Hello. How can I set player ghost mode and vehicle alpha CLIENTSIDE? It's possibly to make it server-sidely by setElementData, but it must be set clientsidely. Link to comment
BinSlayer1 Posted July 8, 2011 Share Posted July 8, 2011 setElementAlpha() --alpha setElementCollisionsEnabled() --gm setElementCollidableWith() --still gm, i suggest you use this one but every respawn, race will set the default values back on So your script should re-run everytime race tries to force its values. Test it out a lot and figure out a way Link to comment
H5N1 Posted July 8, 2011 Author Share Posted July 8, 2011 I wanted to skip it (your idea), but now I thing it's the only way to do this. Thx Link to comment
H5N1 Posted July 8, 2011 Author Share Posted July 8, 2011 How function setElementCollidableWith () works? Can someone show me example? Link to comment
CHC Posted July 8, 2011 Share Posted July 8, 2011 H5N1 said: How function setElementCollidableWith () works? Can someone show me example? This function can be used to set an element to collide with another element. An element with collisions disabled does not interact physically with the other element. ( from wiki https://wiki.multitheftauto.com/wiki/Set ... idableWith ) and example(client-side): function setCol() local x,y,z = getElementPosition(getLocalPlayer()) someped = createPed(0,x,y,z,120) setElementCollidableWith(source,someped,false) end addEventHandler("onClientResourceStart", getRootElement(), setCol) i not tested it Link to comment
H5N1 Posted July 8, 2011 Author Share Posted July 8, 2011 Thx, I will test it. Omg, its crazy o0. When I turn off GM and again ON I dont have gravity! client local playersWithCollisions = {} local ghostState = true local localPlayer = getLocalPlayer() function toogleGhost () if ghostState == true then -- wlaczamy kolizje ghostState = false triggerServerEvent ("onGhostStateChange", localPlayer, false) elseif ghostState == false then -- wylaczamy kolizje. ghostState = true triggerServerEvent ("onGhostStateChange", localPlayer, true) local players = getElementsByType ("player") for k,v in ipairs(players) do local veh = getPedOccupiedVehicle (v) setElementAlpha (veh, 120) setElementAlpha (v, 120) --setElementCollisionsEnabled (v, false) --setElementCollisionsEnabled (veh, false) if setElementCollidableWith (localPlayer, veh, false) then outputChatBox ("nie bedzie kolidowac") end setElementCollidableWith (localPlayer, v, false) end end end addCommandHandler ("ghost", toogleGhost) bindKey ("F3", "up", "ghost") function onGMChange ( playersTable, playerWithoutGM, state ) if ghostState == false then playersWithCollisions = playersTable if state == true then local veh = getPedOccupiedVehicle (playerWithoutGM) setElementAlpha (veh, 120) setElementAlpha (playerWithoutGM, 120) --setElementCollisionsEnabled (veh, false) --setElementCollisionsEnabled (playerWithoutGM, false) if setElementCollidableWith (localPlayer, veh, false) then outputChatBox ("nie bedzie kolidowac") end setElementCollidableWith (localPlayer, playerWithoutGM, false) elseif state == false then for k,v in ipairs(playersTable) do local veh = getPedOccupiedVehicle (v) setElementAlpha (veh, 255) setElementAlpha (v, 255) --setElementCollisionsEnabled (veh, true) --setElementCollisionsEnabled (v, true) if setElementCollidableWith (localPlayer, veh, true) then outputChatBox ("bedzie kolidowac") end setElementCollidableWith (localPlayer, v, true) end end end end addEvent( "onGhostStateChange", true ) addEventHandler( "onGhostStateChange", getRootElement(), onGMChange ) server local playersWithCollisions = {} function onGMChange ( state ) if state == true then for k,v in ipairs (playersWithCollisions) do if isElement(v) then if v == source then table.remove (playersWithCollisions, k) end else table.remove (playersWithCollisions, k) end end triggerClientEvent ( "onGhostStateChange", getRootElement(), playersWithCollisions, source ) end if state == false then table.insert (playersWithCollisions, 1, source) triggerClientEvent ( "onGhostStateChange", getRootElement(), playersWithCollisions, source, state ) end end addEvent( "onGhostStateChange", true ) addEventHandler( "onGhostStateChange", getRootElement(), onGMChange ) edit - fixed. But collisions still doesnt work. My vehicle alpha changes but collisions not. I dont have errors. 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