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: player_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);
return 1;
}
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);
}
return 1;
}
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;
}
You figure out the rest, Einstein.