SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/11/2011, 08:35 PM   #1
English-Conceptz
Big Clucker
 
Join Date: Oct 2011
Posts: 148
Reputation: 8
Default How do i make this into a timer ?

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?
English-Conceptz is offline   Reply With Quote
Old 26/11/2011, 10:31 PM   #2
Tanush123
High-roller
 
Tanush123's Avatar
 
Join Date: Aug 2011
Posts: 1,022
Reputation: 65
Default Re: How do i make this into a timer ?

pawn Code:
SetTimerEx("TimerOne",30000,false,"u",playerid);
Tanush123 is offline   Reply With Quote
Old 26/11/2011, 10:42 PM   #3
English-Conceptz
Big Clucker
 
Join Date: Oct 2011
Posts: 148
Reputation: 8
Default Re: How do i make this into a timer ?

Quote:
Originally Posted by Tanush123 View Post
pawn Code:
SetTimerEx("TimerOne",30000,false,"u",playerid);
didnt work .... =[
English-Conceptz is offline   Reply With Quote
Old 26/11/2011, 10:48 PM   #4
VanHalen9898
Little Clucker
 
Join Date: Nov 2011
Posts: 22
Reputation: 0
Default Re: How do i make this into a timer ?

Try adding it (that part Tanush put) after each SendClientMessage
VanHalen9898 is offline   Reply With Quote
Old 26/11/2011, 10:54 PM   #5
blewert
Huge Clucker
 
blewert's Avatar
 
Join Date: Jan 2008
Location: Wales
Posts: 231
Reputation: 140
Default Re: How do i make this into a timer ?

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".

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:

pawn Code:
//Set a timer to call TimerOne with the 1st argument as the player's id.
SetTimerEx( "TimerOne", 30000, false, "i", playerid );
__________________
littlewhitey's SA-MP server
[/center]
blewert is offline   Reply With Quote
Old 26/11/2011, 11:08 PM   #6
English-Conceptz
Big Clucker
 
Join Date: Oct 2011
Posts: 148
Reputation: 8
Default Re: How do i make this into a timer ?

Quote:
Originally Posted by blewert View Post
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:

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);
    }

English-Conceptz is offline   Reply With Quote
Old 27/11/2011, 12:55 AM   #7
Tanush123
High-roller
 
Tanush123's Avatar
 
Join Date: Aug 2011
Posts: 1,022
Reputation: 65
Default Re: How do i make this into a timer ?

Well lol my bad, i always use u and i have no problem
Tanush123 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make such timer? ajwar Scripting Help 1 25/08/2011 07:17 PM
how to make timer gives little bit hp? the_zande Help Archive 2 24/04/2011 11:37 PM
[HELP] /robbank Timer, how can i make one? marszim Help Archive 11 07/01/2010 12:03 PM
[HELP] how i make a timer? jordylol6 Help Archive 2 05/01/2010 04:33 PM
[help] how do i make a 24hour timer? Mowgli Help Archive 3 16/10/2009 03:56 PM


All times are GMT. The time now is 11:41 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.