I want to know these code
#1

Ok so i will present here numbered questions here and you people answer to them if you know:
First I show some script, from which much part of it is unclear for me :
Код:
if(PlayerInfo[playerid][pJob] != 1)
{
    for(new i = 0; i <MAX_PIZZABIKES; i++)
    {
        if(vehicleid == PizzaJobVehicles[i])
        {
            SendClientMessage(playerid, COLOR_RED, "You don't have the keys of this Vehicle");
            SendClientMessage(playerid, COLOR_RED, "So you decide to step off the Pizzaboy");
           
            RemovePlayerFromVehicle(playerid);
            break; // Kill the loop.
        }
    }
}
1.Ok, isn't i'm right that PlayerInfo collects information about player, like what is his id and in what job he is, and I don't what will do this code - !=1;

2.For what this command is used for: for;

3.Now there is the whole line: for(new i = 0; i <MAX_PIZZABIKES; i++) , so I don't understand anything inside it, so can someone explain to me what doing code for, new i = 0(I know that this is variable, but i don't why it is assigned to 0 and for what it's used for), etc....;

4.Ok and the last thing is break, so what it do in the code.

Thanks for everyone, I aprreciate every help, these questions is for now, in the future maybe i will add more questions, please don't be stupid and don't write anything like go and learn yourself, because it's forum of help.
Reply
#2

1: The first line means "If the player doesn't have job number 1". "!=" means "is not", "==" means "is".

2: for initiates a loop, in this case you're looping (Cycling) through all the pizza bikes.

3: The format is for(new Variable; when should this loop continue; what should happen each loop). You can read more here.

4: break means that the loop is over, so it doesn't cycle anymore.
Reply
#3

Thank you But what is used i++?I know you said that what should happen each loop, but we write the code SendClientMessage later, which shows what should happen.And the code will do the loop, if player isn't in this job, i'm correct?
Reply
#4

i++ means "i = i+1"

everything inside the loop happens too.

Yes, you are correct
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)