30.10.2010, 14:07
(
Последний раз редактировалось karakana7; 30.10.2010 в 14:19.
)
Maybe I'm idiot or maybe samp editors, but I think that they failed with one thing.So there is one lesson/script where is explained about else if function, they explaining it like this(i'll put their explaining here):
So i did't agree with their explanation, which is marked like bold in the code.Because I have example in my script, and this is opposite for their explanation.I have perfectly working race code, so I will copy only the beggining of that:
Ok so how you see there are many if elses statements and by wiki, if the first if won't fail else if will be false and won't be executed.But how I said, my race is working and when I sit into cars infernus and turismo first cp will appear and if that's true, than when I will enter to this cp, another cp will appear with new co-ordinates.So you see that actually you can't trust even wiki, because i have like evidence for their lying...
Simple explanation of what I wanted to say:that by wiki when if statement is true else if won't be exetuded and in my version although it is true, the else if statement will be executed!So may I not read correctly it, maybe you have some other version of this?If yes than write what you think about that-it'll be better for everyone, because more we know, more we can do!
Код:
else if An else if is a check which occurs if the first if check fails to check something else
Код:
public OnPlayerStateChange(playerid, newstate, oldstate) { new string[100]; format(string, sizeof(string), "Now you can start the race!!!", 1, 2); vehicle = GetVehicleModel(GetPlayerVehicleID(playerid)); if(vehicle == 411) { cp[playerid] = SetPlayerRaceCheckpoint(playerid, 0, -2334.7681,-2179.3489,35.1945, -2143.2742,-2006.9039,95.0157, 9); cp[playerid] = 0; } else if(vehicle == 451) { cp[playerid] = SetPlayerRaceCheckpoint(playerid, 0, -2334.7681,-2179.3489,35.1945, -2143.2742,-2006.9039,95.0157, 9); cp[playerid] = 0; SendClientMessage(playerid, 0xFFFFFFFF, string); return 1; } return 0; } public OnPlayerEnterRaceCheckpoint(playerid) { if (cp[playerid] == 0) { cp[playerid] = SetPlayerRaceCheckpoint(playerid, 0, -2143.2742,-2006.9039,95.0157, -2145.5430,-1958.8540,117.9665, 9); cp[playerid] = 1 } else if (cp[playerid] == 1) { cp[playerid] = SetPlayerRaceCheckpoint(playerid, 0, -2145.5430,-1958.8540,117.9665, -2474.9404,-2077.9385,124.7880, 9); cp[playerid] = 2; } else if (cp[playerid] == 2) { cp[playerid] = SetPlayerRaceCheckpoint(playerid, 0, -2474.9404,-2077.9385,124.7880, -2769.8372,-1811.5950,141.6222, 9); cp[playerid] = 3; }
