TheCapn Posted May 9, 2014 Share Posted May 9, 2014 (edited) Hello guys, I'm making a script that checks if the account is registered, and if it's not, it triggers a client-side function that draw a window with a text and a button that will kick the player as soon as he click on the button. However, when I try to trigger the client-side event on the server side, I have this error : ERROR: Server triggered clientside event onUnregAccount, but event is not added clientside Since I don't really know where the issue comes from, I'll give you the two complete code of my files : client and server side Server-side local handler = exports.exports:mysqlConnectHandler() function isAccountRegistered() local query = dbQuery( handler, "SELECT * FROM `users` WHERE `username` = ?", getPlayerName( source ) ) local result, num_affected_rows, last_insert_id = dbPoll( query, -1 ) if num_affected_rows > 0 then outputChatBox( "Compte existant.", source ) local spawnedPlayer = spawnPlayer( source, 0, 0, 0, 0, 66, 0, 0) if spawnedPlayer then fadeCamera( source, true ) setCameraTarget( source, source ) outputChatBox("Votre personnage a été initialisé avec succès. Bon jeu.", source ) end else triggerClientEvent(source, "onUnregAccount", getRootElement()) end end addEventHandler( "onPlayerJoin", getRootElement(), isAccountRegistered ) function unregHandler() kickPlayer( source ) end addEvent( "submitUnreg", true ) addEventHandler( "submitUnreg", root, unregHandler) Client-side -- La fenêtre suivante s'affiche dans le cas où le compte n'est pas enregistré dans la base de données function createUnregWindow() wdwUnreg = guiCreateWindow(0.39, 0.37, 0.22, 0.20, "COMPTE INEXISTANT", true) guiWindowSetSizable(wdwUnreg, false) msg = guiCreateLabel(0.07, 0.15, 0.85, 0.37, "Votre compte n'est pas enregistré dans notre\nbase de données. \nIl est nécessaire de s'inscrire sur notre site \npour pouvoir rejoindre le serveur.", true, wdwUnreg) guiSetFont(msg, "default-bold-small") website = guiCreateLabel(0.30, 0.56, 0.37, 0.12, "http://siteweb.com", true, wdwUnreg) validate = guiCreateButton(0.06, 0.77, 0.86, 0.17, "Valider", true, wdwUnreg) guiSetFont(validate, "default-bold-small") guiSetVisible(wdwUnreg, false) end addEvent("onUnregAccount", true) function unregAccount() createUnregWindow() if wdwUnreg ~= nil then guiSetVisible(wdwUnreg, true) else outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end showCursor(true) addEventHandler("onClientGUIClick", validate, clientSubmitUnreg, false) end addEventHandler("onUnregAccount", getResourceRootElement(getThisResource()), unregAccount ) function clientSubmitUnreg(button,state) if button == "left" and state == "up" then guiSetInputEnabled(false) guiSetVisible(wdwUnreg, false) showCursor(false) triggerServerEvent("submitUnreg", getRootElement()) end end Regards, TheCapn Edited May 9, 2014 by Guest Link to comment
TheCapn Posted May 9, 2014 Author Share Posted May 9, 2014 Just added, sorry, I miss clicked and submit instead of preview Link to comment
TheCapn Posted May 9, 2014 Author Share Posted May 9, 2014 Weel, seems to work by now ! Strange, indeed. Anyway : thanks Link to comment
Karuzo Posted May 9, 2014 Share Posted May 9, 2014 Yeah obviously the serversided file was loaded before the clientsided one Link to comment
Arnold-1 Posted May 9, 2014 Share Posted May 9, 2014 Yeah obviously the serversided file was loaded before the clientsided one oh, yeah, he must execute the function "onClientResourceStart" Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now