SA-MP Forums Archive
Breaktime - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Breaktime (/showthread.php?tid=66790)



Breaktime - Coicatak - 24.02.2009

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


Re: Breaktime - Mikep - 24.02.2009

Use a timer.


Re: Breaktime - Coicatak - 24.02.2009

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...


Re: Breaktime - Mikep - 24.02.2009

Use a variable.


Re: Breaktime - Coicatak - 24.02.2009

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


Re: Breaktime - Mikep - 24.02.2009

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
}



Re: Breaktime - Coicatak - 24.02.2009

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.


Re: Breaktime - Coicatak - 26.02.2009

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?


Re: Breaktime - Streetplaya - 26.02.2009

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



Re: Breaktime - Coicatak - 26.02.2009

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?