Raised This Month: $51 Target: $400
 12% 

Solved Basic get_players question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-31-2018 , 10:28   Basic get_players question
Reply With Quote #1

I've been trying to ask this question for around a year or two now. I just don't get why we do this:
PHP Code:
new iPlayers32 ], iNum;
get_playersszPlayersiNum );

for( new 
iiNumi++ )
{
    
// code

And not this
PHP Code:
new iPlayers32 ], iNum;
get_playersszPlayersiNum );

for( new 
1<= iNumi++ )
{
    
// code

Why do we start from 0 when the first valid player ID is 1? And let's say iNum returns 32, why do we skip the last one by using < operator?
Is get_players 0 based?
__________________

Last edited by edon1337; 08-31-2018 at 10:39.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-31-2018 , 10:32   Re: Basic get_players question
Reply With Quote #2

cause we are looping for szPlayers index which starts from 0 and this array will give you player indexes based on get_players
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-31-2018 , 10:34   Re: Basic get_players question
Reply With Quote #3

Quote:
Originally Posted by Ghosted View Post
cause we are looping for szPlayers index which starts from 0 and this array will give you player indexes based on get_players
I get it now, thanks.
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-31-2018 , 10:36   Re: Basic get_players question
Reply With Quote #4

Also szPlayers is a wrong name. sz is for strings, but in this case you have an array of integers.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-31-2018 , 10:38   Re: Basic get_players question
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
Also szPlayers is a wrong name. sz is for strings, but in this case you have an array of integers.
Fixed, thanks for the info
__________________
edon1337 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 10:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode