Jump to content

onPlayerJoin problem


Piorun

Recommended Posts

Posted

Hi,

I want to ask you why if i have code:

addEventHandler("onPlayerJoin",root, 
    function() 
        triggerClientEvent(source,"playerJoined",root) 
    end 
) 

Someone who enters first time to server gots an error :

server triggered client side event, but event is not added client side
?
Posted

Client:

function playerJoined() 
    outputChatBox("welcome") 
end 
addEvent("playerJoined",true) 
addEventHandler("playerJoined",getRootElement(),playerJoined) 

Posted

You have to add the event in client file:

addEvent("name",true)

then to trigger the event:

addEventHandler("name",root,function)

Just like ADCX said..

Else ,your client side function is missed up..or got smthing wrong

Posted

I think he knows about adding the code to the client, it's all in the documentation of:

triggerClientEvent 

The problem however is that the client files haven't been downloaded when onPlayerJoin is triggered server side which means that the client code doesn't exist yet. A better solution would be to use the client sided event:

addEventHandler( "onClientResourceStart", getRootElement( ), 
    function ( startedRes ) 
        -- Client resources has finished downloading here. 
    end 
); 

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