Jump to content

Necesito ayuda con elementData


depato123

Recommended Posts

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
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 by Guest
Link to comment

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

Copia ahora el script denuevo

Link to comment
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 by Guest
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...