14.02.2014, 20:25
(
Last edited by dugi; 15/02/2014 at 11:05 AM.
)
Hm... Don't get me wrong, but I don't want to change the structure of the programming language. I just want to make the syntax more convenient.
I do this because in our code has a lot of repetitive places. Look at this:
Obviously, all this code we are talking about one player. Why not simplify it?
Looks nice, does not it?
And look at this:
It's very simple.
And this is a loop through all connected players:
This is the normal loop:
I do this because in our code has a lot of repetitive places. Look at this:
PHP Code:
public OnPlayerConnect(playerid)
{
SomePlayerFunction1(playerid, ...); // the first repetition
SomePlayerFunction2(playerid, ...); // the second
SomePlayerFunction3(playerid, ...); // the third
...
// And there is more
}
PHP Code:
public OnPlayerConnect(player) // playerid -> player
{
player.SomeFunction1(...);
player.SomeFunction2(...);
player.SomeFunction3(...);
...
}
And look at this:
PHP Code:
players.for
{
if(!player.IsConnect()) // or !Player.Connected
{
continue;
}
player.Kick("You're a cheater!");
}
And this is a loop through all connected players:
PHP Code:
players.connected
{
player.SetVelocity(0.0, 0.0, 1.0);
// or
Player.Velocity.X = 0.0;
Player.Velocity.Y = 0.0;
Player.Velocity.Z = 1.0;
player.SetVelocity();
}
PHP Code:
for(i -> 10) // this is equivalent to: for(new i = 0; i < 10; ++i)
{
// something there
}

