How do i make this into a timer ?
#1

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:

PHP Code:
             if(TruckerJob[playerid] == 2){
                
TruckerJob[playerid] = 3;
                
SetPlayerCheckpoint(playerid,2819.7258,-1685.1962,9.3214,10);
                
SendClientMessage(playeridCOLOR_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;
            } 
PHP Code:
public TimerOne(playerid)
{
    
SendClientMessage(playeridCOLOR_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?
Reply
#2

pawn Code:
SetTimerEx("TimerOne",30000,false,"u",playerid);
Reply
#3

Quote:
Originally Posted by Tanush123
View Post
pawn Code:
SetTimerEx("TimerOne",30000,false,"u",playerid);
didnt work .... =[
Reply
#4

Try adding it (that part Tanush put) after each SendClientMessage
Reply
#5

Quote:
Originally Posted by Tanush123
View Post
pawn Code:
SetTimerEx("TimerOne",30000,false,"u",playerid);
SetTimerEx doesn't support the parameter "u" ?
It supports: "i", "s", "a", "d", "f" and "b".

https://sampwiki.blast.hk/wiki/SetTimerEx

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

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

Quote:
Originally Posted by blewert
View Post
SetTimerEx doesn't support the parameter "u" ?
It supports: "i", "s", "a", "d", "f" and "b".

https://sampwiki.blast.hk/wiki/SetTimerEx

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

pawn Code:
//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 :

PHP Code:
#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(playeridcmdtext[])
{
    if (
strcmp("/job trucker"cmdtexttrue10) == 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] != && TruckerJob[playerid] != && TruckerJob[playerid] != 3){ TruckerJob[playerid] = 1; }
            new 
name[MAX_PLAYER_NAME], string[48];
            
GetPlayerName(playeridnamesizeof(name));
            
format(stringsizeof(string), "* %s is now a Trucker."name );
            
SendClientMessageToAll(COLOR_YELLOWstring);
    
// TRUCKER JOB #1
            
if(TruckerJob[playerid] == 1){
                
TruckerJob[playerid] = 2;
                
SetPlayerCheckpoint(playerid,1337.4010,-867.7301,38.7622,10);
                
SendClientMessage(playeridCOLOR_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"30000false"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(playeridCOLOR_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"30000false"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(playeridCOLOR_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"30000false"i"playerid );
                          return 
1;
                         }
                return 
1;
            }
            return 
1;
        }
        
SendClientMessage(playeridCOLOR_RED,"You have to be in a Truck cab to start the job");
    }
    return 
0;
}
forward TimerOne(playerid);
public 
TimerOne(playerid)
{
    
SendClientMessage(playeridCOLOR_RED,"You failed to re-attach trailer you have been fired.");
    
DisablePlayerCheckpoint(playerid);
    return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
     if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
     {
         
SendClientMessage(playeridCOLOR_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(playeridvehicleid)
{
    if(
TruckerJob[playerid] > 0)
    {
        
SendClientMessage(playeridCOLOR_RED"* You have left your job, you won't be payed.");
        
DisablePlayerCheckpoint(playerid);
    }

Reply
#7

Well lol my bad, i always use u and i have no problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)