Jump to content

Ayuda, a que se debe este 'ERROR'?


JesusAliso

Recommended Posts

El script es para reiniciar el los 'scores' a 0. Funciona bien, pero me tira ese ERROR, pero no se cuando y cada 2,3,4 minutos. :S

ERROR: [gameplay]/GL/Rscript.lua:7: attempt to index global 'T' (a nil value)

Script:

root = getRootElement() 
  
addEventHandler("onPlayerLogin",root,function(_,account) 
    local kills = getAccountData(account,"T.Kills") 
    local deaths = getAccountData(account,"T.Deaths") 
    if not (deaths and kills) then return end 
    setElementData(source,"T.kills",T.kills) 
    setElementData(source,"T.deaths",T.deaths) 
    end 
) 
     
addEventHandler("onPlayerLogout",root,function(account) 
    local kills = getElementData(source,"T.Kills") 
    local deaths = getElementData(source,"T.Deaths") 
    setAccountData(account,"T.Kills",T.Kills) 
    setAccountData(account,"T.Deaths",T.Deaths) 
    setElementData(source,"T.Kills",0) 
    setElementData(source,"T.Deaths",0) 
    end 
) 
  
addEventHandler("onPlayerQuit",root,function() 
        if not isGuestAccount(getPlayerAccount(source)) then 
        local kills = getElementData(source,"T.Kills") 
        local deaths = getElementData(source,"T.Deaths") 
        setAccountData(getPlayerAccount(source),"T.Kills",T.kills) 
        setAccountData(getPlayerAccount(source),"T.Deaths",T.Deaths) 
        end 
    end 
) 
  
addCommandHandler("reset",function(source) 
    setElementData(source,"T.Kills",0) 
    setElementData(source,"T.Deaths",0) 
    outputChatBox("#ff0000*INFO* #ffffffTus scores han sido reiniciados a '0' !",source,255,0,0, true) 
    if not isGuestAccount(getPlayerAccount(source)) then 
    setAccountData(getPlayerAccount(source),"T.Kills",0) 
    setAccountData(getPlayerAccount(source),"T.Deaths",0) 
    end 
    end 
) 
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),function() 
        for k,v in ipairs(getElementsByType("player")) do 
        if not isGuestAccount(getPlayerAccount(v)) then 
        if (getAccountData(getPlayerAccount(v),"T.Kills") and getAccountData(getPlayerAccount(v),"T.Deaths")) then 
        setElementData(v,"T.Kills",getAccountData(getPlayerAccount(v),"T.Kills")) 
        setElementData(v,"T.Deaths",getAccountData(getPlayerAccount(v),"T.Deaths")) 
        end 
        end 
    end 
    end 
) 

Link to comment

No sé si te das cuenta pero es local kills no T.kills.

PD: Antes de publicar simplemente léelo bien. No lo digo a malas, a mi también me ha pasado, pero es un error pequeño.

local kills = getAccountData(account,"T.Kills") 

setElementData(source,"T.kills",T.kills) 

Cambia el tercer argumento de setElementData por kills, no T.kills

Link to comment
  • Recently Browsing   0 members

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