15.12.2010, 20:50
The loose indentation:
This means the code is a bit messy. That doesn't matter, as an beginner.
A tip, to make a clean code:
You had, for example:
And now the "clean" version
You see the difference? With an "clean" code, you can find error's faster. It also looks more pro and it is a better overview if you look for something.
- Kevin
p.s.
I've editted my previous post. Read the 'p.s.'
This means the code is a bit messy. That doesn't matter, as an beginner.
A tip, to make a clean code:
Код:
After using an bracket (open bracket) or an if statement, use on the new line a TAB. Example:or, a better code:pawn Код:if(this){ //And after this an TAB [= 4 spaces] print("this is true!"); }//close bracket. Same line as the bracket opener
pawn Код:if(this) print("this is true!");
pawn Код:
public EngineTimer(playerid)
{
new rand = random(2);
if(rand == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "Engine Started...");
SendClientMessage(playerid, COLOR_YELLOW, "To turn off the vehicle, Type (/engine)");
new vehicleid = GetPlayerVehicleID(playerid);
Engine[vehicleid] = 1;
TogglePlayerControllable(playerid, 1);
}
if(rand == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "Engine Failed...");
SendClientMessage(playerid, COLOR_YELLOW, "Try Again");
}
}
pawn Код:
public EngineTimer(playerid)
{
new rand = random(2);
if(rand == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "Engine Started...");
SendClientMessage(playerid, COLOR_YELLOW, "To turn off the vehicle, Type (/engine)");
new vehicleid = GetPlayerVehicleID(playerid);
Engine[vehicleid] = 1;
TogglePlayerControllable(playerid, 1);
}
else if(rand == 1) //else if instead of 'if'
{
SendClientMessage(playerid, COLOR_GREEN, "Engine Failed...");
SendClientMessage(playerid, COLOR_YELLOW, "Try Again");
}
}
- Kevin
p.s.
I've editted my previous post. Read the 'p.s.'