Problem with a timer.
#1

I have do this:

pawn Код:
forward jailcountdown(playerid);
public jailcountdown(playerid)
{
    new time = 1000;
    new times[15];
    valstr(times,time);
    if(times == jTime)
    {
        KillTimer(timerjailcd);
        TextDrawHideForPlayer(playerid,intestajail);
        TextDrawHideForPlayer(playerid,contojail);
        return 1;
    }

    TextDrawSetString(contojail,times);
    times[14] = valstr(times,time+1000);
    return 1;
}
This is an function for a timer that will repeat each 1000ms, for the update of textdraw, but the function is repeat only one time, so my textdraw still 1000.

some one can help me?
thanks.
Reply
#2

The problem is probably on SetTimer(...) anyways change the code you currently have with this

pawn Код:
SetTimerEx("jailcountdown", 1000, true, "i", playerid);
Reply
#3

Quote:
Originally Posted by Patrick_
Посмотреть сообщение
The problem is probably on SetTimer(...) anyways change the code you currently have with this

pawn Код:
SetTimerEx("jailcountdown", 1000, true, "i", playerid);
I have do it but instead of playerid:

pawn Код:
CMD:ajail(playerid,params[])
{
    new stringa[128], pID;
    format(stringa,sizeof(stringa),"{FF0000}[SERVER]**{FFFFFF}You can't use this command, level so low or you aren't an admin");
    if(pinfo[playerid][adminlevel] < 3) return SendClientMessage(playerid,-1,stringa);
    format(stringa,sizeof(stringa),"{FF0000}[SERVER]**{FFFFFF}Use: /ajail [ID][time]");
    if(sscanf(params,"ui",pID,jTempo)) return SendClientMessage(playerid,-1,stringa);
    new randomid = random(sizeof(randomspawnsjail));
    SetPlayerPos(pID,randomspawnsjail[randomid][0],randomspawnsjail[randomid][1],randomspawnsjail[randomid][2]);
    SetPlayerInterior(pID,10);
    SetPlayerVirtualWorld(pID,100);
    format(stringa,128,"{FF0000}[SERVER]**{FFFFFF}You have been jailed for: %i ms, try to follow the rules the next time",jTempo);
    SendClientMessage(pID,-1,stringa);
    SetTimerEx("rilasciotimer",jTempo,false,"i",pID);
    TextDrawShowForPlayer(playerid,intestajail);
    TextDrawShowForPlayer(playerid,contojail);
   
    timerjailcd = SetTimerEx("jailcountdown",1000,true,"i",pID);
   
    return 1;
}
Reply
#4

Reflecting on the code I was able to find the solution.

pawn Код:
forward jailcountdown(playerid);
public jailcountdown(playerid)
{
    new stringat[20];
    valstr(stringat,jTempo);
   
    new stringaf[2];
    new fine = 0;
    valstr(stringaf,fine);
   
    if(strcmp(stringat,stringaf) == 0)
    {
        TextDrawHideForPlayer(playerid,intestajail);
        TextDrawHideForPlayer(playerid,contojail);
        KillTimer(timerjailcd);
    }
    jTempo = jTempo - 1000;
    TextDrawSetString(contojail,stringat);
    return 1;
}
This is a function that convert a value that i want that show in my textdraw, to string, because, the function SetTextdrawString, only can read strings. But i still looking for replace it from ms at seconds.. some one have ideaas?

Thanks anyways.
Reply
#5

Why do you compare strings ?

pawn Код:
forward jailcountdown(playerid);
public jailcountdown(playerid) {
    if(jTempo <= 0) {
        TextDrawHideForPlayer(playerid, intestajail);
        TextDrawHideForPlayer(playerid, contojail);
        KillTimer(timerjailcd);
    } else {
        new tmp[16];
        valstr(tmp, jTempo / 1000);
        jTempo = jTempo - 1000;
        TextDrawSetString(contojail, tmp);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)