CMD:engine(playerid, params[]) {
if(GetPlayerState(playerid) != 2)
return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle!");
new vid = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(vid, health);
if(health <= 450) {
format(szMessage, sizeof(szMessage), "* %s's engine stalls as they attempt to start the vehicle.", playerVariables[playerid][pNormalName]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
SendClientMessage(playerid, COLOR_GREY, "You must call a mechanic to fix this vehicle before it can be used again.");
return 1;
}
if(Engine[vid] == 0 && health > 450) {
if(vehicleVariables[vid][vVehicleGroup] == playerVariables[playerid][pGroup] || vid == playerVariables[playerid][pCarID]) {
SetTimer("StartEngine", 2000, false);
format(szMessage, sizeof(szMessage), "* %s turns the key in the ignition, starting the vehicle.", playerVariables[playerid][pNormalName]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
return 1;
}
else {
return SendClientMessage(playerid, COLOR_GREY, "You do not have a key to this vehicle. Please use /hotwire.");
}
}
if(Engine[vid] == 1 && health > 450) {
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
format(szMessage, sizeof(szMessage), "* %s turns the key in the ignition, disabling the vehicle.", playerVariables[playerid][pNormalName]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
Engine[vid] = 0;
Lights[vid] = 0;
return 1;
}
return 1;
}
CMD:hotwire(playerid, params[]) {
if(GetPlayerState(playerid) != 2)
return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle!");
new vid = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(vid, health);
if(health <= 450) {
format(szMessage, sizeof(szMessage), "* %s fiddles with a few wires under the dashboard, and the engine stalls as they attempt to hotwire it.", playerVariables[playerid][pNormalName]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
SendClientMessage(playerid, COLOR_GREY, "This vehicle must be fixed before it can be used again.");
return 1;
}
if(Engine[vid] == 0 && health > 450) {
if(playerVariables[playerid][pToolkit] == 1) {
SetTimer("StartEngine", 2000, false);
format(szMessage, sizeof(szMessage), "* %s fiddles with a few wires under the dashboard, and the engine starts as they hotwire it.", playerVariables[playerid][pNormalName]);
nearByMessage(playerid, COLOR_PURPLE, szMessage);
return 1;
}
else {
return SendClientMessage(playerid, COLOR_GREY, "You do not have a tool kit! Buy one at a 24/7.");
}
}
else {
return SendClientMessage(playerid, COLOR_GREY, "The engine is already started! Use /engine to stop it.");
}
}
forward StartEngine(const playerid);
public StartEngine(const playerid) {
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, 1, alarm, doors, bonnet, boot, objective);
Engine[GetPlayerVehicleID(playerid)] = 1;
Lights[GetPlayerVehicleID(playerid)] = 1;
SendClientMessage(playerid, COLOR_GREEN, "Engine started!");
}
if(GetPlayerState(playerid) != 2)
Whats can helps you this ? lvl 2 + can do /engine ? |
SetTimer("StartEngine", 2000, false);
public StartEngine(const playerid)
SetTimerEx("StartingEngine", 2000, false, "d", playerid);
SetTimerEx("StartEngine", 2000, false, "dd", playerid, vehicleid);
You're using SetTimer, and not SetTimeEx.
pawn Код:
pawn Код:
pawn Код:
You could even do this: pawn Код:
|