Dice Posted June 20, 2013 Posted June 20, 2013 function triggerSwarm( myName ) runningStreaks[player] = getPlayerFromName ( myName ) runningStreaks[player].x, runningStreaks[player].y, runningStreaks[player].z = getElementPosition ( runningStreaks[player] ) end I tested myName with outputChatBox and it passes from client to server successfully.
iMr.3a[Z]eF Posted June 20, 2013 Posted June 20, 2013 So,, what is the problem??? To Visit Us Press Here: mtasa://5.9.206.180:22002
xXMADEXx Posted June 20, 2013 Posted June 20, 2013 Try this: function triggerSwarm( myName ) runningStreaks[myName] = getPlayerFromName ( myName ) runningStreaks[myName].x, runningStreaks[myName].y, runningStreaks[myName].z = getElementPosition ( runningStreaks[myName] ) end The Ultimate Lua Tutorial! | MTA PHP SDK
ixjf Posted June 20, 2013 Posted June 20, 2013 (edited) The error message is very obvious I guess. getPlayerFromName never ever returns a table but still you're using the return value as if it was one. In this case, getPlayerFromName shouldn't be finding a player with the specified name and so returning false. Edited June 20, 2013 by Guest I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
xXMADEXx Posted June 20, 2013 Posted June 20, 2013 How are you triggering "triggerSwarm" ? The Ultimate Lua Tutorial! | MTA PHP SDK
iMr.3a[Z]eF Posted June 20, 2013 Posted June 20, 2013 may i see the "debugscript 3" ??? To Visit Us Press Here: mtasa://5.9.206.180:22002
Moderators IIYAMA Posted June 20, 2013 Moderators Posted June 20, 2013 function triggerSwarm( player ) if not runningStreaks[player] then runningStreaks[player] = {} -- make it a table end runningStreaks[player]["name"] = getPlayerFromName (player ) -- insert name runningStreaks[player].x, runningStreaks[player].y, runningStreaks[player].z = getElementPosition ( runningStreaks[player] ) -- insert pos end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
uhm Posted June 20, 2013 Posted June 20, 2013 also i dunno if im talking bs right now but do you ever do runningStreaks = {} in other words construct the runningStreaks table also y are u using both object notation and table notation ? is that allowed? idk legit question runningStreaks[player]["name"] = getPlayerFromName (player ) runningStreaks[player].x ------> runningStreaks[player]["name"] = getPlayerFromName (player ) runningStreaks[player]["x"] ----- ?
Moderators IIYAMA Posted June 20, 2013 Moderators Posted June 20, 2013 also i dunno if im talking bs right now but do you ever do runningStreaks = {} He must have because else it would start giving an error instead of a warning. ERROR: attempt to index a nil value. (title: Re: table index is nil) As far I know it is the same. runningStreaks[player].x runningStreaks[player]["x"] But I prefer ["x"]. When I use table.x, I always get confused that x is a not defined value. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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