FunZY Posted October 15, 2021 Share Posted October 15, 2021 Como posso fazer para esses markers spawnarem em todos os jogadores do servidor? Alguém pode me dar uma luz? setTimer (function() x, y, z = getElementPosition (source) frente = createMarker (x+1.2,y,z,"cylinder",1,255,255,255,255) tras = createMarker (x-1.2,y,z,"cylinder",1,255,255,255,255) direita = createMarker (x,y+1.2,z,"cylinder",1,255,255,255,255) esquerda = createMarker (x,y-1.2,z,"cylinder",1,255,255,255,255) if getElementData (source,"jogo") == "sim" then addEventHandler ("onMarkerHit",frente,matar) addEventHandler ("onMarkerHit",tras,matar) addEventHandler ("onMarkerHit",direita,matar) addEventHandler ("onMarkerHit",esquerda,matar) end end ,5000,5) Link to comment
_SAXI_ Posted October 16, 2021 Share Posted October 16, 2021 playerMarkers = {}; function onSpawn(x,y,z) -- reset table if(playerMarkers[source])then for i,m in pairs(playerMarkers)do if(m)then if(isElement(m))then destroyElement(m); end end end end playerMarkers[source] = nil; if(getElementData('jogo') == 'sim')then playerMarkers[source] = {}; local frente = createMarker (x+1.2,y,z,"cylinder",1,255,255,255,255); local tras = createMarker (x-1.2,y,z,"cylinder",1,255,255,255,255); local direita = createMarker (x,y+1.2,z,"cylinder",1,255,255,255,255); local esquerda = createMarker (x,y-1.2,z,"cylinder",1,255,255,255,255); playerMarkers[source] = {frente,tras,direita,esquerda}; addEventHandler ("onMarkerHit",frente,matar); addEventHandler ("onMarkerHit",tras,matar); addEventHandler ("onMarkerHit",direita,matar); addEventHandler ("onMarkerHit",esquerda,matar); end end addEventHandler('onPlayerSpawn',root,onSpawn); function matar(elem,dim) if(type(elem) == 'player') and (dim == getElementDimension(source))then if(playerMarkers[elem])then for _,m in pairs(playerMarkers[elem])do if(m == source)then killPed(source); end end end end end function muerteJogador() if(playerMarkers[source])then for i,m in pairs(playerMarkers)do if(isElement(m))then destroyElement(m); end end playerMarkers[source] = {}; end end addEventHandler('onPlayerWasted',root,muerteJogador); -- OPCIONAL -- addEventHandler('onResourceStart',resourceRoot,function() for _,j in pairs(getElementsByType('player'))do if(getElementData(j,'jogo') == 'sim')then local x,y,z = getElementPosition(j); playerMarkers[j] = {}; local frente = createMarker (x+1.2,y,z,"cylinder",1,255,255,255,255); local tras = createMarker (x-1.2,y,z,"cylinder",1,255,255,255,255); local direita = createMarker (x,y+1.2,z,"cylinder",1,255,255,255,255); local esquerda = createMarker (x,y-1.2,z,"cylinder",1,255,255,255,255); playerMarkers[j] = {frente,tras,direita,esquerda}; addEventHandler ("onMarkerHit",frente,matar); addEventHandler ("onMarkerHit",tras,matar); addEventHandler ("onMarkerHit",direita,matar); addEventHandler ("onMarkerHit",esquerda,matar); end end end); 1 Link to comment
FunZY Posted October 16, 2021 Author Share Posted October 16, 2021 Não entendi direito o script pode explicar melhor oq cada coisa faz? Se possivel 16 hours ago, _SAXI_ said: 16 hours ago, _SAXI_ said: playerMarkers pairs 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