When to use "for" ?
#1

Hello everyone , I was thinking that there is no difference between the loop( for) and not using it , but know , I see several players advicing using the loop "For"
so my question is how to use it and how to avoid it ?
I will give ex:

*Someone who has Level system and active timer for every player who join the server , because the level timer is different between each player.should he add a for(...) or just using playerid when forwarding the timer?
Reply
#2

Thank you , actually , I use 'for' for general variables (like map change+timer) & I don't use it for MAX_PLAYERS because there is a timer running for each connected player.
Reply
#3

Another thing you could use for repeating things is the if-goto statement. It's actually quite useful in some cases.

https://sampwiki.blast.hk/wiki/Control_Structures#if-goto
Reply
#4

Well , I also use 'for' to check a variable for every player in the server (/admins for ex).
Код:
if-goto
don't think gonna use it in the entire script , but thanks for the information.
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
No it isn't! Not only is it bad practice, but it actually generates worse code than "for" or "do...while".
I'm aware of that, but nevertheless, it solved an issue for me in the past (on about 2 occasions only though).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)