Jump to content

A question about setTimer's


Xeno

Recommended Posts

Posted

This is worng

Correct

function start( player ) 
    if isElement( player ) then 
        crate = createObject( 2991,-1353,-185,14 ) 
        local team = getPlayerTeam( player ) 
        local object = createObject( 2991, -1353, -185, 14 ) 
        if team then 
            local police = getTeamFromName( "Police" ) 
            local criminals = getTeamFromName( "Criminals" ) 
            
            if team == police then 
                outputChatBox( "You're a police officer.", player, 0, 255, 0 ) 
            elseif team == criminal then 
                outputChatBox( "You're a criminal.", player, 0, 255, 0 ) 
            end 
        end 
    end     
end 
  
addEventHandler("onResourceStart", resourceRoot,  
    function( resource ) 
        setTimer( 
            function ( ) 
                local players = getElementsByType( "player" ) 
                for _, player in pairs( players ) do 
                    start( player ) 
                end 
            end 
        , 7500, 
        1) 
    end 
)    

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

assuming it's clientside.. 'player' is not defined when the resource starts, you can only use 'localPlayer', BUT there is no reason why you would pass the localPlayer with a timer, since it exists everywhere in the script and can be used at all times

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