[Help] Setting a timer to delay rest of command -
Ace_Menace - 19.07.2010
Concept:
Have a player type a command, "getcar", and in 2 minutes a car spawns on(near) their position.
Now I'm good, until I get to the timer part, I've never been familiar with timers, I spent a few hours now looking at other timers, and searching wiki, but no luck.
What I got:
pawn Код:
if(strcmp(cmd, "/getcar", true) == 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SendClientMessage(playerid, COLOR_HELP, "A car will be to your position in 2 Minutes");
// DELAY FOR CAR SPAWNING (2 Minutes) HERE
new carid = CreateVehicle(410, X,Y+5,Z+1, 0.0, 6, 6, 15);
CreatedCars[CreatedCar] = carid; // Part of la-rp base
CreatedCar ++; // Part of la-rp base
return 1;
}
And Basically, I tried to put this into it:
pawn Код:
new CarTimer = SetTimer ("CarTimer", 120000,1);
But I have no clue how to make it so that the timer stops the car from spawning for 2 minutes
Re: [Help] Setting a timer to delay rest of command -
Kar - 19.07.2010
make a forward CarTimer();
then public CarTimer()
then under cartimer
public CarTimer()
{
new carid = CreateVehicle(410, X,Y+5,Z+1, 0.0, 6, 6, 15);
CreatedCars[CreatedCar] = carid; // Part of la-rp base
CreatedCar ++; // Part of la-rp base
KillTimer(CarTimer);
}
Re: [Help] Setting a timer to delay rest of command -
Ace_Menace - 19.07.2010
Alright, I did what you suggested,
but I don't see how it implements the 2 minutes waiting.
Re: [Help] Setting a timer to delay rest of command -
Kar - 19.07.2010
look at my commands
pawn Код:
else if(gTeam[playerid] == TEAM_MEDIC)
{
TextDrawShowForPlayer(playerid, MDCBOX);
TextDrawShowForPlayer(playerid, text9);
TextDrawShowForPlayer(playerid, text10);
TextDrawShowForPlayer(playerid, text11);
TextDrawShowForPlayer(playerid, text12);
SetTimerEx("HideDraw", 15000, 0, "i", playerid);
}
//see hidedraw next public hidedraw
forward HideDraw(playerid);
public HideDraw(playerid)
{
TextDrawHideForPlayer(playerid, text28);
TextDrawHideForPlayer(playerid, text29);
TextDrawHideForPlayer(playerid, HOUSEBOX);
TextDrawHideForPlayer(playerid, HSTATSBOX);
TextDrawHideForPlayer(playerid, text34);
TextDrawHideForPlayer(playerid, text30);
TextDrawHideForPlayer(playerid, text31);
TextDrawHideForPlayer(playerid, text32);
TextDrawHideForPlayer(playerid, text33);
TextDrawHideForPlayer(playerid, CIVBOX);
TextDrawHideForPlayer(playerid, text1);
TextDrawHideForPlayer(playerid, text2);
TextDrawHideForPlayer(playerid, text3);
TextDrawHideForPlayer(playerid, text4);
TextDrawHideForPlayer(playerid, COPBOX);
TextDrawHideForPlayer(playerid, text6);
TextDrawHideForPlayer(playerid, text7);
TextDrawHideForPlayer(playerid, text8);
TextDrawHideForPlayer(playerid, MDCBOX);
TextDrawHideForPlayer(playerid, text9);
TextDrawHideForPlayer(playerid, text10);
TextDrawHideForPlayer(playerid, text11);
TextDrawHideForPlayer(playerid, text12);
new str2[256];
format(str2, sizeof(str2), " ");
TextDrawSetString(text32, str2);
return 1;
}
see? the textdraws i have gets hidden after 15000 Seconds
Re: [Help] Setting a timer to delay rest of command -
Ace_Menace - 19.07.2010
I just ran what I had through it's paces. Typed the command ingame waited 2 minutes, and nothing occured.
Anyways here's what I have so far:
pawn Код:
forward TaxiTimer();
public TaxiTimer()
{
new tmp[256];
new playa = ReturnUser(tmp);
new Float:Xb, Float:Yb, Float:Zb;
GetPlayerPos(playa, Xb, Yb, Zb);
new carid = CreateVehicle(438, Xb,Yb+5,Zb+1, 0.0, 6, 6, 60000);
CreatedCars[CreatedCar] = carid;
CreatedCar ++;
}
if(strcmp(cmd, "/gettaxi", true) == 0)
{
SendClientMessage(playerid, COLOR_HELP, "A Taxi is in-bound to your position in 2 Minutes");
SetTimer ("TaxiTimer", 120000,1);
return 1;
}
Re: [Help] Setting a timer to delay rest of command -
[HUN]Jaki - 19.07.2010
pawn Код:
forward CarTimer(Float:X, Float:Y, Float:Z);
pawn Код:
if(strcmp(cmd, "/getcar", true) == 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SendClientMessage(playerid, COLOR_HELP, "A car will be to your position in 2 Minutes");
SetTimer("CarTimer",60*2*1000, false, "%f %f %f", X, Y, Z);
return 1;
}
pawn Код:
public CarTimer(Float:X, Float:Y, Float:Z)
new carid = CreateVehicle(410, X,Y+5,Z+1, 0.0, 6, 6, 15);
CreatedCars[CreatedCar] = carid; // Part of la-rp base
CreatedCar ++; // Part of la-rp base
}
Not tested.
Re: [Help] Setting a timer to delay rest of command -
Ace_Menace - 19.07.2010
Just attempted to compile, and I get the following:
Код:
(2476) : error 025: function heading differs from prototype
(2478) : error 017: undefined symbol "Y"
(56470) : warning 202: number of arguments does not match definition
(56470) : warning 202: number of arguments does not match definition
(56470) : warning 202: number of arguments does not match definition
(56470) : warning 202: number of arguments does not match definition
I couldn't make sense of the errors
Note: I canged CarTimer to TaxiTimer
pawn Код:
public TaxiTimer(Float:X, Float:Z, Float:Z) //Line 2476
{
new carid = CreateVehicle(438, X,Y+5,Z+1, 0.0, 6, 6, 15); //Line 2478
CreatedCars[CreatedCar] = carid;
CreatedCar ++;
}
if(strcmp(cmd, "/gettaxi", true) == 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SendClientMessage(playerid, COLOR_HELP, "A car will be to your position in 2 Minutes");
SetTimer("TaxiTimer",60*2*1000, false, "%f %f %f", X, Y, Z); //Line 56470
return 1;
}
Re: [Help] Setting a timer to delay rest of command -
[HUN]Jaki - 20.07.2010
Sorry, it's SetTimerEx(), not SetTimer()...
And it does not need the % signs.
pawn Код:
if(strcmp(cmd, "/getcar", true) == 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SendClientMessage(playerid, COLOR_HELP, "A car will be to your position in 2 Minutes");
SetTimerEx("CarTimer",60*2*1000, false, "f f f", X, Y, Z);
return 1;
}
Re: [Help] Setting a timer to delay rest of command -
Ace_Menace - 20.07.2010
Thanks, it seems to have worked, although it unfortunately crashes my server
as soon as I type the command.