14.08.2012, 04:05
Hi guys!
I created an engine system for my script (based off of Vortex 2).
However, upon using the command, it does everything fine leading up to the timer.
However for some reason, the timer works on ID 0. For example if I were ID 4, and I typed /hotwire in a vehicle, it would display everything fine, and all would be well, except that it doesn't start my engine and it submits the "Engine Started!" message to ID 0.
Can anybody help me out? I've tried multiple things but I can't figure out what is causing it.
Thanks for any help given!
With kind regards,
Eric.
I created an engine system for my script (based off of Vortex 2).
However, upon using the command, it does everything fine leading up to the timer.
However for some reason, the timer works on ID 0. For example if I were ID 4, and I typed /hotwire in a vehicle, it would display everything fine, and all would be well, except that it doesn't start my engine and it submits the "Engine Started!" message to ID 0.
Can anybody help me out? I've tried multiple things but I can't figure out what is causing it.
pawn Код:
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;
}
pawn Код:
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.");
}
}
pawn Код:
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!");
}
With kind regards,
Eric.