CountTimer Not Working Properly!
#1

I type /startevent 25 ihopeitworks It shows the dialog and The counter works cause i have it call on something at the end.. well it shows ihopeitworks 53 and it doesnt change.. any Ideals?

pawn Код:
#include <a_samp>
#include <zcmd>


#define BLUE 0x000FFFFF
#define ORANGE 0xFF7800FF
#define WARNING 0x00FFFFFF


forward StartRandomEvent();
forward RandomEvent1(playerid);
forward RandomEvent2(playerid);

new seconds;
new ETimer;
new Text:EventDraw[MAX_PLAYERS] = Text:INVALID_TEXT_DRAW;
new TimerShowing[MAX_PLAYERS];
new EventTimer;
new RandomEvent[][] =
{
    "RandomEvent1",
    "RandomEvent2"
};

public OnFilterScriptInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    EventDraw[i] = TextDrawCreate(1.000000, 426.000000, " ");
    TextDrawBackgroundColor(EventDraw[i], 65535);
    TextDrawFont(EventDraw[i], 1);
    TextDrawLetterSize(EventDraw[i], 0.500000, 1.000000);
    TextDrawColor(EventDraw[i], 16777215);
    TextDrawSetOutline(EventDraw[i], 1);
    TextDrawSetProportional(EventDraw[i], 1);
    TextDrawUseBox(EventDraw[i], 1);
    TextDrawBoxColor(EventDraw[i], 255);
    TextDrawTextSize(EventDraw[i], 639.000000, 0.000000);
    }
    //EventTimer = SetTimer("StartRandomEvent",5000,true);
    return 1;
}

CMD:startevent(playerid,params[])
{
    new eventname[128],Estring[256],tstr[5];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {

        if(TimerShowing[i] == 1)
        {
           // EventTimer = SetTimer("StartRandomEvent",150000,true);
            TimerShowing[i] = 0;
            TextDrawHideForPlayer(i, EventDraw[i]);
        }
        else
        {
            if(sscanf(params, "ds",seconds,eventname)) return SendClientMessage(playerid, WARNING, "/startevent time discription ");
            if(seconds < 1 || seconds > 1000000) return SendClientMessage(playerid, WARNING, "Allowed Eventimes Seconds 1-1000000");
            ETimer = SetTimerEx("RandomEvent1",seconds*1000, false,"i", i); // Set a repeated timer of 1000 miliseconds (1 second)
            KillTimer(EventTimer);
            format(tstr,sizeof(tstr),"%d",ETimer);
            format(Estring,sizeof(Estring),"Event: %s Starts in: %d Seconds",eventname,tstr);
            TextDrawShowForPlayer(i, EventDraw[i]);
            TextDrawSetString(EventDraw[i],Estring);
            TimerShowing[playerid] = 1;
           
        }
    }
    return 1;
}

CMD:eventhelp(playerid,params[])
{
    SendClientMessage(playerid, BLUE,"$$$$====$$$$====$$$$ Event $$$ Help $$$$====$$$$====$$$$");
    SendClientMessage(playerid, ORANGE,"/startevent /stopevent ");
    return 1;
}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    TextDrawHideForAll(EventDraw[i]);
    TextDrawDestroy(EventDraw[i]);
    KillTimer(EventTimer);
    }
    return 1;
}

public StartRandomEvent()
{
    new RandEvent = random(sizeof(RandomEvent));
    SetTimer(RandomEvent[RandEvent] ,5000,false);
    return 1;
}


public RandomEvent1(playerid)
{
    new msg[64];
    for(new i; i < MAX_PLAYERS; i++)
    {
        format(msg,sizeof(msg),"~g~IT ~b~WORKED");
        GameTextForAll(msg,5000,3);
        TextDrawHideForAll(EventDraw[i]);
        //TextDrawDestroy(EventDraw[i]);
        KillTimer(ETimer);
    }
    KillTimer(EventTimer);
    return 1;
}

public RandomEvent2(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {

    }
    KillTimer(EventTimer);
    return 1;
}
Any Suggestions Please Comment.. Thanks A Million..
Reply
#2

try this
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>


#define BLUE 0x000FFFFF
#define ORANGE 0xFF7800FF
#define WARNING 0x00FFFFFF


forward StartRandomEvent();
forward RandomEvent1(playerid);
forward RandomEvent2(playerid);


new seconds;
new ETimer;
new Text:EventDraw[MAX_PLAYERS];
new TimerShowing[MAX_PLAYERS];
new EventTimer;
new RandomEvent[][] =
{
    "RandomEvent1",
    "RandomEvent2"
};

public OnFilterScriptInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    EventDraw[i] = TextDrawCreate(1.000000, 426.000000, " ");
    TextDrawBackgroundColor(EventDraw[i], 65535);
    TextDrawFont(EventDraw[i], 1);
    TextDrawLetterSize(EventDraw[i], 0.500000, 1.000000);
    TextDrawColor(EventDraw[i], 16777215);
    TextDrawSetOutline(EventDraw[i], 1);
    TextDrawSetProportional(EventDraw[i], 1);
    TextDrawUseBox(EventDraw[i], 1);
    TextDrawBoxColor(EventDraw[i], 255);
    TextDrawTextSize(EventDraw[i], 639.000000, 0.000000);
    }
    //EventTimer = SetTimer("StartRandomEvent",5000,true);
    return 1;
}

public OnPlayerSpawn(playerid)
{

    return 1;
}

CMD:startevent(playerid,params[])
{
    new eventname[128],Estring[256],tstr[5];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {

        if(TimerShowing[i] == 1)
        {
            EventTimer = SetTimer("StartRandomEvent",150000,true);
            TimerShowing[i] = 0;
            TextDrawHideForPlayer(i, EventDraw[i]);
        }
        else
        {
            if(sscanf(params, "ds",seconds,eventname)) return SendClientMessage(playerid, WARNING, "/startevent time discription ");
            if(strval(seconds) < 1 || strval(seconds) > 1000000) return SendClientMessage(playerid, WARNING, "Allowed Eventimes Seconds 1-1000000");
            ETimer = SetTimerEx("RandomEvent1",seconds*1000, false,"i", i); // Set a repeated timer of 1000 miliseconds (1 second)
            KillTimer(EventTimer);
            format(tstr,sizeof(tstr),"%d",ETimer);
            format(Estring,sizeof(Estring),"Event: %s Starts in: %d Seconds",eventname,tstr);
            TextDrawShowForPlayer(i, EventDraw[i]);
            TextDrawSetString(EventDraw[i],Estring);
            TimerShowing[playerid] = 1;
           
        }
    }
    return 1;
}

CMD:eventhelp(playerid,params[])
{
    SendClientMessage(playerid, BLUE,"$$$$====$$$$====$$$$ Event $$$ Help $$$$====$$$$====$$$$");
    SendClientMessage(playerid, ORANGE,"/startevent /stopevent ");
    return 1;
}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    TextDrawHideForAll(EventDraw[i]);
    TextDrawDestroy(EventDraw[i]);
    KillTimer(EventTimer);
    }
    return 1;
}

public StartRandomEvent()
{
    new RandEvent = random(sizeof(RandomEvent));
    SetTimer(RandomEvent[RandEvent] ,5000,false);
    return 1;
}


public RandomEvent1(playerid)
{
    new msg[64];
    for(new i; i < MAX_PLAYERS; i++)
    {
        format(msg,sizeof(msg),"~g~IT ~b~WORKED");
        GameTextForAll(msg,5000,3);
        TextDrawHideForAll(EventDraw[i]);
        //TextDrawDestroy(EventDraw[i]);
        KillTimer(ETimer);
    }
    KillTimer(EventTimer);
    return 1;
}

public RandomEvent2(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {

    }
    KillTimer(EventTimer);
    return 1;
}
Reply
#3

No the line you edited That lines works perfectly Just the problem i have is getting the Textdraw to count down the time i entered .. if just enter a random number it says my event message starts in 56 witch not the number i typed .. and it doesnt change...
Reply
#4

Is it Okay to Bump this?
Reply
#5

Oops let me update my post i done tried that still just random shows a number and does nothing

pawn Код:
#include <a_samp>
#include <zcmd>


#define BLUE 0x000FFFFF
#define ORANGE 0xFF7800FF
#define WARNING 0x00FFFFFF


forward StartRandomEvent();
forward RandomEvent1(playerid);
forward RandomEvent2(playerid);

new seconds;
new ETimer;
new Text:EventDraw[MAX_PLAYERS] = Text:INVALID_TEXT_DRAW;
new TimerShowing[MAX_PLAYERS];
new EventTimer;
new RandomEvent[][] =
{
    "RandomEvent1",
    "RandomEvent2"
};

public OnFilterScriptInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    EventDraw[i] = TextDrawCreate(1.000000, 426.000000, " ");
    TextDrawBackgroundColor(EventDraw[i], 65535);
    TextDrawFont(EventDraw[i], 1);
    TextDrawLetterSize(EventDraw[i], 0.500000, 1.000000);
    TextDrawColor(EventDraw[i], 16777215);
    TextDrawSetOutline(EventDraw[i], 1);
    TextDrawSetProportional(EventDraw[i], 1);
    TextDrawUseBox(EventDraw[i], 1);
    TextDrawBoxColor(EventDraw[i], 255);
    TextDrawTextSize(EventDraw[i], 639.000000, 0.000000);
    }
    //EventTimer = SetTimer("StartRandomEvent",5000,true);
    return 1;
}

CMD:startevent(playerid,params[])
{
    new eventname[128],Estring[256],tstr[5];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {

        if(TimerShowing[i] == 1)
        {
           // EventTimer = SetTimer("StartRandomEvent",150000,true);
            TimerShowing[i] = 0;
            TextDrawHideForPlayer(i, EventDraw[i]);
        }
        else
        {
            if(sscanf(params, "ds",seconds,eventname)) return SendClientMessage(playerid, WARNING, "/startevent time discription ");
            if(seconds < 1 || seconds > 1000000) return SendClientMessage(playerid, WARNING, "Allowed Eventimes Seconds 1-1000000");
            ETimer = SetTimerEx("RandomEvent1",seconds*1000, false,"i", i); // Set a repeated timer of 1000 miliseconds (1 second)
            KillTimer(EventTimer);
            format(tstr,sizeof(tstr),"%d",ETimer);
            format(Estring,sizeof(Estring),"Event: %s Starts in: %d Seconds",eventname,tstr);
            TextDrawShowForPlayer(i, EventDraw[i]);
            TextDrawSetString(EventDraw[i],Estring);
            TimerShowing[playerid] = 1;
           
        }
    }
    return 1;
}

CMD:eventhelp(playerid,params[])
{
    SendClientMessage(playerid, BLUE,"$$$$====$$$$====$$$$ Event $$$ Help $$$$====$$$$====$$$$");
    SendClientMessage(playerid, ORANGE,"/startevent /stopevent ");
    return 1;
}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    TextDrawHideForAll(EventDraw[i]);
    TextDrawDestroy(EventDraw[i]);
    KillTimer(EventTimer);
    }
    return 1;
}

public StartRandomEvent()
{
    new RandEvent = random(sizeof(RandomEvent));
    SetTimer(RandomEvent[RandEvent] ,5000,false);
    return 1;
}


public RandomEvent1(playerid)
{
    new msg[64];
    for(new i; i < MAX_PLAYERS; i++)
    {
        format(msg,sizeof(msg),"~g~IT ~b~WORKED");
        GameTextForAll(msg,5000,3);
        TextDrawHideForAll(EventDraw[i]);
        //TextDrawDestroy(EventDraw[i]);
        KillTimer(ETimer);
    }
    KillTimer(EventTimer);
    return 1;
}

public RandomEvent2(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {

    }
    KillTimer(EventTimer);
    return 1;
}
Reply
#6

Hey man, I might be totally off or not, but.
ETimer is your timer for randomevent1, u then used the ETimer variable in a format, with the integer format character, and u used this formatted integer in your event string..
I went to SetTimer and noticed that ETimer returns the ID of the timer, not the amount of seconds left.
And that's what I think you mixed up...
I don't really feel like explaining how to do a countdown timer now, so let someone else do this for you.
I hope this helped you and merry christmas.
Reply
#7

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
try this
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>


#define BLUE 0x000FFFFF
#define ORANGE 0xFF7800FF
#define WARNING 0x00FFFFFF


forward StartRandomEvent();
forward RandomEvent1(playerid);
forward RandomEvent2(playerid);


new seconds;
new ETimer;
new Text:EventDraw[MAX_PLAYERS];
new TimerShowing[MAX_PLAYERS];
new EventTimer;
new RandomEvent[][] =
{
    "RandomEvent1",
    "RandomEvent2"
};

public OnFilterScriptInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    EventDraw[i] = TextDrawCreate(1.000000, 426.000000, " ");
    TextDrawBackgroundColor(EventDraw[i], 65535);
    TextDrawFont(EventDraw[i], 1);
    TextDrawLetterSize(EventDraw[i], 0.500000, 1.000000);
    TextDrawColor(EventDraw[i], 16777215);
    TextDrawSetOutline(EventDraw[i], 1);
    TextDrawSetProportional(EventDraw[i], 1);
    TextDrawUseBox(EventDraw[i], 1);
    TextDrawBoxColor(EventDraw[i], 255);
    TextDrawTextSize(EventDraw[i], 639.000000, 0.000000);
    }
    //EventTimer = SetTimer("StartRandomEvent",5000,true);
    return 1;
}

public OnPlayerSpawn(playerid)
{

    return 1;
}

CMD:startevent(playerid,params[])
{
    new eventname[128],Estring[256],tstr[5];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {

        if(TimerShowing[i] == 1)
        {
            EventTimer = SetTimer("StartRandomEvent",150000,true);
            TimerShowing[i] = 0;
            TextDrawHideForPlayer(i, EventDraw[i]);
        }
        else
        {
            if(sscanf(params, "ds",seconds,eventname)) return SendClientMessage(playerid, WARNING, "/startevent time discription ");
            if(strval(seconds) < 1 || strval(seconds) > 1000000) return SendClientMessage(playerid, WARNING, "Allowed Eventimes Seconds 1-1000000");
            ETimer = SetTimerEx("RandomEvent1",seconds*1000, false,"i", i); // Set a repeated timer of 1000 miliseconds (1 second)
            KillTimer(EventTimer);
            format(tstr,sizeof(tstr),"%d",ETimer);
            format(Estring,sizeof(Estring),"Event: %s Starts in: %d Seconds",eventname,tstr);
            TextDrawShowForPlayer(i, EventDraw[i]);
            TextDrawSetString(EventDraw[i],Estring);
            TimerShowing[playerid] = 1;
           
        }
    }
    return 1;
}

CMD:eventhelp(playerid,params[])
{
    SendClientMessage(playerid, BLUE,"$$$$====$$$$====$$$$ Event $$$ Help $$$$====$$$$====$$$$");
    SendClientMessage(playerid, ORANGE,"/startevent /stopevent ");
    return 1;
}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    TextDrawHideForAll(EventDraw[i]);
    TextDrawDestroy(EventDraw[i]);
    KillTimer(EventTimer);
    }
    return 1;
}

public StartRandomEvent()
{
    new RandEvent = random(sizeof(RandomEvent));
    SetTimer(RandomEvent[RandEvent] ,5000,false);
    return 1;
}


public RandomEvent1(playerid)
{
    new msg[64];
    for(new i; i < MAX_PLAYERS; i++)
    {
        format(msg,sizeof(msg),"~g~IT ~b~WORKED");
        GameTextForAll(msg,5000,3);
        TextDrawHideForAll(EventDraw[i]);
        //TextDrawDestroy(EventDraw[i]);
        KillTimer(ETimer);
    }
    KillTimer(EventTimer);
    return 1;
}

public RandomEvent2(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {

    }
    KillTimer(EventTimer);
    return 1;
}
Well while giving the Fixed Code Please Explain what you have edited and what is it for , so that he can learn it and use it other works.
Reply
#8

Quote:
Originally Posted by Mike_Peterson
Посмотреть сообщение
Hey man, I might be totally off or not, but.
ETimer is your timer for randomevent1, u then used the ETimer variable in a format, with the integer format character, and u used this formatted integer in your event string..
I went to SetTimer and noticed that ETimer returns the ID of the timer, not the amount of seconds left.
And that's what I think you mixed up...
I don't really feel like explaining how to do a countdown timer now, so let someone else do this for you.
I hope this helped you and merry christmas.
Oh yeah Might be why thanks for that information ..
Reply
#9

Quote:
Originally Posted by RedCrossER
Посмотреть сообщение
Well while giving the Fixed Code Please Explain what you have edited and what is it for , so that he can learn it and use it other works.
He changed something i cant remember what it was i had to over look it my self with mine i about never changed it.. but it was the Message i think.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)