Jump to content

Stealth - Spec


CeKiT

Recommended Posts

Ejemplo de la Wiki:

g_Players = getElementsByType("player")        -- get a list of all players in the server 
for i,aPlayer in ipairs(g_Players) do          -- find out what index the local player has in the list 
    if aPlayer == getLocalPlayer() then 
        g_CurrentSpectated = i 
        break 
    end 
end 
  
function spectatePrevious()                    -- decrement the spectate index and spectate the corresponding player 
     if g_CurrentSpectated == 1 then 
         g_CurrentSpectated = #g_Players 
     else 
         g_CurrentSpectated = g_CurrentSpectated - 1 
     end 
    setCameraTarget(g_Players[g_CurrentSpectated]) 
end 
  
function spectateNext()                        -- increment the spectate index and spectate the corresponding player 
     if g_CurrentSpectated == #g_Players then 
         g_CurrentSpectated = 1 
     else 
         g_CurrentSpectated = g_CurrentSpectated + 1 
     end 
    setCameraTarget(g_Players[g_CurrentSpectated]) 
end 
  
-- Bind above functions to arrow keys 
bindKey("arrow_l", "down", spectatePrevious) 
bindKey("arrow_r", "down", spectateNext) 

Y para lo que quieres, nose si funcione

en la primera linea

en vez de

g_Players = getElementsByType("player")  

usa

g_Players = getAlivePlayers () 

y deberas editarlo con el evento onPlayerWasted

Link to comment

Por lo visto es esto:

function spectateNext (source) -- THIS IS THE FUNCTION USED TO SWICH WHO IS BEING SPECTATED BY PRESSING R 
    if playingaround == 1 then  -- IF A ROUND IS IN PROGRESS 
        if ( isPedDead ( source ) ) then --IF THE PLAYER IS DEAD 
            local specPlayer = getPlayerSpectatee[source] -- gets the spectatee player 
            if not specPlayer then  
                specPlayer = 1  
                spectators[source] = true 
            end 
            local deadplayerTeam = getPlayerTeam(source) 
            local playersTable = getPlayersInTeam ( deadplayerTeam ) 
            playersTable = filterPlayersTable ( playersTable ) 
            -- 
            local playerCount = #playersTable 
            if playerCount == 0 then 
                outputSpectateMessage("No hay nadie para mirar.",source) -- IF ITS JUST THE 1 PLAYER, SPECTATING IS IMPOSSIBLE 
            else 
                specPlayer = specPlayer+1 
                while isPedDead ( playersTable[specPlayer] ) do 
                    specPlayer = specPlayer+1 
                end 
                if specPlayer > playerCount then 
                    specPlayer = 1 
                end 
                setCameraMode ( source, "player" )     
                setCameraTarget ( source, playersTable[specPlayer] ) 
                outputSpectateMessage("Esta viendo a "..getPlayerName(playersTable[specPlayer]),source) 
                getPlayerSpectatee[source] = specPlayer 
            end 
        end 
    end 
end 
  
function outputSpectateMessage(text,source) 
    triggerClientEvent(source,"showSpectateText",source,text,true) 
end 

Pero que debo editar

Link to comment
  • Recently Browsing   0 members

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