help with count down secounts
#1

pawn Код:
CMD:jail(playerid, params[])
{
    if(IsPlayerAdmin2[playerid] == 2)
    {
        new targetid, reason[128], msg[64], name[46];
        if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /jail [id] [reason]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "That player is not online.");
        GetPlayerName(playerid, name, sizeof(name));
        format(msg, sizeof(msg), "%s was jailed. Reason: %s. Time: 120sec.", name, reason);
        SendClientMessageToAll(COLOR_RED, msg);
        SetTimer("jailtime", 120000, false);
        SetPlayerInterior(targetid, 6);
        SetPlayerPos(targetid, 265.34756469727, 77.521759033203, 1001.0390625);
        return 1;
    }
    return 1;
}
how i can make to show player text draw and count down from 120sec. :/
Thanks
Reply
#2

Код:
new Jailed[MAX_PLAYERS], JailTime[MAX_PLAYERS];
In command set:
Код:
Jailed[playerid] = 1;
JailTime[playerid] = 120;
Down of your script:
Код:
forward jailtime(playerid);
public jailtime(playerid)
{
if(Jailed[playerid])
{
format (format your TextDraw with time)
TextDrawSetString
TextDrawShowForPlayer
		
JailTime[playerid] -= 1;

if(JailTime[playerid] == -1)
{
Jailed[playerid] = 0;
// Unjail player here.
}
return true;
}
And in command use SetTimerEx with looping.
Reply
#3

UPDATED.

Made a func, will work i guess. (Ignore the warning).
pawn Код:
forward TimeTextDrawShowForPlayer(playerid, Text:textid, second);
public TimeTextDrawShowForPlayer(playerid, Text:textid, second)
{
    if(second == -1337) { TextDrawHideForPlayer(playerid, textid); }
    else {
        TextDrawShowForPlayer(playerid, textid);
        SetTimerEx("TimeTextDrawShowForPlayer", second*1000, false, "ddd", playerid, textid, -1337);
    }
    return true;
}
Use it like this:
pawn Код:
new Text:lol;

//Somewhere:
lol = TextDrawCreate(86.000000, 91.000000, "lol");

//Whereever you like:
TimeTextDrawShowForPlayer(playerid, lol, 120);
//This will show "lol" on playerid's screen for 120 seconds.
//Just don't use -times.
Reply
#4

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
**Oh wait a minute, seems like i failed. Updating post.

Made a func, will work i guess. (Ignore the warning).
pawn Код:
forward TimeTextDrawShowForPlayer(playerid, Text:textid, second);
public TimeTextDrawShowForPlayer(playerid, Text:textid, second)
{
    if(second == -1337) { TextDrawHideForPlayer(playerid, textid); }
    else {
        TextDrawShowForPlayer(playerid, textid);
        SetTimerEx("TimeTextDrawShowForPlayer", second*1000, false, "ddd", playerid, textid, -1337);
    }
    return true;
}
Use it like this:
pawn Код:
new Text:lol;

//Somewhere:
lol = TextDrawCreate(86.000000, 91.000000, "lol");

//Whereever you like:
TimeTextDrawShowForPlayer(playerid, lol, 120);
//This will show "lol" on playerid's screen for 120 seconds.
//Just don't use -times.
for what is that -1337 does i need to change in the secounts like 120000 ??
and secound*1000 ? :/
Reply
#5

This will work (the one before isn't good for you )

Here (No extra Variables required):
pawn Код:
forward CountdownTextDraw(playerid, Text:textid, secondstocount);
public CountdownTextDraw(playerid, Text:textid, secondstocount)
{
    if(secondstocount == 0) { TextDrawHideForPlayer(playerid, textid); }
    else {
        new timestring[32];
        format(timestring, sizeof(timestring), "%i seconds remaining..", secondstocount);
        TextDrawSetString(textid, timestring);
        TextDrawShowForPlayer(playerid, textid);
        secondstocount--;
        SetTimerEx("CountdownTextDraw", 1000, false, "ddd", playerid, textid, secondstocount);
    }
    return true;
}
Example usage:
pawn Код:
new Text:JailTextDraw;

    JailTextDraw = TextDrawCreate(327.000000, 377.000000, "X");
    TextDrawAlignment(JailTextDraw, 2);
    TextDrawBackgroundColor(JailTextDraw, 255);
    TextDrawFont(JailTextDraw, 2);
    TextDrawLetterSize(JailTextDraw, 0.620000, 3.200000);
    TextDrawColor(JailTextDraw, -1);
    TextDrawSetOutline(JailTextDraw, 0);
    TextDrawSetProportional(JailTextDraw, 1);
    TextDrawSetShadow(JailTextDraw, 1);

CountdownTextDraw(playerid, JailTextDraw, 120);
Reply
#6

thanks man it works xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)