08.10.2011, 22:33
for checkpoint-decisions, try switch{case{}case{}} instead of if{}if{}. if's will get called even if the first one got triggered when you didnt use an else-if. even if you use the else, then it will loop through them until a decision is done or w/o result: it uses CPU time if you extend the amount later.
the switch/case avoids that behavior, it prepares a quick decision "table", and for one case it triggers the action. well, i describe it horribly, just look at this piece:
iam curious if this works. didnt test it indeed ^^
the switch/case avoids that behavior, it prepares a quick decision "table", and for one case it triggers the action. well, i describe it horribly, just look at this piece:
Код:
new NewVehicleID = GetPlayerVehicleID(playerid); switch(checkpointid) { case Mcheck[0]: { if(OldVehicleID[playerid] != NewVehicleID) return SendClientMessage(playerid,COLOR_RED,"This vehicle does not contain a passenger!"); // stop previous CP DestroyDynamicCP(Mcheck[0]); Mcheck[1] = CreateDynamicCP(mInfo[playerid][Del_x], mInfo[playerid][Del_y], mInfo[playerid][Del_z], 2.0, -1, -1, playerid, 400000.0); } case Mcheck[1]: { SendClientMessage(playerid,COLOR_RED,"completed the mission"); } }