isa_Khamdan Posted January 24, 2014 Share Posted January 24, 2014 Can I use this function to count players within a colshape? Link to comment
Anubhav Posted January 24, 2014 Share 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 . Link to comment
Karuzo Posted January 24, 2014 Share Posted January 24, 2014 yes cou can. btw Anubhav it has to be : local players = getElementsWithinColShape ( colShape, "player" ) Link to comment
Anubhav Posted January 24, 2014 Share Posted January 24, 2014 ahh , ty for correcting my as it was on wiki:3 i edited it . Link to comment
isa_Khamdan Posted January 24, 2014 Author Share Posted January 24, 2014 I don't want names I want to know how many players within ColShape Link to comment
Moderators IIYAMA Posted January 24, 2014 Moderators Share Posted January 24, 2014 outputChatBox(#getElementsWithinColShape ( colShape, "player" ) ) Link to comment
Smart. Posted January 24, 2014 Share Posted January 24, 2014 Or do a variable, count = 0 before the loop then count = count + 1 inside. Link to comment
Moderators IIYAMA Posted January 24, 2014 Moderators Share 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. Link to comment
Smart. Posted January 24, 2014 Share 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. Link to comment
Moderators IIYAMA Posted January 24, 2014 Moderators Share 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....." Link to comment
Smart. Posted January 24, 2014 Share 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 Link to comment
isa_Khamdan Posted January 24, 2014 Author Share Posted January 24, 2014 outputChatBox(#getElementsWithinColShape ( colShape, "player" ) ) Thanks Link to comment
Moderators IIYAMA Posted January 24, 2014 Moderators Share Posted January 24, 2014 np. 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