FUNExtreme Posted April 30, 2010 Share Posted April 30, 2010 (edited) Hello, I'm new to lua as I come from samp and I've stumbled upon a problem that I couldn't solve by searching the wiki, forum, etc So I've come along tables and understand how they work by now although I still seem to have some problems. code removed As you see I created a table wich will hold the current team and skin for each player. But when I try to use these tables in a function wich is here "SetElementModel" I get the error *Resource location*: attempt to index field '?' <a nil value> And I really don't understand why it gives this error, I hope that someone of you can light me up on this one so that I won't stumble upon this problem again. Greetzz, FUNExtreme Edited May 1, 2010 by Guest Link to comment
robhol Posted April 30, 2010 Share Posted April 30, 2010 source is nil. Are you sure you're doing it in an event handler? Either way, add a debug output with tostring(source) and see what it is. And if you can't figure it out, please try to post as much as your script as possible. Preferably the whole file. It makes it a lot easier for people to figure out. Link to comment
FUNExtreme Posted April 30, 2010 Author Share Posted April 30, 2010 (edited) Well I tried adding tostring allready, just as I tried tonumber and both gave the error. I'll show you the whole join handler code removed Edited May 1, 2010 by Guest Link to comment
50p Posted April 30, 2010 Share Posted April 30, 2010 Well I tried adding tostring allready, just as I tried tonumber and both gave the error. I'll show you the whole join handler function serverJoinHandler() currentTeamID[source] = 1 currentSkinID[source] = 1 setElementModel(source, playerSkins[currentTeamID[source]][currentSkinID[source]]) setElementPosition(source, 1474.43, -2286.91, 42.42) -- for testing purpose -- above line should be edited later on local PosX, PosY, PosZ = getElementPosition(source) local PosRot = setPedRotation(source, 1) setCameraMatrix(source, PosX, PosY+2, PosZ, PosX, PosY, PosZ) fadeCamera(source, true) triggerClientEvent("createSelectionGUIEvent", gRoot, CreateSelectionGUI) end addEventHandler("onPlayerJoin", gRoot, serverJoinHandler) Where is your playerSkins? To me, it looks like playerSkins is the problem maker. Link to comment
FUNExtreme Posted April 30, 2010 Author Share Posted April 30, 2010 As you stated the playerSkins seems to be the problem. When using currentTeamID[tostring(source)] then it will return the correct number (in this case 1) Here you have the code that shows how the playerSkins is built-up Side-note: The table playerSkins is in another .lua file (wich doesn't give trouble when I use a number instaid of the table) code removed Link to comment
FUNExtreme Posted May 1, 2010 Author Share Posted May 1, 2010 Sorry for the double post but I fixed the problem. There was a typo in the file where playerSkins gets information from wich made that it didn't get the information, therefore the table didn't get filled and all the tries returned false Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now