Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: umar4911 on Jun 08, 2018, 08:09 PM

Title: Timer and delete timer
Post by: umar4911 on Jun 08, 2018, 08:09 PM
How to make timers in Client Side. NewTimer doesn't exist in Client Side.

How to delete a timer in both server side and client side.

Off-topic: Where did vitogta go?
Title: Re: Timer and delete timer
Post by: vitogta on Jun 08, 2018, 08:29 PM
I use this https://forum.vc-mp.org/?topic=2748.0
Title: Re: Timer and delete timer
Post by: umar4911 on Jun 08, 2018, 09:15 PM
Suppose there is a timer
Timer.Create(this, abc, 1000, 0)How to identify this timer? How to see that it exists or not? How to destroy this timer?
Title: Re: Timer and delete timer
Post by: vitogta on Jun 08, 2018, 09:20 PM
function Script::ScriptLoad()
{
 local hash = Timer.Create(this, function(text, int) {
  Console.Print(text + int);
 }, 1000, 0, "Timer Text ", 12345);

 Console.Print(hash);

 if(Timer.Exists(hash)){
 //...
 }

 Timer.Destroy(hash);
}
Title: Re: Timer and delete timer
Post by: umar4911 on Jun 08, 2018, 10:17 PM
Quote from: vitogta on Jun 08, 2018, 09:20 PMfunction Script::ScriptLoad()
{
 local hash = Timer.Create(this, function(text, int) {
  Console.Print(text + int);
 }, 1000, 0, "Timer Text ", 12345);

 Console.Print(hash);

 if(Timer.Exists(hash)){
 //...
 }

 Timer.Destroy(hash);
}
Means I need to record the hash of player and then delete it using the hash.
Title: Re: Timer and delete timer
Post by: Xmair on Jun 09, 2018, 01:12 PM
Just store the timer inside a variable and delete it when you want to.
Title: Re: Timer and delete timer
Post by: [KM]Helathien on Jun 22, 2018, 08:44 AM
Bro the easiet way is just name the timer in onscriptload
Ex
T1=NewTimer..........


And then when u want to remove it just so
T1. Delete()
Title: Re: Timer and delete timer
Post by: umar4911 on Jun 22, 2018, 10:10 AM
Quote from: [KM]Helathien on Jun 22, 2018, 08:44 AMBro the easiet way is just name the timer in onscriptload
Ex
T1=NewTimer..........


And then when u want to remove it just so
T1. Delete()
Already solved man! Dont bump these topics.