isa_Khamdan Posted January 24, 2014 Posted January 24, 2014 Can I use this function to count players within a colshape?
Anubhav Posted January 24, 2014 Posted January 24, 2014 Yes! EXAMPLE: local colShape = createColSphere ( 1, 2, 3, 4 ) local players = getElementsWithinColShape ( newcolshape, "player" ) for theKey,thePlayer in ipairs(players) do outputChatBox ( getPlayerName ( thePlayer ) .. " is in the col shape." ) end --I Have got this example from wiki . See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Karuzo Posted January 24, 2014 Posted January 24, 2014 yes cou can. btw Anubhav it has to be : local players = getElementsWithinColShape ( colShape, "player" )
Anubhav Posted January 24, 2014 Posted January 24, 2014 ahh , ty for correcting my as it was on wiki:3 i edited it . See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
isa_Khamdan Posted January 24, 2014 Author Posted January 24, 2014 I don't want names I want to know how many players within ColShape
Moderators IIYAMA Posted January 24, 2014 Moderators Posted January 24, 2014 outputChatBox(#getElementsWithinColShape ( colShape, "player" ) ) 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
Smart. Posted January 24, 2014 Posted January 24, 2014 Or do a variable, count = 0 before the loop then count = count + 1 inside. lol
Moderators IIYAMA Posted January 24, 2014 Moderators Posted January 24, 2014 Or do a variable, count = 0 before the loop then count = count + 1 inside. True, but it would be a waste of your memory since you only use it for counting. 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
Smart. Posted January 24, 2014 Posted January 24, 2014 Or do a variable, count = 0 before the loop then count = count + 1 inside. True, but it would be a waste of your memory since you only use it for counting. What if he would like to use the previous count at any other time and I hardly doubt a variable containing max 3 integers will do anything to the memory and if it does you should seriously consider a new host. lol
Moderators IIYAMA Posted January 24, 2014 Moderators Posted January 24, 2014 True, but that is just 1 loop. If you use it in 20 times in one 1 script. And you have 10 scripts. And then you have 200 loops and yes that is still nothing for cpu's of these times. (only for players that have bad pc's) But ask your self: "why write more lines then you need?" You probably will answer: "I love to write lua....." 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
Smart. Posted January 24, 2014 Posted January 24, 2014 True, but that is just 1 loop.If you use it in 20 times in one 1 script. And you have 10 scripts. And then you have 200 loops and yes that is still nothing for cpu's of these times. (only for players that have bad pc's) But ask your self: "why write more lines then you need?" You probably will answer: "I love to write lua....." Completely off topic but haven't been writing lua in couple of months lol lol
isa_Khamdan Posted January 24, 2014 Author Posted January 24, 2014 outputChatBox(#getElementsWithinColShape ( colShape, "player" ) ) Thanks
Moderators IIYAMA Posted January 24, 2014 Moderators Posted January 24, 2014 np. 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