Breaktime
#1

Just a little question, do you know a function which will allow a break between to things?
Here is an exemple
pawn Код:
if(strcmp(cmd, "/break", true) == 0)
{
    GameTextForPlayer(playerid, "Hey, sending you a message at the end of this one", 5000, 3);
    break(5); //what I need, here it would make a break of 5 seconds and then continue the code below
    GameTextForPlayer(playerid, "Well 5 seconds have passed!", 5000, 3);
    //...
}
I found this on the wiki:
pawn Код:
halt(seconds)
{
    new _newTime[4], _oldTime[4];
    gettime(_oldTime[0], _oldTime[1], _oldTime[2]);
    _oldTime[3] = _oldTime[2] + (_oldTime[1] * 60) + (_oldTime[0] * 600);

    while(_newTime[3] != (_oldTime[3] + seconds))
    {
        gettime(_newTime[0], _newTime[1], _newTime[2]);
        _newTime[3] = _newTime[2] + (_newTime[1] * 60) + (_newTime[0] * 600);
    }
}
But when I use it it freezes all, not only the command
For example, if I type /me is hungry duing the halt time it will only appear at the eand of this time... I althouhg think that it freezes the whole script..

So any help please?
Thanks in advance
Reply
#2

Use a timer.
Reply
#3

Quote:
Originally Posted by Mikep
Use a timer.
But I'll have to make one timer per use, won't I?

For exemple, I got a speedo meter when I'm driving, id shows up via a gametext. But when an admin type a command which shows a gametext i'd like to desactivate the speedometer for ~5seconds...
Reply
#4

Use a variable.
Reply
#5

Quote:
Originally Posted by Mikep
Use a variable.
Could you please show me an example? Actually I don't handle well timer ...
Reply
#6

pawn Код:
new SpeedoOn[MAX_PLAYERS];

To stop the Speedo:

SpeedoOn[playerid] = 0;

To turn on the Speedo:

SpeedoOn[playerid] = 1;

In the Speedo:

if(Speedo[playerid] == 1)
{
  //GameText
}
Reply
#7

Quote:
Originally Posted by Mikep
pawn Код:
new SpeedoOn[MAX_PLAYERS];

To stop the Speedo:

SpeedoOn[playerid] = 0;

To turn on the Speedo:

SpeedoOn[playerid] = 1;

In the Speedo:

if(Speedo[playerid] == 1)
{
  //GameText
}
Thanks for your help but actually I want the speedo to be desactivated during the time of the gametext sent by the admin (in this example) something like halt would be great if it didn't freeze the whole script.
Reply
#8

Well, any help? for example:
pawn Код:
if(strcmp(cmdtext, "/test", true) == 0)
{
    SendClientMessage(playerid, color, "Sending you a message in 10 seconds =)");
    breaktime(10); //10 is the ammount of seconds;
    SendClientMessage(playerid, color, "Tada!") //this appears after 10secs
    return 1;
}
Any idea about how to make the breaktime function?
Reply
#9

not possible without freezing the whole server, use a timer.
Reply
#10

Quote:
Originally Posted by !MaVe
not possible without freezing the whole server, use a timer.
But how to use a timer then? I use several timers but can't find the way to use one to do what I want, any help please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)