No reason for this not to work. -
Dokins - 14.01.2012
It simply does not work. I don't know why..
pawn Код:
CMD:eon(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOUR_GREY, "You are not in a vehicle.");
EngineStartStatus[playerid] = 3;
engineon = SetTimer("EngineOn", 3000, 0);
new vehicleid = GetPlayerVehicleID(playerid);
if(EngineStartStatus[playerid] == 1)
{
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}
Timer:
pawn Код:
forward EngineOn();
public EngineOn()
{
foreach(Player, i)
{
if(EngineStartStatus[i] == 3)
{
GameTextForPlayer(i, "~g~Engine Starting...", 1000, 5);
EngineStartStatus[i] --;
}
if(EngineStartStatus[i] == 2)
{
GameTextForPlayer(i, "~g~Engine Starting..", 1000, 5);
}
if(EngineStartStatus[i] == 1)
{
EngineStartStatus[i] = 1;
KillTimer(engineon);
GameTextForPlayer(i, "~g~Engine Started.", 1000, 5);
}
}
return 1;
}
Re: No reason for this not to work. -
MP2 - 14.01.2012
There is always a reason. A computer only does what it's told.
Define 'does not work'. What happens?
Re: No reason for this not to work. -
iGetty - 14.01.2012
Change:
pawn Код:
forward EngineOn();
public EngineOn()
to
pawn Код:
forward EngineOn(playerid);
public EngineOn(playerid)
Then,
pawn Код:
engineon = SetTimer("EngineOn", 3000, 0);
To
pawn Код:
engineon = SetTimerEx("EngineOn", 3000, 0, "i", playerid);
Because what you are doing is setting the timer for ALL players on the Server, where you only want it for the one player.
Re: No reason for this not to work. -
Dokins - 14.01.2012
Yeah I know, but it just seems that way, In game it only displays the game text for If EngineStartStatus == 2. then it doesnt continue the code and nor does it display the game text for 3.
Re: No reason for this not to work. -
iGetty - 14.01.2012
On
pawn Код:
if(EngineStartStatus[i] == 2)
{
GameTextForPlayer(i, "~g~Engine Starting..", 1000, 5);
}
Add:
Re: No reason for this not to work. -
Dokins - 14.01.2012
Thanks, trying all this stuff.
EDIT: Still not working....Got to 1 but still not displaying 3. And the engine didn't run.
Re: No reason for this not to work. -
iGetty - 14.01.2012
pawn Код:
forward EngineOn(playerid);
public EngineOn(playerid)
{
if(EngineStartStatus[playerid] == 3)
{
GameTextForPlayer(playerid, "~g~Engine Starting...", 1000, 5);
EngineStartStatus[playerid] --;
}
if(EngineStartStatus[playerid] == 2)
{
GameTextForPlayer(playerid, "~g~Engine Starting..", 1000, 5);
EngineStartStatus[playerid] --;
}
if(EngineStartStatus[playerid] == 1)
{
EngineStartStatus[playerid] = 1;
KillTimer(engineon);
GameTextForPlayer(playerid, "~g~Engine Started.", 1000, 5);
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}
That's what it should be as.
Also, take:
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
if(EngineStartStatus[playerid] == 1)
{
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
}
from the /eon command and add it to the last part, as show above.
Re: No reason for this not to work. -
Dokins - 14.01.2012
Thanks, trying this time, although it doesnt display when its at 3, 2 now, only 1.
Re: No reason for this not to work. -
Scenario - 14.01.2012
pawn Код:
CMD:eon(playerid, params[])
{
if(LoggedIn[playerid] == 0)
return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOUR_GREY, "You are not in a vehicle.");
GameTextForPlayer(playerid, "~g~Engine starting...", 2500, 5);
SetTimerEx("EngineOn", 3000, false, "i", playerid);
return 1;
}
forward EngineOn(playerid);
public EngineOn(playerid)
{
GameTextForPlayer(playerid, "~g~Engine started!", 1500, 5);
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
return 1;
}
See if this works for you.
Re: No reason for this not to work. -
Dokins - 14.01.2012
That work's absolutely perfectly @realcop228 Thank you very much! I've learned from that now! and thanks to IGetty for the assistance as well!