Jump to content

triggerClientEvent problem.


Eth

Recommended Posts

Posted

Hello there, so right now I am making a register/login window for my game using mysql , everything is working fine so far but for some reason triggerClientEvent doesn't want to be executed. here is the code:

OnPlayerConnect:

    dbQuery( CheckPlayerAccount,{playerNick}, database_connection, "SELECT `Password`,`ID`,`Banned` FROM `players` WHERE `Username`='"..playerNick.."'") 
  

CheckPlayerAccount:

  
function CheckPlayerAccount(qh,Player) 
     
    local result = dbPoll( qh, 0 ) 
    local thePlayer = getPlayerFromName ( Player ) 
    outputChatBox(Player) 
    outputDebugString("Player Name is "..Player) 
     
    if(result == true) then 
        triggerClientEvent ( thePlayer, "ShowLoginWindow", thePlayer,true) 
        triggerClientEvent ( thePlayer, "ShowRegisterWindow", thePlayer,true) 
    else 
        triggerClientEvent ( thePlayer, "ShowLoginWindow", thePlayer,true) 
        triggerClientEvent ( thePlayer, "ShowRegisterWindow", thePlayer,true) 
    end 
end 
  

Client Side:

  
  
function RegisterWindowShow(show) 
    outputDebugString("Dsd") 
    if(show == true) then  
        guiSetVisible(RegisterPanel.Window[0], true) 
        showCursor(true) 
    else 
        guiSetVisible(RegisterPanel.Window[0], false) 
    showCursor(false)  
    end 
end 
function LoginWindowShow(show) 
        outputDebugString("Dsd") 
    if(show == true) then  
        guiSetVisible(LoginPanel.Window[0], true) 
    showCursor(true) 
    else 
        guiSetVisible(LoginPanel.Window[0], false) 
    showCursor(false) 
    end 
end 
addEvent("ShowLoginWindow",true) 
addEvent("ShowRegisterWindow",true) 
addEventHandler("ShowLoginWindow",localPlayer,LoginWindowShow) 
addEventHandler("ShowRegisterWindow",localPlayer,RegisterWindowShow) 
  

now the debugstring shows my name just fine in the server sideso the code should be working, but somehow the debugstring in both ShowLoginWindow and ShowRegisterWindow aren't working, what could be the problem?

Posted

addEventHandler("ShowLoginWindow",root,LoginWindowShow) 
addEventHandler("ShowRegisterWindow",root,RegisterWindowShow) 
  

I changed it like you told me but still it doesn't show up

Posted

debugscript doesnt show any errors?

Even not in script restart?

I don't see any problem here o.O

Try to trigger the event one time to all (delete the first thePlayer) to test it.

Does it work?

Posted

Yes the debugscript doesn't show any type of erros and even when I try to restart the server.

I tried to delete the first thePlayer and it still doesn't work o.O

Posted

lol I finally fixed it, Instead of placing the onplayerconnect on the "onPlayerConnect" handler I put it "onPlayerJoin" lol

Posted

Oh sure, I let you try with deleting the first thePlayer, but not the second thePlayer -.-'

The player element doesnt exist on connect, so you can't use getPlayerFromName.

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