Dude' Posted March 5, 2014 Share Posted March 5, 2014 i saw fady's scripts which is hit script and i added onClientPlayerQuit to destroy the player blip when he quit but plz fix the script. this is server side function onquit () local name = getPlayerName ( source ) if hitBlip and isElement( hitBlip ) then destroyElement ( hitBlip ) outputChatBox ( name .. " has quit hit", root, 255,235,0 ) end end addEvent ( "onQuit", true ) addEventHandler ( "onQuit", getRootElement(), onquit ) this is client side function onQuitGame () triggerServerEvent ( "onQuit", localPlayer ) end addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame ) please anyone help me. Link to comment
Dude' Posted March 5, 2014 Author Share Posted March 5, 2014 local playername = getPlayerName ( thePlayer ) local hitBlip = createBlipAttachedTo ( thePlayer, 26 ) setElementData ( thePlayer, "hitBlip", hitBlip ) Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 Well, you can't save element to element data. Link to comment
Dude' Posted March 5, 2014 Author Share Posted March 5, 2014 but its working and saving elements Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 (edited) Try this blips = { } addEventHandler ( "onPlayerJoin", root, function () blips [ source ] = createBlipAttachedTo ( source, 26 ) end ) addEventHandler ( "onPlayerQuit", root, function () if ( blips and isElement ( blips [ source ] ) ) then destroyElement ( blips [ source ] ) end end ) Edited March 5, 2014 by Guest Link to comment
Dude' Posted March 5, 2014 Author Share Posted March 5, 2014 the problem is not with saving data the problem is with the onquit function and client function so can u please fix them ? Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 I edited my code. Serverside only. Link to comment
Dude' Posted March 5, 2014 Author Share Posted March 5, 2014 still the same addEventHandler ( "onPlayerQuit", root, function () local name = getPlayerName ( source ) if hitBlip and isElement ( hitBlip ) then destroyElement ( hitBlip ) outputChatBox ( name .. " has quit hit", root, 255,235,0 ) end end) i dont want to make it with tables, i want to make it with setElementData Link to comment
pa3ck Posted March 5, 2014 Share Posted March 5, 2014 If you create the blip server side, then this code should work and this is server side only ( you don't need client side ) : function onquit () local name = getPlayerName ( source ) local hitBlip = getElementData ( source, "hitBlip" ) if hitBlip and isElement( hitBlip ) then destroyElement ( hitBlip ) outputChatBox ( name .. " has quit hit", root, 255,235,0 ) end end addEventHandler ( "onPlayerQuit", getRootElement(), onquit ) If that doesn't work try to edit the part where you set element data with the userdata of the blip: local playername = getPlayerName ( thePlayer ) local hitBlip = createBlipAttachedTo ( thePlayer, 26 ) setElementData ( thePlayer, "hitBlip", tostring ( hitBlip ) ) 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