AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Random task time (https://forums.alliedmods.net/showthread.php?t=159700)

.Dare Devil. 06-20-2011 10:25

Random task time
 
Hi

How i do random task time something like this

PHP Code:

new const RANDOM_TASKTIME[][] =
{  
         
25,
         
15,
         
40,
         
150,
          
12,
            
2,
          
150              
}
 
// And set task something
set_task(RANDOM_TASKTIME"thunderclap"TASK_THUNDER_PRE

But i want like this way :)

new const RANDOM_TASKTIME[][] =
{
25, // first task time
15, // then this
40, // then this
150, // then this
12, // then this
2, // then this
150 // And start again 24
}

thanking in advance.

Arkshine 06-20-2011 11:18

Re: Random task time
 
You don't need two [], just one, since one dimension.
Also make the value as float.

Just use a var which will be incremented.

set_task( RANDOM_TASKTIME[ myvar ], ... );
[...]
myvar++;

.Dare Devil. 06-20-2011 11:27

Re: Random task time
 
Quote:

Originally Posted by Arkshine (Post 1492229)
You don't need two [], just one, since one dimension.
Also make the value as float.

Just use a var which will be incremented.

set_task( RANDOM_TASKTIME[ myvar ], ... );
[...]
myvar++;

Thanks :)
You are pro man... :)

jimaway 06-20-2011 13:38

Re: Random task time
 
wouldnt just this work?
set_task( RANDOM_TASKTIME[ myvar++ ], ... );

Arkshine 06-20-2011 14:05

Re: Random task time
 
Yes, sure.

DjOptimuS 06-20-2011 23:40

Re: Random task time
 
you can use the numbers in that form but use the set task function like this

PHP Code:

set_task(float(RANDOM_TASKTIME), "thunderclap"TASK_THUNDER_PRE


Exolent[jNr] 06-21-2011 01:01

Re: Random task time
 
Quote:

Originally Posted by DjOptimuS (Post 1492615)
you can use the numbers in that form but use the set task function like this

PHP Code:

set_task(float(RANDOM_TASKTIME), "thunderclap"TASK_THUNDER_PRE


Useless native call since they can be declared as float.

DjOptimuS 06-21-2011 05:40

Re: Random task time
 
I camed with the solution. maybe the coder is comfortable coding like this.

Exolent[jNr] 06-21-2011 12:49

Re: Random task time
 
Quote:

Originally Posted by DjOptimuS (Post 1492699)
I camed with the solution. maybe the coder is comfortable coding like this.

The "solution" you provided is pointless and also inefficient since the coder can already declare them as float values.

.Dare Devil. 07-31-2011 17:49

Re: Random task time
 
Like this ?

PHP Code:

 
 
 
new const RANDOM_TASKTIME[] =
{  
         
25,
         
15,
         
40,
         
150,
          
12,
            
2,
         
150              
}
 
new 
g_randomvar
 
// And set task something
set_task(RANDOM_TASKTIMEg_randomvar ], "thunderclap"TASK_THUNDER_PRE)
g_randomvar++ 

And i think i must reset it if this will end

g_randomvar = 0


All times are GMT -4. The time now is 23:34.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.