Lua - attempt to call global 'contains' (a nil value) -


i'm interesting, if know problem of code bellow. error:

''attempt call global 'contains' (a nil value)''

here code:

state1={10,11,20,21,22,23,24,30,31,32,33,34,35,36,37,38,39,40,45,46,47,48,49,50,51,69,72,73,74,85} state3={78} state4={1,2,3,4,5,6}  playerskin=initarray2(32,0) wepskin=initarray2(32,0)  function getplayerdata(id,d) if (d=="team")     if (player(id,"team")==1)         return "red"     end     if (player(id,"team")==2)         return "blu"     end end if (d=="class")     return string.lower(tf2.classes.name[tf2.classes.class[id]]) end end  function changeskin(id,w) if (contains(state1,w))     if (playerskin[id]~=0)         freeimage(playerskin[id])     end     playerskin[id]=image("gfx/tf2/skins/"..getplayerdata(id,"team").."   /"..getplayerdata(id,"class").."/"..getplayerdata(id,"team").."_"..getplayerdata(id,"class").."_1.png",1,0,200+id) end if (contains(state3,w))     if (playerskin[id]~=0)         freeimage(playerskin[id])     end     playerskin[id]=image("gfx/tf2/skins/"..getplayerdata(id,"team").."/"..getplayerdata(id,"class").."/"..getplayerdata(id,"team").."_"..getplayerdata(id,"class").."_3.png",1,0,200+id) end if (contains(state4,w))     if (playerskin[id]~=0)         freeimage(playerskin[id])     end     playerskin[id]=image("gfx/tf2/skins/"..getplayerdata(id,"team").."/"..getplayerdata(id,"class").."/"..getplayerdata(id,"team").."_"..getplayerdata(id,"class").."_4.png",1,0,200+id) end if (hat[id]~=0 , tf2.classes.hatunlock[id][tf2.classes.class[id]]~=0)     freeimage(hat[id])     hat[id]=image(crafts[tf2.classes.hatunlock[id] [tf2.classes.class[id]]].image,1,0,200+id) end end  --[[function changeweaponskin(id,w) if (wepskin[id]~=0)     freeimage(wepskin[id]) end wepskin[id]=image("gfx/tf2/skins/weapons/"..getplayerdata(id,"class").." /"..string.lower(tf2.classes.weaponnames[w])..".png",1,0,200+id) end ]]  addhook("select","tf2.classes.images") function tf2.classes.images(id,w) if (player(id,"armor")~=206)     changeskin(id,player(id,"weapontype"))     --changeweaponskin(id,w) end end  addhook("spawn","tf2.classes.spawndebug") function tf2.classes.spawndebug(id) if (player(id,"armor")~=206)     changeskin(id,player(id,"weapontype"))     timer(10,"parse","lua changeskin("..id..",player("..id..",\"weapontype \"))")     if (tf2.classes.hatunlock[id][tf2.classes.class[id]]~=0)         timer(10,"parse","lua freeimage("..hat[id]..")")         timer(10,"parse","lua   hat["..id.."]=image(crafts[tf2.classes.hatunlock["..id.."][tf2.classes.class["..id.."]]].image,1,0,200+"..id..")")     else         timer(10,"parse","lua freeimage("..hat[id]..")")         timer(10,"parse","lua hat["..id.."]=0")     end end end  addhook("attack2","tf2.classes.spycloak") function tf2.classes.spycloak(id) if (tf2.classes.class[id]==9 , player(id,"armor")==0)     if (playerskin[id]~=0)         freeimage(playerskin[id])     end     --[[     if (wepskin[id]~=0)         freeimage(wepskin[id]) 

if you've solution please me.

thanks,

michael

your have

if( contains(...) ) 

in code segments. function contains need defined called. function definition missing.

you can use this(if want find w inside table):

function contains( tpassed, ivalue )     _, v in pairs( tpassed )         if tonumber(v) == tonumber(ivalue)             return true         end     end     return nil end 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -