[HELP]Countdown
#1

hey guys im making an Countdown system ,
its all like this

GameTextForAll("1",2000,3);

but it show to all player who are play on my server , ,

i want it to show only around 20meter . . how can i do like that ?

Help Rep+!
Reply
#2

Get your position (If you don't have a certain position for the cd) (GetPlayerPos), loop through all the connected players (Read about Loops), use IsPlayerInRangeOfPoint to detect if a player is in the range of the point you want (You might use the one we got by GetPlayerPos) then show the game text for that player (GameTextForPlayer). I'm here if ya get stuck, just ask.
Reply
#3

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
Get your position (If you don't have a certain position for the cd) (GetPlayerPos), loop through all the connected players (Read about Loops), use IsPlayerInRangeOfPoint to detect if a player is in the range of the point you want (You might use the one we got by GetPlayerPos) then show the game text for that player (GameTextForPlayer). I'm here if ya get stuck, just ask.
can ya show me how to do that ?
im still learning and idk more bout scripting , :\
Reply
#4

Kinda like this

pawn Код:
// top
new Count, Timer[MAX_PLAYERS];

// goes under OnPlayerCommandText. It's a command for the count down
if (strcmp("/countdown", cmdtext, true) == 0)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    Timer[playerid] = SetTimerEx("CountDown", 1000, true, "d", playerid); // Declaring a timer to call the public CountDown every 1 second
    for(new i; i < MAX_PLAYERS; i ++) // looping through all players
    {
        if(IsPlayerConnected(i)) // if connected
        {
            if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if they are in your range
            {
                new str[4];
                Count = 5; // setting the countdown to 5 .. you can change that
                format(str, sizeof(str), "%d", Count); // formatting a string to use it in GameTextForPlayer
                GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
            }
        }
    }
    return 1;
}

forward CountDown(playerid);

public CountDown(playerid)
{
    Count --; // decreasing Count by one
    if(Count == 0) // if Count reaches 0
    {
        KillTimer(Timer[playerid]); // kill the cd timer
        // your codes when the cd ends go here
        return 1; // to stop it
    }
    // so it's not = 0
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z); // getting the player position again (he probably has moved!)
    new str[4];
    format(str, sizeof(str), "%d", Count); // formatting a string with the new decreased Count
    for(new i; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if he is in your range
            {
                GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
            }
        }
    }
    return 1;
}
Reply
#5

let me try this first
Reply
#6

i just need this to start the cd or not ?
Reply
#7

I think everything is explained enough. Well follow my comments until you get it to compile fine then go in-game and type /countdown.
Reply
#8

okay . .
i need help with this simple question

this is the Text

5
4
3
2
1

right , but how can i add after 1 GO GO GO!!
Reply
#9

Very simple

pawn Код:
// top
new Count, Timer[MAX_PLAYERS];

// goes under OnPlayerCommandText. It's a command for the count down
if (strcmp("/countdown", cmdtext, true) == 0)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    Timer[playerid] = SetTimerEx("CountDown", 1000, true, "d", playerid); // Declaring a timer to call the public CountDown every 1 second
    for(new i; i < MAX_PLAYERS; i ++) // looping through all players
    {
        if(IsPlayerConnected(i)) // if connected
        {
            if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if they are in your range
            {
                new str[4];
                Count = 5; // setting the countdown to 5 .. you can change that
                format(str, sizeof(str), "%d", Count); // formatting a string to use it in GameTextForPlayer
                GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
            }
        }
    }
    return 1;
}

forward CountDown(playerid);

public CountDown(playerid)
{
    Count --; // decreasing Count by one
    if(Count == 0) // if Count reaches 0
    {
        KillTimer(Timer[playerid]); // kill the cd timer
        // your codes when the cd ends go here
        GameTextForPlayer(i, "GO GO GO!!, 3000, 3);
        return 1; // to stop it
    }
    // so it's not = 0
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z); // getting the player position again (he probably has moved!)
    new str[4];
    format(str, sizeof(str), "
%d", Count); // formatting a string with the new decreased Count
    for(new i; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) // if he is in your range
            {
                GameTextForPlayer(i, str, 3000, 3); // showing the gametext for that player in your range
            }
        }
    }
    return 1;
}
I simply copied his code and added it in as another GameText.
Reply
#10

I typed this comment there for a reason!
pawn Код:
// your codes when the cd ends go here
Reply
#11

when i add that
pawn Код:
GameTextForPlayer(i, "GO GO GO!!, 3000, 3);
pawn Код:
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : error 017: undefined symbol "i"
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : error 017: undefined symbol "GO"
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : error 017: undefined symbol "GO"
C:\Users\user\Desktop\SERVER\gamemodes\DriftZoneX.pwn(842) : fatal error 107: too many error messages on one line
Reply
#12

Sorry about that, wasn't paying attention

Change that to this:

pawn Код:
GameTextForPlayer(playerid, "GO GO GO!!", 3000, 3);
Reply
#13

Works and Perfect ! Rep+
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)