glowdemon1 Posted February 3, 2014 Posted February 3, 2014 Hi, I have a snippet of code that I'll use to get elements of peds from their ID. It all seems to work, however it does not return the ped element as I've noticed in various tests. Here's my snippet of code : http://paste.ofcode.org/VSWFybYGwAJV6MdeFiQsPw MySQL based MP3 System - unique radio stations My mappings
Castillo Posted February 3, 2014 Posted February 3, 2014 And you are setting the "ped_id__" element data? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
glowdemon1 Posted February 3, 2014 Author Posted February 3, 2014 And you are setting the "ped_id__" element data? ped_id__ is indeed set. I have checked whether the ID is present and it is indeed present. Here's how I use it : http://paste.ofcode.org/UgUNdigKupSgRFei23YDf4 , at line 18 you can see the element isn't present because it returns an error. MySQL based MP3 System - unique radio stations My mappings
Castillo Posted February 3, 2014 Posted February 3, 2014 function getPedById ( id ) if ( id ) then local peds = getElementsByType ( "ped" ) for _, v in pairs ( peds ) do local d = getElementData ( v, "ped_id__" ) if ( d == tonumber ( id ) ) then return v end end end end Try that one. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
glowdemon1 Posted February 3, 2014 Author Posted February 3, 2014 function getPedById ( id ) if ( id ) then local peds = getElementsByType ( "ped" ) for _, v in pairs ( peds ) do local d = getElementData ( v, "ped_id__" ) if ( d == tonumber ( id ) ) then return v end end end end Try that one. This one seemed to work,thanks. MySQL based MP3 System - unique radio stations My mappings
Castillo Posted February 3, 2014 Posted February 3, 2014 The problem was that you were comparing a string with a number, since 'pedid' in your command is a string, not a number. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
glowdemon1 Posted February 3, 2014 Author Posted February 3, 2014 The problem was that you were comparing a string with a number, since 'pedid' in your command is a string, not a number. Ah, that explains it. Since I'm here now, I've got another problem. I can successfully set a ped's anim and it gets saved into my mysql db. But after restarting the script it doesn't load the anims. No errors at all. Here's the code http://paste.ofcode.org/yyyyHeYzb4aYBQQatmL3SW and here's the mysql layout incase you need it. http://puu.sh/6I0X0.png and http://puu.sh/6I0VN.png I've tried without checking if v.animblock exists etc. I also tried tostring() but none helped. MySQL based MP3 System - unique radio stations My mappings
Castillo Posted February 3, 2014 Posted February 3, 2014 Set a 1 second timer to set the animation. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
glowdemon1 Posted February 3, 2014 Author Posted February 3, 2014 Set a 1 second timer to set the animation. Welp, that worked. Thanks. MySQL based MP3 System - unique radio stations My mappings
Castillo Posted February 3, 2014 Posted February 3, 2014 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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