CMD:engine(playerid, params[]) { new playername[25]; if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage2(playerid, COLOR_RED, "You must be the driver of a vehicle!"); new giveplayerid = GetPlayerVehicleID(playerid); new moneys1 = GetVehicleModel(giveplayerid); if (moneys1 == 481 || moneys1 == 509 || moneys1 == 510) return SendClientMessage2(playerid, COLOR_RED, "Error:{FFFFFF} This vehicle doesn't have an engine!"); new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(giveplayerid, engine, lights, alarm, doors, bonnet, boot, objective); if (engine != 1) { if (floatround(Gas[giveplayerid]) <= 0) return SendClientMessage2(playerid, COLOR_RED, "Error:{FFFFFF} You have ran out of fuel!"); GetPlayerName(playerid, playername, MAX_PLAYER_NAME); if (DoesVehicleTakeFuel(giveplayerid) && drivscstats[playerid][0] == 0) { if (IsVehicleBike(giveplayerid) && !dini_Isset(AddDirFile(dir_userfiles, playername), "licenseb")) return SendClientMessage2(playerid, COLOR_RED, "You don't have a bike license!"); else if (IsVehicleAircraft(giveplayerid) && !dini_Isset(AddDirFile(dir_userfiles, playername), "licensef")) return SendClientMessage2(playerid, COLOR_RED, "You don't have a flying license!"); else if (!IsVehicleBike(giveplayerid) && !IsVehicleAircraft(giveplayerid) && !dini_Isset(AddDirFile(dir_userfiles, playername), "license")) return SendClientMessage2(playerid, COLOR_RED, "You don't have a driving license!"); } if (!vehiclelocked[playerid][giveplayerid] && (vorgo[giveplayerid] == 0 || vorgo[giveplayerid] == GetPVarInt(playerid, "playerorg")) && (vehstored[giveplayerid] == -1 || PlayerVehicle(playerid, giveplayerid)) && cfs[giveplayerid][0] != 1) SetVehicleParamsEx(giveplayerid, 1, lights, alarm, doors, bonnet, boot, objective); if (ptextdraw[playerid] == cartext1) { TextDrawHideForPlayer(playerid, cartext1); KillTimer(textdtimer[playerid]); } GameTextForPlayer(playerid, "~w~~w~~w~Starting engine", 5000, 3); SetTimerEx("engine", 5000, false, "i", playerid); } else { SetVehicleParamsEx(giveplayerid, 0, lights, alarm, doors, bonnet, boot, objective); SendClientMessage2(playerid, COLOR_WGRAY, "Engine has been turned off."); } return 1; }
//This sets a 5 seconds timer and passes the player that has used the command
SetTimerEx("StartEngineForPlayer", 5000, false, "i", playerid); //I have changed the name to this since it is more readable.
//Place the following anywhere in the script, preferably around the command so you don't miss it.
forward StartEngineForPlayer(playerid); //Forwards to this function so it can be called here
public StartEngineForPlayer(playerid) //The actual function. Place what you want to happen after the function is called
{
//5 seconds passed start the engine here for the playerid
}
There you go:
PHP код:
|