Jump to content

Como posso fazer para spawnar nos jogadores


Recommended Posts

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
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);

 

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...