Count Down Timer
#1

It's not counting down it just spamming numbers and i want to add a 30 timer.
Код:
forward TruckCheck(playerid);
public TruckCheck(playerid)
{
        if (IsPlayerInAnyVehicle(playerid) == 0)
        {
                const time = 10; //This would be 10sec
                //GameTextForPlayer(playerid,!"Get back in your TRUCK!~n~Or Reconnect your trailer!~n~[10]",1000,5);
                @countdown(playerid,time);
                return 1;
        }
        else if (IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)) == 0)
        {
            GameTextForPlayer(playerid, "Reconnect your trailer!", 1000, 5);
            return 1;
        }
        return 0;
}

@countdown(playerid,x);@countdown(playerid,x) {
    if(--x == 0)  return GameTextForPlayer(playerid,!"Los Los Los!",1000,5);
    new str[8];
    valstr(str,x);
    GameTextForPlayer(playerid,str,1000,5);
    return SetTimerEx(!"@countdown",999,0,!"ii",playerid,x);
}
inside my work command
Код:
SetTimerEx("TruckCheck", 1000, true, "i", playerid);
Reply
#2

Maybe something like this will work
PHP код:
new trckTime[MAX_PLAYERS];
forward TruckCheck(playerid);
public 
TruckCheck(playerid)
{
        if (
IsPlayerInAnyVehicle(playerid) == 0) {
                
truckTime[playerid]++;
                new 
str[64];
                
format(strsizeof(str), "Get back in your truck! [time left %d]"10 truckTime[playerid]);
                
GameTextForPlayer(istr10003);
                
                if (
truckTime[playerid] >= 10) {
                    
// Do stuff here
                    
truckTime[playerid] = 0;
                }
                return 
1;
        }
        else if (
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)) == 0)
        {
            
GameTextForPlayer(playerid"Reconnect your trailer!"10005);
            return 
1;
        }
        return 
0;

Reply
#3

Код:
(1427) : error 029: invalid expression, assumed zero
(1427) : warning 215: expression has no effect
(1427) : error 001: expected token: ";", but found "if"
(1427) : error 001: expected token: "*then", but found ")"
(1427) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
line 1427:
Код:
if (IsPlayerInAnyVehicle(playerid) == 0) && if IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)) == 0){
Код:
forward TruckCheck(playerid);
public TruckCheck(playerid)
{
        if (IsPlayerInAnyVehicle(playerid) == 0) && if IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)) == 0){
                truckTime[playerid]++;
                new str[128];
                format(str, sizeof(str), "Get back in your truck! ~n~or ~n~ Reconnect your trailer! ~n~(%d)", 30 - truckTime[playerid]);
                GameTextForPlayer(playerid, str, 3000, 3);
                PlayerPlaySound(playerid,1055,0.0,0.0,0.0);
                if (truckTime[playerid] >= 30) {
                    // Do stuff here

                    truckTime[playerid] = 0;
                    KillTimer(truckchecktime);
                    StopPlayerJob(playerid);
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You failed the mission!");

                }
                return 1;
        }
        return 0;
}
Reply
#4

I get this errors^
Reply
#5

Код:
if (!IsPlayerInAnyVehicle(playerid) && !IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)){
Reply
#6

Line 1499:
Код:
{
Код:
  if (!IsPlayerInAnyVehicle(playerid) && !IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))
		{
Код:
(1499) : error 001: expected token: ")", but found "{"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Код:
public TruckCheck(playerid)
{
        if (!IsPlayerInAnyVehicle(playerid) && !IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))
		{
                truckTime[playerid]++;
                new str[128];
                format(str, sizeof(str), "Get back in your truck! ~n~or ~n~ Reconnect your trailer! ~n~(%d)", 30 - truckTime[playerid]);
                GameTextForPlayer(playerid, str, 1000, 3);
                PlayerPlaySound(playerid,1055,0.0,0.0,0.0);
                if (truckTime[playerid] >= 30) {
                    // Do stuff here

                    truckTime[playerid] = 0;
                    KillTimer(truckchecktime);
                    StopPlayerJob(playerid);
                    //format(str, sizeof(str), "");
                    //GameTextForPlayer(playerid, str, 0, 3);
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You failed the mission!");

                }
                return 1;
        }
        return 0;
}
Reply
#7

PHP код:
forward TruckCheck(playerid);
public 
TruckCheck(playerid)
{
    new 
attachedtrailer GetPlayerVehicleID(playerid);
    new 
str[128];
    if (!
IsPlayerInAnyVehicle(playerid) && !IsTrailerAttachedToVehicle(attachedtrailer)) {
            
truckTime[playerid]++;
            
format(strsizeof(str), "Get back in your truck! ~n~or ~n~ Reconnect your trailer! ~n~(%d)"30 truckTime[playerid]);
            
GameTextForPlayer(playeridstr30003);
            
PlayerPlaySound(playerid,1055,0.0,0.0,0.0);
            if (
truckTime[playerid] >= 30) {
                
KillTimer(truckchecktime);
                
StopPlayerJob(playerid);
                
SendClientMessage(playeridCOLOR_LIGHTGREEN"You failed the mission!");
                
truckTime[playerid] = 0;
            }
            return 
1;
    }
    return 
0;

Reply
#8

Код:
if (!IsPlayerInAnyVehicle(playerid) && !IsTrailerAttachedToVehicle(attachedtrailer)){
Код:
(1502) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#9

copy and paste again, I edited it, but guess you already were copied.
Reply
#10

When i don't have a trailer it don't show the gametext. When i get out of the truck it shows but not the trailer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)