SA-MP Forums Archive
How to make a timer.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to make a timer.. (/showthread.php?tid=465952)



How to make a timer.. - CesarLT - 25.09.2013

Hello everyone, I am willing to make a timer which will be shown if a player join the race, and how to make that to be shown only to the people who are in the race itself?

It shall be something like that:

the race will start\n3, the race will start\n2..etc.

Thanks in advance.


Re: How to make a timer.. - JamesH - 25.09.2013

this on top of script
pawn Код:
new subscribeds;
new racers[MAX_PLAYERS]=-1;
The timer
forward RaceTimer(numero);
pawn Код:
public RaceTimer(numero){
    new str[50];
    new Float:pX,Float:pY,Float:pZ;
    if(numero>0){
            for(new i = 0; i < subscribeds; i++){
                format(str, sizeof (str), "~r~[][] %d[][]", numero);
                if (IsPlayerConnected(racers[i])){ // the racers is a variable that check if the player is in a race. thats up to you change.
                    GameTextForPlayer(racers[i], str, 1200, 3); // the racers is a variable that check if the player is in a race. thats up to you change.
                    if(numero<6){
                        GetPlayerPos(i,pX,pY,pZ);
                        PlayerPlaySound(i,1056,pX,pY,pZ);
                    }
                }
            }
            numero--;
            SetTimerEx("CD",1000,0,"i",numero);
    }
    else{
          for(new i = 0; i < subscribeds; i++){
                if (IsPlayerConnected(racers[i])){ // the racers is a variable that check if the player is in a race. thats up to you change.
                    GameTextForPlayer(racers[i], "~g~[][][]  GO!! [][][]!!!", 1200, 3); // the racers is a variable that check if the player is in a race. thats up to you change.
                    PlayerPlaySound(i,1057,pX,pY,pZ);
                }
            }
    }
    return 1;
}
And where the player joins the race add SEE BELOW
pawn Код:
racers[subscribeds]=playerid;
Good luck


Re: How to make a timer.. - CesarLT - 25.09.2013

Quote:
Originally Posted by JamesH
Посмотреть сообщение
this on top of script
pawn Код:
new subscribeds;
new racers[MAX_PLAYERS]=-1;
The timer
forward RaceTimer(numero);
pawn Код:
public RaceTimer(numero){
    new str[50];
    new Float:pX,Float:pY,Float:pZ;
    if(numero>0){
            for(new i = 0; i < subscribeds; i++){
                format(str, sizeof (str), "~r~[][] %d[][]", numero);
                if (IsPlayerConnected(racers[i])){ // the racers is a variable that check if the player is in a race. thats up to you change.
                    GameTextForPlayer(racers[i], str, 1200, 3); // the racers is a variable that check if the player is in a race. thats up to you change.
                    if(numero<6){
                        GetPlayerPos(i,pX,pY,pZ);
                        PlayerPlaySound(i,1056,pX,pY,pZ);
                    }
                }
            }
            numero--;
            SetTimerEx("CD",1000,0,"i",numero);
    }
    else{
          for(new i = 0; i < subscribeds; i++){
                if (IsPlayerConnected(racers[i])){ // the racers is a variable that check if the player is in a race. thats up to you change.
                    GameTextForPlayer(racers[i], "~g~[][][]  GO!! [][][]!!!", 1200, 3); // the racers is a variable that check if the player is in a race. thats up to you change.
                    PlayerPlaySound(i,1057,pX,pY,pZ);
                }
            }
    }
    return 1;
}
And where the player joins the race add SEE BELOW
pawn Код:
racers[subscribeds]=playerid;
Good luck
Wow, would never figure that out by myself lol...
Thanks alot.


Re: How to make a timer.. - JamesH - 25.09.2013

Sure, update here if you need anything else.