depato123 Posted December 12, 2013 Share Posted December 12, 2013 Hola, tengo un problema con este script de licencias de conduccion: function givePlayerCarLicence () if not ( getElementData( source, "carLicence" ) ) then setElementData( source, "carLicence", true ) outputChatBox("**Otro Conductor en las Carreteras! "..getPlayerName(source).." Ha Pasado el Examen de Conducir**", root,155, 155, 0) end end addEvent("givePlayerCarLicence", true) addEventHandler("givePlayerCarLicence", root, givePlayerCarLicence) --- /licencias function elchat(player) if getElementData( player, "carLicence" ) then outputChatBox ( "-------------------- Licencias --------------------", player, 255, 193, 37 ) outputChatBox ( "Licencia de Autos: #00FF00Si", player, 255, 193, 37, true ) else outputChatBox ( "-------------------- Licencias --------------------", player, 255, 193, 37 ) outputChatBox ( "Licencia de Autos: #00FF00No", player, 255, 193, 37, true ) end end addCommandHandler( "licencias", elchat)` El problema es que cuando el usuario termina unas preguntas se le entrega una licencia, esta licencia es un setElementData y el problema es que no se guarda cuando el usuario se reconecta. cuando el usuario obtiene el ElementData pone el comando /licencias y le aparece si, pero luego reconecta y le aparece en /licencias no, osea que la pierde al reconectar. ¿Como puedo arreglar esto? Link to comment
MTA Team 0xCiBeR Posted December 12, 2013 MTA Team Share Posted December 12, 2013 (edited) function givePlayerCarLicence () if not ( getElementData( source, "carLicence" ) ) then setElementData( source, "carLicence", true ) outputChatBox("**Otro Conductor en las Carreteras! "..getPlayerName(source).." Ha Pasado el Examen de Conducir**", root,155, 155, 0) end end addEvent("givePlayerCarLicence", true) addEventHandler("givePlayerCarLicence", root, givePlayerCarLicence) --- /licencias function elchat(player) if getElementData( player, "carLicence" ) then outputChatBox ( "-------------------- Licencias --------------------", player, 255, 193, 37 ) outputChatBox ( "Licencia de Autos: #00FF00Si", player, 255, 193, 37, true ) else outputChatBox ( "-------------------- Licencias --------------------", player, 255, 193, 37 ) outputChatBox ( "Licencia de Autos: #00FF00No", player, 255, 193, 37, true ) end end addCommandHandler( "licencias", elchat) -- function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local lic = getElementData(source,"carLicence") if lic == true then setAccountData ( playeraccount, "carLicence", true ) end end end function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local lic = getAccountData(source,"carLicence") if lic == true then setElementData ( source, "carLicence", lic ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Edited December 12, 2013 by Guest Link to comment
depato123 Posted December 12, 2013 Author Share Posted December 12, 2013 Ahora cualquiera tiene la licencia, haya hecho la prueba de manejo o no intente cambiar eso ultimo por esto function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local lic = getAccountData(source,"carLicence") if ( lic) then if getElementData( source, "carLicence" ) then setElementData ( source, "carLicence", lic ) end end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Link to comment
MTA Team 0xCiBeR Posted December 12, 2013 MTA Team Share Posted December 12, 2013 Ahora cualquiera tiene la licencia, haya hecho la prueba de manejo o nointente cambiar eso ultimo por esto function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local lic = getAccountData(source,"carLicence") if ( lic) then if getElementData( source, "carLicence" ) then setElementData ( source, "carLicence", lic ) end end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Copia ahora el script denuevo Link to comment
depato123 Posted December 12, 2013 Author Share Posted December 12, 2013 Ahora el mismo problema de antes, cuando el usuario reconecta se pierde el ElementData D: Link to comment
Sasu Posted December 12, 2013 Share Posted December 12, 2013 (edited) function givePlayerCarLicence () if not ( getElementData( source, "carLicence" ) ) then setElementData( source, "carLicence", "true" ) outputChatBox("**Otro Conductor en las Carreteras! "..getPlayerName(source).." Ha Pasado el Examen de Conducir**", root,155, 155, 0) end end addEvent("givePlayerCarLicence", true) addEventHandler("givePlayerCarLicence", root, givePlayerCarLicence) --- /licencias function elchat(player) if getElementData( player, "carLicence" ) then outputChatBox ( "-------------------- Licencias --------------------", player, 255, 193, 37 ) outputChatBox ( "Licencia de Autos: #00FF00Si", player, 255, 193, 37, true ) else outputChatBox ( "-------------------- Licencias --------------------", player, 255, 193, 37 ) outputChatBox ( "Licencia de Autos: #00FF00No", player, 255, 193, 37, true ) end end addCommandHandler( "licencias", elchat) -- function onPlayerQuit (acc) local playeraccount if eventName == "onPlayerQuit" then playeraccount = getPlayerAccount ( source ) elseif eventName == "onPlayerLogout" then playeraccount = acc end if not isGuestAccount(playeraccount) then local lic = getElementData(source,"carLicence") if lic then setAccountData ( playeraccount, "carLicence", "true" ) end end end function onPlayerLogin ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local lic = getAccountData(source,"carLicence") if tostring(lic) == 'true' then setElementData ( source, "carLicence", lic ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Edited December 12, 2013 by Guest Link to comment
depato123 Posted December 13, 2013 Author Share Posted December 13, 2013 Intente con eso pero sigue sin guardar el elementData al desconectarse, luego intente arreglarlo pero ahora el script no funciona D: Link to comment
Recommended Posts