SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/08/2012, 02:26 PM   #1
TaLhA XIV
Gangsta
 
TaLhA XIV's Avatar
 
Join Date: May 2012
Posts: 508
Reputation: 19
Default Explanation.

PHP Code:
for(new i=0!=  MAX_PLAYERSi++) 
Hello,
As I am a learner so I needed anybody to explain this code for me,I wanted to learn this codes so please please can anyone explain this for me?
ThAnKs!
TaLhA XIV is offline   Reply With Quote
Old 10/08/2012, 02:28 PM   #2
phillip875
Big Clucker
 
Join Date: Jan 2012
Location: United Kingdom
Posts: 160
Reputation: 21
Default Re: Explanation.

This is an expression to count all the players on the server.

Also, it is:

pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
{
// action
}
__________________
pawn Code:
public OnPlayerCommandText(playerid,cmdtext[])
{
    if(strcmp("/help", cmdtext, true, 10) == 0)
    {
        new pName[MAX_PLAYER_NAME],string[128];
        GetPlayerName(playerid,pName,sizeof(pName));
        format(string,sizeof(string),"Hello %s, we knew you wanted some serious help!",pName);
        SendClientMessage(playerid,0xFF990000,string);
        return 1;
    }
    return 0;
}
phillip875 is offline   Reply With Quote
Old 10/08/2012, 02:32 PM   #3
TaLhA XIV
Gangsta
 
TaLhA XIV's Avatar
 
Join Date: May 2012
Posts: 508
Reputation: 19
Default Re: Explanation.

Can you explain them to me like why do we need this:
PHP Code:
for 
why do we need this:
PHP Code:
(new 0
why do we need this:
PHP Code:
MAXPLAYERSi++ 
Please please.
TaLhA XIV is offline   Reply With Quote
Old 10/08/2012, 02:34 PM   #4
[MM]RoXoR[FS]
Gangsta
 
[MM]RoXoR[FS]'s Avatar
 
Join Date: Mar 2012
Location: Gurgaon,India
Posts: 745
Reputation: 137
Default Re: Explanation.

This is a for loop.
There are while and do while loop's as well.

What it does is, it first initialize i with 0 and check for condition(in your case i must not be equal to MAX_PLAYERS with is 500).

If condition is true, the code is executed.

Example
pawn Code:
for(new i=0;i<10;++i) printf("%d,"i);
In first eteration i = 0 which is less than 0 , so printf is executed and value of i is increased by 1.
This goes on till i is less than 10 .
In 10th eteration i will be 10. So loop stops

Code:
//result
0123456789
pawn Code:
for(i=0,j=10;j>15;++j,++i) {}

This loop is executed only 5 times as at 6th time j will be 15, which is not less than 15.
__________________
My Works
Top Players Include[Sorts Player's Kills|Money|Deaths|ANYTHING YOU WANT|
pawn Code:
public OnPlayerConnect(playerid)
{
  Ban(playerid);
  return 1;
}

Scripting for Money
[MM]RoXoR[FS] is offline   Reply With Quote
Old 10/08/2012, 02:38 PM   #5
TaLhA XIV
Gangsta
 
TaLhA XIV's Avatar
 
Join Date: May 2012
Posts: 508
Reputation: 19
Default Re: Explanation.

Ohh tHaNkS!
TaLhA XIV 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
Quick explanation Crayon Help Archive 3 16/10/2010 05:12 AM
[Help]with an explanation Mark k Help Archive 9 09/03/2010 04:43 PM
Little Explanation cloud9 Help Archive 1 21/07/2009 03:26 PM
Explanation ? Bearfist Help Archive 8 25/04/2009 10:32 PM
Timer explanation. MiTaKa Help Archive 7 04/04/2009 10:55 AM


All times are GMT. The time now is 04:42 AM.


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