Jump to content

Problem with client events


Recommended Posts

Hello everybody,

Here i'm again!

In my client side scripts i made 2 event:

addEvent("onStartSelection", true) 
addEventHandler("onStartSelection", getRootElement(), class_start) 
addEvent("onRegisterStart", true) 
addEventHandler("onRegisterStart", getRootElement(), toggleRegister) 

The event "onRegisterStart" will be called up when a player joins the server, it need to popup the registration window. But if i join at the first time, and i be not registered, it will give an error "Event onRegisterStart is not created."

I also added a bind key (F5) when i press it it will popup the register window, if i fill everything in, and register my self (everything ok) it should call onStartSelection event but it gives the same error :(

If i rejoin it works fine that, but i want that it works when i first join the server.

Link to comment

F5 was bound in the client script. But deleted it!

I just found the best solution for this problem:

Client side code:

function clientResStart() 
    triggerServerEvent("clientResourceStart", getRootElement(), getLocalPlayer()) 
end 
  
addEventHandler("onClientResourceStart", getRootElement(), clientResStart) 
  

Simple and small and works like how it need to work :P

Server side code:

function clientResStart(player) 
    if checkAccount(player) then 
        -- Show login window 
        triggerClientEvent("onLoginAccount", getRootElement()) 
    else 
        -- outputChatBox("#FF0000It look's like you are not registered, please register your self!", source, 255, 255, 255, true) 
        triggerClientEvent("onRegisterStart", getRootElement()) 
    end 
end 
  
addEvent("clientResourceStart", true) 
addEventHandler("clientResourceStart", getRootElement(), clientResStart) 

That is perfect solution for what i want, and now I HAVE IT!!!

Thanks to you all for the help, reply's to you.

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