Maybe it's the most convenient syntax for pawn
#8

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:

PHP Code:
public OnPlayerConnect(playerid)
{
    
SomePlayerFunction1(playerid, ...); // the first repetition
    
SomePlayerFunction2(playerid, ...); // the second
    
SomePlayerFunction3(playerid, ...); // the third
    
...
    
// And there is more

Obviously, all this code we are talking about one player. Why not simplify it?

PHP Code:
public OnPlayerConnect(player// playerid -> player
{
    
player.SomeFunction1(...);
    
player.SomeFunction2(...);
    
player.SomeFunction3(...);
    ...

Looks nice, does not it?
And look at this:

PHP Code:
players.for
{
    if(!
player.IsConnect()) // or !Player.Connected
    
{
        continue;
    }
    
    
player.Kick("You're a cheater!");

It's very simple.
And this is a loop through all connected players:

PHP Code:
players.connected
{
    
player.SetVelocity(0.00.01.0);
    
    
// or
    
    
Player.Velocity.0.0;
    
Player.Velocity.0.0;
    
Player.Velocity.1.0;
    
player.SetVelocity();

This is the normal loop:

PHP Code:
for(-> 10// this is equivalent to: for(new i = 0; i < 10; ++i)
{
    
// something there

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)