therenex Posted March 25, 2008 Share Posted March 25, 2008 (edited) Hey guys! Well, i solved the crashing server problem. But now i have another prob: GUI changes (like hiding or showing windows) are synced for all the players, not for the local only, like it should be. D: ! local rootElement = getRootElement() function aRegister ( localPlayerName, username_register , password_register) if ( password_register ~= nil ) then if ( string.len ( password_register ) < 4 ) then outputChatBox ( "Tu clave de acceso debe tener al menos cuatro caracteres.", localPlayerName, 243, 0, 0 ) elseif ( addAccount ( username_register , password_register ) ) then local theAccount = getAccount ( username_register ) outputChatBox ( "Bienvenido a Drift City, '"..username_register..", Recuerda tu clave: '"..password_register.."'", localPlayerName, 109, 243, 0 ) outputChatBox ( "Por razones de seguridad, debes loguearte. Por favor logueate para continuar.", localPlayerName, 109, 243, 0 ) setAccountData ( theAccount, "dc.listo", 0 ) setAccountData ( theAccount, "dc.auto", 0 ) setAccountData ( theAccount, "dc.dinero", 20000 ) setAccountData ( theAccount, "dc.consecionario", 0 ) triggerClientEvent ( localPlayerName, "esconRegistro", getRootElement() ) elseif ( getAccount ( username_register ) ) then outputChatBox ( "Ya existe una cuenta con este nombre.", localPlayerName, 243, 0, 0 ) else outputChatBox ( "Error desconocido. Contacta a un administrador.", localPlayerName, 243, 0, 0 ) end else outputChatBox ( "Debes escribir una clave de acceso!", localPlayerName, 243, 0, 0 ) end end addEvent("onRegister", true) addEventHandler("onRegister", getRootElement(), aRegister) function aLogin (localplayername, username_login , password_login ) if ( password_login ~= nil ) then if ( string.len ( password_login ) < 4 ) then outputChatBox ( "Tu clave de acceso debe ser de mas de cuatro caracteres.", localplayername, 243, 0, 0) elseif (getAccount (username_login, password_login) ) then local theAccount = getAccount (username_login, password_login) if (theAccount) then local playerlogin = logIn (source, theAccount, password_login) if (playerlogin) then setElementData ( source, "username", username_login ) setElementData ( source, "password", password_login ) outputChatBox ( "Bienvenido a Drift City, "..username_login.."!", localplayername, 109, 243, 0 ) triggerClientEvent ( localplayername, "esconLogin", getRootElement() ) local dinero = getAccountData ( theAccount, "dc.dinero" ) setPlayerMoney ( source, dinero ) local status = getAccountData ( theAccount, "dc.listo" ) local consecionario = getAccountData ( theAccount, "dc.consecionario" ) local vehiculo = getAccountData ( theAccount, "dc.auto" ) if ( status == "0" ) then outputChatBox ( "Asi que eres nuevo por aqui, eh?", localplayername, 109, 243, 0 ) outputChatBox ( "Vas a necesitar un auspiciador para iniciarte.", localplayername, 109, 243, 0 ) outputChatBox ( "Elige un consecionario y comenzemos de una vez.", localplayername, 109, 243, 0 ) triggerClientEvent ( "abrirCons", getRootElement() ) elseif ( status == "1" ) then spawnPlayer ( source, 0, 0, 0 ) outputChatBox ( "Bienvenido de vuelta!", source, 109, 243, 0 ) local color = getAccountData ( theAccount, "dc.autocolor" ) if ( consecionario == "grotti" ) then local auto = createVehicle ( vehiculo, 554.3156, -1278.9517, 22.0508 ) setVehicleColor ( auto, color, color ) setVehicleDamageProof ( auto, true ) warpPlayerIntoVehicle ( source, auto ) elseif ( consecionario == "autobahn" ) then local auto = createVehicle ( vehiculo, 2135.6921, 1409.2946, 13.6231 ) setVehicleColor ( auto, color, color ) setVehicleDamageProof ( auto, true ) warpPlayerIntoVehicle ( source, auto ) elseif ( consecionario == "wang" ) then local auto = createVehicle ( vehiculo, -1933.7096, 271.9773, 45.6677 ) setVehicleColor ( auto, color, color ) setVehicleDamageProof ( auto, true ) warpPlayerIntoVehicle ( source, auto ) end end end end elseif (theAccount ~= getAccount (username_login, password_login) ) then outputChatBox ( "Contrasena erronea!", localplayername, 243, 0, 0 ) else outputChatBox ( "Esa cuenta no existe!", localplayername, 243, 0, 0 ) end else outputChatBox ( "Debes escribir usuario y contrasena!", localplayername, 243, 0, 0 ) end end addEvent("onLogin", true) addEventHandler("onLogin", getRootElement(), aLogin) --Funciones de Consecionarios function defGrotti ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.consecionario", "grotti" ) triggerClientEvent ( "esconCons", localPlayerName ) triggerClientEvent ( "abrirConsGrotti", localPlayerName ) end addEvent ( "definirGrotti", true ) addEventHandler ( "definirGrotti", getRootElement(), defGrotti ) function defAutobahn ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.consecionario", "autobahn" ) triggerClientEvent ( "esconCons", localPlayerName ) triggerClientEvent ( "abrirConsAutobahn", localPlayerName ) end addEvent ( "definirAutobahn", true ) addEventHandler ( "definirAutobahn", getRootElement(), defAutobahn ) function defWang ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.consecionario", "wang" ) triggerClientEvent ( "esconCons", localPlayerName ) triggerClientEvent ( "abrirConsWang", localPlayerName ) end addEvent ( "definirWang", true ) addEventHandler ( "definirWang", getRootElement(), defWang ) --Funciones de Vehículos --GROTTI --Sentinel function defGrottiSentinel ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 405 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirGrottiSentinel", true ) addEventHandler ( "definirGrottiSentinel", getRootElement(), defGrottiSentinel ) --Primo function defGrottiPrimo ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 547 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirGrottiPrimo", true ) addEventHandler ( "definirGrottiPrimo", getRootElement(), defGrottiPrimo ) --Elegant function defGrottiElegant ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 507 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirGrottiElegant", true ) addEventHandler ( "definirGrottiElegant", getRootElement(), defGrottiElegant ) --AUTOBAHN --Infernus function defAutobahnInfernus ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 411 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirAutobahnInfernus", true ) addEventHandler ( "definirAutobahnInfernus", getRootElement(), defAutobahnInfernus ) --Cheetah function defAutobahnCheetah ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 415 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirAutobahnCheetah", true ) addEventHandler ( "definirAutobahnCheetah", getRootElement(), defAutobahnCheetah ) --Banshee function defAutobahnBanshee ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 429 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirAutobahnBanshee", true ) addEventHandler ( "definirAutobahnBanshee", getRootElement(), defAutobahnBanshee ) --WANG --Jester function defWangJester ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 559 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirWangJester", true ) addEventHandler ( "definirWangJester", getRootElement(), defWangJester ) --Sultan function defWangSultan ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.auto", 560 ) setAccountData ( theAccount, "dc.listo", 1 ) local color = randInt ( 0, 125 ) setAccountData ( theAccount, "dc.autocolor", color ) triggerClientEvent ( "esconConsCualq", localPlayerName ) outputChatBox ( "Hemos terminado. Reconectate y logueate!", localPlayerName, 109, 243, 0 ) end addEvent ( "definirWangSultan", true ) addEventHandler ( "definirWangSultan", getRootElement(), defWangSultan ) --Elegy function defWangElegy ( localPlayerName ) local nombre = getElementData ( source, "username" ) local theAccount = getAccount ( nombre ) setAccountData Edited March 29, 2008 by Guest Link to comment
arc_ Posted March 25, 2008 Share Posted March 25, 2008 Hi, In your serverside dealer selection code, you are making a mistake. getAccount() expects the account name of the player, but you are passing it a player element. The function you are looking for is getClientAccount. Thanks to this topic the developers will be able to fix the crash however, so thanks for reporting it. Link to comment
therenex Posted March 27, 2008 Author Share Posted March 27, 2008 i have a new problem... can you help me? : D I'd updated the first post. Link to comment
arc_ Posted March 27, 2008 Share Posted March 27, 2008 That's a common mistake. You are not specifying the "trigger for" argument of triggerClientEvent, which causes it to default to the root element and trigger the event for all players. The solution is of course to specify the argument so the event only gets triggered for one player. See the documentation: triggerClientEvent. Good luck with your mode Link to comment
therenex Posted March 28, 2008 Author Share Posted March 28, 2008 (edited) Niiiiiiiice :B Thanks! ^^ This caused me a lot of headaches, because when someone clicked on a GUI element for another player, server crashed. Edited March 28, 2008 by Guest Link to comment
therenex Posted March 28, 2008 Author Share Posted March 28, 2008 i'm passing 'source' to the triggerFor argument, but still not working Link to comment
Mr.Hankey Posted March 28, 2008 Share Posted March 28, 2008 "source" is always related to the event that calls the function. for example if you use triggerClientEvent ("test", source) in a function that is bound to a "onMarkerHit" event "source" would be a marker element^^ just specifie a certain player element e.g: function defAutobahn ( localPlayer ) local nombre = getElementData ( localPlayer "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.consecionario", "autobahn" ) triggerClientEvent ( "esconCons", localPlayer ) triggerClientEvent ( "abrirConsAutobahn", localPlayer ) end addEvent ( "definirAutobahn", true ) addEventHandler ( "definirAutobahn", getRootElement(), defAutobahn ) and remember the function getLocalPlayer () returns a player element not the player name Link to comment
therenex Posted March 29, 2008 Author Share Posted March 29, 2008 this is very strange. im doing it just like you said, but still not working. damn it im going to get like the angry german kid i'd updated the code so you can see the changes i'd made thanks for all teh help (: Link to comment
arc_ Posted March 29, 2008 Share Posted March 29, 2008 function defAutobahn ( player ) local nombre = getElementData ( player, "username" ) local theAccount = getAccount ( nombre ) setAccountData ( theAccount, "dc.consecionario", "autobahn" ) triggerClientEvent ( player, "esconCons" ) -- triggerFor = player triggerClientEvent ( player, "abrirConsAutobahn" ) -- triggerFor = player end addEvent ( "definirAutobahn", true ) addEventHandler ( "definirAutobahn", getRootElement(), defAutobahn ) Although if you do triggerServerEvent("definirAutobahn", getLocalPlayer(), getLocalPlayer()), "source" should work just as well as "player" here. Link to comment
therenex Posted March 29, 2008 Author Share Posted March 29, 2008 the problem was in the login function. when i check "status", if 0 i trigger a client event and i didnt fix that event. 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