need help
#1

can someone give me an example code that show the player remaining time using gametext..and the remaining time format is in minutes and second..i'll use the code for reference...and maybe useful if i want to make a robbery timer...just share the code..i can edit the code later...i hope someone will help me
Reply
#2

you want to make a countdown ?
Reply
#3

nope not count down....its remaining time that show player how much time left on sceen using gametext..like when you play cnr and you want to rob burger shot..you will notice how much time left before the robbery is complete..i want that time left script in format minutes and seconds
Reply
#4

Actually, "time remaining" and a "countdown" is exactly the same thing.
pawn Код:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>
#include <sscanf2>
#include <zcmd>

// DEFINES:

// FUNCTIONS:

#define function%0(%1) forward%0(%1); public%0(%1)
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)

// PER-PLAYER VARIABLES:

// GENERAL:

new pCountdown[MAX_PLAYERS],
pCountdownText[MAX_PLAYERS][2][128];

// TIMERS:

new tmPlayerCountdown[MAX_PLAYERS];

// MAIN:

main()
{
    print("Development Mode: countdown.amx");
}

// CALLBACKS:

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// COMMANDS:

CMD:playercountdown(playerid, params[])
{
    new time;
    if(sscanf(params, "i", time)) return SendClientMessage(playerid, -1, "Usage: /countdown (time in seconds).");
    if(time <= 0) return SendClientMessage(playerid, -1, "You have entered an invalid number.");

    SetPlayerCountdown(playerid, time, "Player countdown: ", "Countdown over!");
    return 1;
}

// FUNCTIONS:

stock SetPlayerCountdown(playerid, time, interval_text[], complete_text[])
{
    pCountdown[playerid] = time + 1;
    strcpy(pCountdownText[playerid][0], interval_text, 128);
    strcpy(pCountdownText[playerid][1], complete_text, 128);

    KillTimer(tmPlayerCountdown[playerid]);
    tmPlayerCountdown[playerid] = SetTimerEx("PlayerCountdown", 1000, true, "i", playerid);
}

function PlayerCountdown(playerid)
{
    new string[144];
    pCountdown[playerid] --;

    if(pCountdown[playerid] <= 0)
    {
        GameTextForPlayer(playerid, pCountdownText[playerid][1], 5000, 3);

        KillTimer(tmPlayerCountdown[playerid]);
    }
    else
    {
        format(string, sizeof(string), "%s%s", pCountdownText[playerid][0], ConvertToMinutes(pCountdown[playerid]));
        GameTextForPlayer(playerid, string, 5000, 3);
    }
}

stock ConvertToMinutes(time)
{
    new string[10], minutes, seconds;
    if(time > 59)
    {
        minutes = floatround(time / 60);
        seconds = floatround(time - minutes * 60);
        format(string, sizeof(string), "%01d:%02d", minutes, seconds);
    }
    else
    {
        seconds = floatround(time);
        format(string, sizeof(string), "0:%02d", seconds);
    }
    return string;
}
Usage:
pawn Код:
SetPlayerCountdown(playerid, time, interval_text[], complete_text[]);
During the interval of the countdown, interval_text[] + countdown progress in format of minutes:


When the countdown finishes, complete_text[]:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)