This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

For cycle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KamiN
Senior Member
Join Date: Jun 2011
Old 12-11-2011 , 06:20   For cycle
Reply With Quote #1

Witch one is better??

Code:
    new name[33]; get_user_name(id, name, charsmax(name))
 
    for(new i = 1; i < g_max_clients; i++)
    {
To give a gun to a player i would have to write
Code:
give_item(i, "weapon_deagle")


--

Code:
    new players[32], num
   
    get_players(players, num, "a")  // It returns all alive players? I mean both teams, CTs and Ts?

 
    for(new i; i < num; i++) 
    {
To give a gun to a player i should write this
Code:
give_item(players[i], "weapon_deagle")



or this
Code:
give_item(i, "weapon_deagle")

?



KamiN is offline
Kidev
Veteran Member
Join Date: Jun 2010
Location: France
Old 12-11-2011 , 08:02   Re: For cycle
Reply With Quote #2

PHP Code:
static iPlayers32 ], iNumtid;
get_playersiPlayersiNum"a" );
for ( new 
0iNumi++ )
{
    
tid iPlayers]; // You can also use iPlayers[ i ], but if you use it more than one time, cache the value in a variable.
    
give_itemtid"weapon_deagle" );

__________________

Last edited by Kidev; 12-11-2011 at 08:03.
Kidev is offline
KamiN
Senior Member
Join Date: Jun 2011
Old 12-11-2011 , 08:59   Re: For cycle
Reply With Quote #3

Whats the difference betwen

Code:
new i
and
Code:
new i = 0
?
KamiN is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-11-2011 , 10:02   Re: For cycle
Reply With Quote #4

Quote:
Originally Posted by KamiN View Post
Whats the difference betwen

Code:
new i
and
Code:
new i = 0
?
Nothing, some programming languages (c++ too i think) require to be initialized when they are created. Pawn doesn't require it but some people do it out of habit.
Pawn initialized at 0, so there is no difference in this case.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Kidev
Veteran Member
Join Date: Jun 2010
Location: France
Old 12-11-2011 , 11:27   Re: For cycle
Reply With Quote #5

Quote:
Originally Posted by drekes View Post
Nothing, some programming languages (c++ too i think) require to be initialized when they are created. Pawn doesn't require it but some people do it out of habit.
Pawn initialized at 0, so there is no difference in this case.
Yeah, I set it to 0 to be clear.
__________________
Kidev 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 18:39.


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