CeKiT Posted June 15, 2015 Posted June 15, 2015 Hola que tal, tengo un problema con crear una variable global tengo esto: toptimes_server.lua function showCountry () cCountry = exports.admin:getPlayerCountry(source) end addEventHandler("onPlayerJoin", g_Root, showCountry) toptimes_client.lua dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/".. cCountry ..".png",tocolor(255,255,255,255)) no entiendo que es lo que estoy haciendo mal que en el debugsript me dice nil value.
Castillo Posted June 15, 2015 Posted June 15, 2015 Los archivos cliente y servidor no comparten las variables, tabla, etc. Tu variable "cCountry" esta definida solamente en el script "toptimes_server.lua".
Tomas Posted June 16, 2015 Posted June 16, 2015 Server-side: function showCountry () setElementData(source, "country", exports.admin:getPlayerCountry(source) ) end addEventHandler("onPlayerJoin", g_Root, showCountry) Client-side: if not cCountry then cCountry = getElementData(localPlayer, "country" ) end dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/".. cCountry ..".png",tocolor(255,255,255,255))
CeKiT Posted June 20, 2015 Author Posted June 20, 2015 Server-side: function showCountry () setElementData(source, "country", exports.admin:getPlayerCountry(source) ) end addEventHandler("onPlayerJoin", g_Root, showCountry) Client-side: if not cCountry then cCountry = getElementData(localPlayer, "country" ) end dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/".. cCountry ..".png",tocolor(255,255,255,255)) Gracias capo, me solucionaste la vida varias veces. Al igual que solid
Recommended Posts