JesusAliso Posted August 13, 2016 Share Posted August 13, 2016 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. 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
aka Blue Posted August 13, 2016 Share Posted August 13, 2016 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
JesusAliso Posted August 13, 2016 Author Share Posted August 13, 2016 jejeje gracias, disculpa la molestia no se mucho Link to comment
aka Blue Posted August 13, 2016 Share Posted August 13, 2016 No pasa nada, como te dije, no va a malas, simplemente antes de postear o lo que sea, échale un ojo y fíjate bien en el error. Ha pasado que he llegado a borrar posts por temas así, por una coma suelta por ahí y que me como la cabeza... . Link to comment
Recommended Posts