PDA

View Full Version : How do i make this into a timer ?


English-Conceptz
26/11/2011, 08:35 PM
hi i need a timer checking if the trailer has become detached from my truck whilst going to a checkpoint

if so i want something like:


Run this timer now:
ifTrailerDetachedFromVehicle during mission do this....
client message " you have 30 seconds to re-attach trailer or you will fail your mission
set timer
public timer
disablecheckpoint;


ive tried this in my job if statement but it didnt work:


if(TruckerJob[playerid] == 2){
TruckerJob[playerid] = 3;
SetPlayerCheckpoint(playerid,2819.7258,-1685.1962,9.3214,10);
SendClientMessage(playerid, COLOR_RED, "Deliver Xtreme Team supplies to the stadium");
if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID( playerid)))
{
SendClientMessage(playerid,COLOR_RED,"re-attach trailer within 30 seconds or job failed!");
SetTimer("TimerOne",30000,false);
return 1;
}
return 1;
}


public TimerOne(playerid)
{
SendClientMessage(playerid, COLOR_RED,"You failed to re-attach trailer you have been fired.");
DisablePlayerCheckpoint(playerid);
return 1;
}


but it didnt work because i need to have it running inside a timer constantly when on a mission, how the fuck do i do this ? helppppp????

Tanush123
26/11/2011, 10:31 PM
SetTimerEx("TimerOne",30000,false,"u",playerid);

English-Conceptz
26/11/2011, 10:42 PM
SetTimerEx("TimerOne",30000,false,"u",playerid);

didnt work .... =[

VanHalen9898
26/11/2011, 10:48 PM
Try adding it (that part Tanush put) after each SendClientMessage

blewert
26/11/2011, 10:54 PM
SetTimerEx("TimerOne",30000,false,"u",playerid);

SetTimerEx doesn't support the parameter "u" ?
It supports: "i", "s", "a", "d", "f" and "b".

http://wiki.sa-mp.com/wiki/SetTimerEx

Seeing as we're passing an integer (the player's id) we'd use "d" or "i". Try:


//Set a timer to call TimerOne with the 1st argument as the player's id.
SetTimerEx( "TimerOne", 30000, false, "i", playerid );

English-Conceptz
26/11/2011, 11:08 PM
SetTimerEx doesn't support the parameter "u" ?
It supports: "i", "s", "a", "d", "f" and "b".

http://wiki.sa-mp.com/wiki/SetTimerEx

Seeing as we're passing an integer (the player's id) we'd use "d" or "i". Try:


//Set a timer to call TimerOne with the 1st argument as the player's id.
SetTimerEx( "TimerOne", 30000, false, "i", playerid );

i tried this instead of "u" and it still does nothing =/

i think the if statement doesnt work or is the wrong type of function or is in the wrong place ? anyone? il post the entire script now :


#include <a_samp>

#define COLOR_DARKGOLD 0x808000AA
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA

new TruckerJob[256];

public OnFilterScriptInit()
{
AddStaticVehicle(403,2057.3081,-1939.9397,13.9432,270.4501,6,6); // Truck (Spawn Front)
AddStaticVehicle(591,2045.2939,-1939.9041,13.0633,268.2366,6,6); // Trailer (Spawn Back)
AddStaticVehicle(403,2032.4635,-1939.7537,13.9389,271.0817,6,6); // Truck (Spawn Front)
AddStaticVehicle(591,2020.9797,-1940.1196,13.9476,270.5276,6,6); // Trailer (Spawn Back)
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/job trucker", cmdtext, true, 10) == 0)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
{
if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID( playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); return 1; }
if(TruckerJob[playerid] != 1 && TruckerJob[playerid] != 2 && TruckerJob[playerid] != 3){ TruckerJob[playerid] = 1; }

new name[MAX_PLAYER_NAME], string[48];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "* %s is now a Trucker.", name );
SendClientMessageToAll(COLOR_YELLOW, string);

// TRUCKER JOB #1

if(TruckerJob[playerid] == 1){
TruckerJob[playerid] = 2;
SetPlayerCheckpoint(playerid,1337.4010,-867.7301,38.7622,10);
SendClientMessage(playerid, COLOR_RED, "Deliver food supplies to Roboi's Food Mart");

if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID( playerid)))
{
SendClientMessage(playerid,COLOR_RED,"re-attach trailer within 30 seconds or job failed!");
SetTimerEx( "TimerOne", 30000, false, "i", playerid );
return 1;
}
return 1;
}

// TRUCKER JOB #2

if(TruckerJob[playerid] == 2){
TruckerJob[playerid] = 3;
SetPlayerCheckpoint(playerid,2819.7258,-1685.1962,9.3214,10);
SendClientMessage(playerid, COLOR_RED, "Deliver Xtreme Team supplies to the stadium");
if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID( playerid)))
{
SendClientMessage(playerid,COLOR_RED,"re-attach trailer within 30 seconds or job failed!");
SetTimerEx( "TimerOne", 30000, false, "i", playerid );
return 1;
}
return 1;
}

// TRUCKER JOB #3

if(TruckerJob[playerid] == 3){
TruckerJob[playerid] = 1;
SetPlayerCheckpoint(playerid,-65.8111,-1161.3187,1.1491,10);
SendClientMessage(playerid, COLOR_RED, "Deliver car parts to the gas station next to 'RS Haul'");
if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID( playerid)))
{
SendClientMessage(playerid,COLOR_RED,"re-attach trailer within 30 seconds or job failed!");
SetTimerEx( "TimerOne", 30000, false, "i", playerid );
return 1;
}
return 1;
}
return 1;
}
SendClientMessage(playerid, COLOR_RED,"You have to be in a Truck cab to start the job");
}
return 0;
}

forward TimerOne(playerid);

public TimerOne(playerid)
{
SendClientMessage(playerid, COLOR_RED,"You failed to re-attach trailer you have been fired.");
DisablePlayerCheckpoint(playerid);
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
{
SendClientMessage(playerid, COLOR_RED, "* You can start Trucking by typing /job trucker");
}
return 0;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
{
if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID( playerid)))
{
SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!");
DisablePlayerCheckpoint(playerid);
return 1;
}
GivePlayerMoney(playerid,500);
SendClientMessage(playerid,COLOR_YELLOW,"* You have earned $500!");
DisablePlayerCheckpoint(playerid);
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(TruckerJob[playerid] > 0)
{
SendClientMessage(playerid, COLOR_RED, "* You have left your job, you won't be payed.");
DisablePlayerCheckpoint(playerid);
}
}

Tanush123
27/11/2011, 12:55 AM
Well lol my bad, i always use u and i have no problem