Jump to content

Help please


ELmarcoS.

Recommended Posts

Guest Guest4401

A fun map for race gamemode, right? If so, then you mustn't use getRandomPlayer because he might be dead, and isPlayerAlive also doesn't work in such a case. Try adding this as a server side script in your map.

function _getAlivePlayers() 
    local t = {} 
    for i,v in ipairs(getElementsByType'player') do 
        if getElementData(v,"state")  == "alive" then 
            table.insert(t,v) 
        end 
    end 
    if #t ~= 0 then 
        return t 
    end 
    return false 
end 
  
addEvent("onRaceStateChanging",true) 
addEventHandler("onRaceStateChanging",root, 
    function(n,o) 
        if o == "GridCountdown" and n == "Running" then 
            outputChatBox("Someone will get a rhino in 2 minutes",root) 
            setTimer( 
                function() 
                    local p = _getAlivePlayers() 
                    if p then 
                        local p = p[math.random(#p)] 
                        local v = getPedOccupiedVehicle(p) 
                        if v then 
                            setElementModel(v,432) 
                        end 
                    end 
                end,120000,1 
            ) 
        end 
    end 
) 

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...