SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/03/2019, 08:48 PM   #1
NoteND
Big Clucker
 
Join Date: May 2016
Posts: 197
Reputation: 3
Default Whats better and why

Hey!

I'm just wondering if there is any difference between

PHP Code:
for(new GetPlayerPoolSize(), 0<= j;  i++) 
and

PHP Code:
for(new 0GetPlayerPoolSize(); <= ji++) 
And if there is, whats the difference and whats better to use?

EDIT: And do you need to use "if(IsPlayerConnected(i))" after using GetPlayerPoolSize, since getplayerpoolsize only gets online players ?

Thanks for help!
NoteND is offline   Reply With Quote
Old 24/03/2019, 08:58 PM   #2
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 254
Reputation: 25
Default Re: Whats better and why

https://forum.sa-mp.com/showthread.php?t=581727
SymonClash is offline   Reply With Quote
Old 24/03/2019, 09:00 PM   #3
Heress
Huge Clucker
 
Heress's Avatar
 
Join Date: Mar 2018
Location: Lithuania
Posts: 262
Reputation: 7
Default Re: Whats better and why

Use foreach, i think it is the best choice.
__________________
==============
Sorry for my bad English









Respect: Kalcor, ******. Thank you for this great game!
Heress is offline   Reply With Quote
Old 24/03/2019, 09:03 PM   #4
NoteND
Big Clucker
 
Join Date: May 2016
Posts: 197
Reputation: 3
Default Re: Whats better and why

Okay thanks
NoteND is offline   Reply With Quote
Old 24/03/2019, 10:44 PM   #5
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,766
Reputation: 840
Default Re: Whats better and why

There's no difference. And yes you need to use IsPlayerConnected inside the loop because https://wiki.sa-mp.com/wiki/GetPlayerPoolSize

So you still need to check the ids are connected to the server.

And on another note, foreach is faster and better.
__________________

Follow me on Github: Follow me on Spotify: Donate on Paypal:

Gammix is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats the fix Lixyde Scripting Help 4 19/03/2019 10:22 AM
whats this andrewgrob Scripting Help 6 01/05/2012 01:57 AM
whats better GaGlets(R) Help Archive 4 20/09/2010 04:16 AM
Whats better JoeDaDude Help Archive 3 15/05/2009 07:19 PM
Whats this ? GTAplay Help Archive 15 15/05/2009 03:35 PM


All times are GMT. The time now is 03:03 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.