12.05.2012, 20:56
This might be confusing for a beginner, but I have a solution for such commands/parts of script using only one native function.
What's the benefit from this? You might start arguing me over the necessity of such "optimization", but theoretically speaking this is faster than a command that first calls IsPlayerInAnyVehicle and then GetPlayerVehicleID. And further on, if you're going to do more things with the vehicle ID, you're going to need to store it in a variable anyways (or it would be good to do so).
GetPlayerVehicleID(playerid) returns 0 when the player isn't in a vehicle, so this is an helpful thing to keep in mind.
pawn Код:
if(!strcmp(cmd, "/fixveh", true))
{
new vID = GetPlayerVehicleID(playerid);
if(vID != 0)
{
RepairVehicle(vID);
}
return 1;
}
GetPlayerVehicleID(playerid) returns 0 when the player isn't in a vehicle, so this is an helpful thing to keep in mind.