SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 01/09/2011, 10:39 AM   #1
Cowboy
Big Clucker
 
Join Date: Jun 2011
Posts: 107
Reputation: 0
Default Does these two loops do the same thing?

pawn Code:
for (new i = 0; i < MAX_PLAYERS; i++)

and

pawn Code:
for(new i; i != MAX_PLAYERS; i++)
Cowboy is offline   Reply With Quote
Old 01/09/2011, 10:41 AM   #2
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,793
Reputation: 1179
Default Re: Does these two loops do the same thing?

yes

( 1234 )
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 01/09/2011, 10:46 AM   #3
Cowboy
Big Clucker
 
Join Date: Jun 2011
Posts: 107
Reputation: 0
Default Re: Does these two loops do the same thing?

Hi Lorenc, thanks for your answer.

Btw, from your tutorial, this

pawn Code:
public OnGameModeExit()
{
    for(new i; i != MAX_PLAYERS; i++) OnPlayerDisconnect(i, 1);
    db_close(Database);
    return 1;
}

Doesn't it need a IsPlayerConnected check?

EDIT:

I gotta another question.

Example:

PlayerInfo[playerid][pAdminLevel] = 0;

Where is it best to put this? OnPlayerConnect or OnPlayerDisconnect? Or maybe both?

Thanks
Cowboy is offline   Reply With Quote
Old 01/09/2011, 11:16 AM   #4
Babul
High-roller
 
Babul's Avatar
 
Join Date: Sep 2009
Location: in a cement block
Posts: 1,781
Reputation: 266
Default Re: Does these two loops do the same thing?

the PlayerInfo[playerid][pAdminLevel] is a global variable, it wont get erased in case a level 3 admin logs out. so adding the level=0 into the disconnect, is a good idea.
to set admin level to 0 when connecting, is not the best idea (its value is set to 0 at initializing, also got set to 0 from a recently playing admin on that slot).
i suggest you to use PVars to store such "important" variables, so any of your filterscript can access it aswell. PVars gets deleted when a player disconnects, so no worry about resetting the player-arrays.
__________________
FireWorks

new sscanf2 custom specifiers available for Download, read the Release Topic
Babul is offline   Reply With Quote
Old 01/09/2011, 11:28 AM   #5
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 1,988
Reputation: 133
Default Re: Does these two loops do the same thing?

Quote:
Originally Posted by Babul View Post
the PlayerInfo[playerid][pAdminLevel] is a global variable, it wont get erased in case a level 3 admin logs out. so adding the level=0 into the disconnect, is a good idea.
to set admin level to 0 when connecting, is not the best idea (its value is set to 0 at initializing, also got set to 0 from a recently playing admin on that slot).
i suggest you to use PVars to store such "important" variables, so any of your filterscript can access it aswell. PVars gets deleted when a player disconnects, so no worry about resetting the player-arrays.
I suggest you to read this:
http://forum.sa-mp.com/showthread.ph...highlight=PVar
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 01/09/2011, 11:46 AM   #6
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 966
Reputation: 414
Default Re: Does these two loops do the same thing?

Quote:
Originally Posted by Cowboy View Post
pawn Code:
public OnGameModeExit()
{
    for(new i; i != MAX_PLAYERS; i++) OnPlayerDisconnect(i, 1);
    db_close(Database);
    return 1;
}
Why would there be anything like that at all is what I'm wondering. OnPlayerDisconnect is called for every player upon a controlled server restart anyways.
Quote:
Originally Posted by Cowboy View Post
I gotta another question.

Example:

PlayerInfo[playerid][pAdminLevel] = 0;

Where is it best to put this? OnPlayerConnect or OnPlayerDisconnect? Or maybe both?
Both would be a waste. Resetting it under OnPlayerDisconnect is a good idea.
AndreT is offline   Reply With Quote
Old 01/09/2011, 11:56 AM   #7
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 1,988
Reputation: 133
Default Re: Does these two loops do the same thing?

Quote:
Originally Posted by AndreT View Post
Why would there be anything like that at all is what I'm wondering. OnPlayerDisconnect is called for every player upon a controlled server restart anyways.
It's bugged with gmx.
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 01/09/2011, 11:58 AM   #8
Cowboy
Big Clucker
 
Join Date: Jun 2011
Posts: 107
Reputation: 0
Default Re: Does these two loops do the same thing?

I tried that code, but it doesn't save when I gmx, why?
Cowboy is offline   Reply With Quote
Old 01/09/2011, 12:08 PM   #9
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 1,988
Reputation: 133
Default Re: Does these two loops do the same thing?

Create costum gmx command.
Do the saving thinghy then run gmx.
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 01/09/2011, 12:17 PM   #10
Cowboy
Big Clucker
 
Join Date: Jun 2011
Posts: 107
Reputation: 0
Default Re: Does these two loops do the same thing?

No other way? I would really like to use the gmx from rcon window
Cowboy is offline   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
[Map] Loops Thanator Maps 21 12/04/2012 11:08 PM
loops fissekarl Help Archive 4 24/04/2011 11:30 AM
[Help] Loops Maxips2 Help Archive 4 16/07/2010 04:03 PM
Vehicle respawn thing thing velkarumpali Help Archive 5 28/07/2009 07:29 PM


All times are GMT. The time now is 11:27 AM.


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