Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: King on Jul 22, 2016, 05:28 AM

Title: how to make a count 1sec to 10sec with array?
Post by: King on Jul 22, 2016, 05:28 AM
how to make a count from 1sec to 10sec with array
Title: Re: how to make a count 1sec to 10sec with array?
Post by: KAKAN on Jul 22, 2016, 08:49 AM
array <- [];
I <- 0;
while( array.len() < 10 )
{
array.push( I )
}
There might be some more better functions, that was just an example
Title: Re: how to make a count 1sec to 10sec with array?
Post by: EK.IceFlake on Jul 22, 2016, 01:47 PM
That wont work, squirrel is on 1 thread
Title: Re: how to make a count 1sec to 10sec with array?
Post by: Mötley on Jul 22, 2016, 02:13 PM
This is from LU and I'm to busy but rwwpl's code should help you from another script help


Quote from: rwwpl on Dec 21, 2015, 06:53 PMLOOOOL

Example:

Count <- array(GetMaxPlayers(),0);

function onServerStart()
{
NewTimer("CountDown",1000,0);
return 1;
}

function CountDown()
{
for (local i = 0; i <= GetMaxPlayers(); i++)
{
local p = FindPlayer(i);
if (p)
{
if (p.Vehicle) Count[p.ID] ++;
else Count[p.ID] --;
MessagePlayer("Count: "+Count[p.ID],p);
}
}
}

Do not thank me thank rwwpl
@rww
Title: Re: how to make a count 1sec to 10sec with array?
Post by: King on Jul 27, 2016, 10:36 AM
No i mean counting from 1 to 10 without using a  timer
Title: Re: how to make a count 1sec to 10sec with array?
Post by: EK.IceFlake on Jul 27, 2016, 11:05 AM
Why not timer? Do you have personal enmity with timer? Timer is most efficient friend for this task. Timer was made with the sole purpose to be able to call functions after a specified time.
Title: Re: how to make a count 1sec to 10sec with array?
Post by: Finch Real on Jul 27, 2016, 11:20 AM
Timers lag the script :P
Title: Re: how to make a count 1sec to 10sec with array?
Post by: Anik on Jul 27, 2016, 11:24 AM
Quote from: Finch Real on Jul 27, 2016, 11:20 AMTimers lag the script :P
ahh!! I think you should read the topic posted by @Stormeus  at Vice Underdogs forum.
http://viceunderdogs.com/index.php?topic=4452.0
Title: Re: how to make a count 1sec to 10sec with array?
Post by: KAKAN on Jul 27, 2016, 01:18 PM
Quote from: Finch Real on Jul 27, 2016, 11:20 AMTimers lag the script :P
No it doesn't. I had 700+ timers in a testing script, even players with 250+ ping didn't lag.
Read what @Anik has posted, click on that link and read that topic.
Title: Re: how to make a count 1sec to 10sec with array?
Post by: Mötley on Jul 27, 2016, 03:27 PM
The snippet from rwwpl is perfect with common sense it could be re scripted for whatever.

My suggestion, I only have one timer in my script typically and that timer is for a function that has many and I mean many player loop methods etc, or depending on what your doing with arrays etc, to an Announced timed message telling you to re enter a car within 60 secs or mission failed, or whatever you want,.

Timers are not bad unless used poorly/shity. There is no other way to do this, If you do not want to do this I suggest skip whatever your working on as it will never work out and you will waste your time/life.

You could use the game clock but thats even more retarded.


Just use the simple method and get it over with. You do not need to have many timers just one and many array values and decrease increase that value with ++ etc then check the array value, I really do not feel like going into detail as this is pre explanatory..