Raised This Month: $ Target: $400
 0% 

Make 2 tasks chosen randomly. (Solved)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 12-28-2013 , 02:29   Re: Make 2 tasks chosen randomly. (how?)
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
There are no issues with the code that you have posted (assuming you have it complete which it isn't in the posted code).

I.E. This compiles just fine:

Code:
public make_hero(id)
{	
	switch (random_num(0, 1))	
	{
		case 0:
		{
			// stuff 0
		}
		case 1:
		{
			// stuff 1
		}
	}
}
But there is a problem, you cant add more then 1 thing lets say if i do like this :

Code:
case 0:
		{
	         1 thing
                 1 thing
                 1 thing
		}
If i compile it. it will show this error :

Code:
// C:\Users\Billy\Desktop\Compiler\zp_hero.sma(65) : error 002: only a single st
atement (or expression) can follow each "case"
But i want it to select a hero randomly.

meaning i want it to select 2 tasks randomly.

1st task will switch the player model to hero and gives a svdex dual deagle etc.

2nd task will switch the player model to "heroine" and gives a quad barrel and dual deagle etc.

hope you understand better now. im bad at explaining, sorry for that.

EDIT! :

Got an idea, If i do it like this :

setting 2 tasks

set_task(0.5,"make_hero")
set_task(0.5,"make_heroine")

Then the
public make_heroine(id)

etc-.-

But im gonna need a code that randomizes what task to choose.

I coded the plugin to make 2 hero's now, but i need something that can randomize what task to use.

Will this work? correct the code if not please.

Code:
public random_task(id) 
{	
	switch (random_num(0, 1))	
	{
		case 0:
		{
                             set_task(0.5,"make_heroine")	
		}
                             case 1:
		{
                             set_task(0.5,"make_hero")	
		}
	}
}
That compiled great, but will it work?


EDIT 2 :

So that was wrong, it had already set the tasks before my code above. so i change it to this.

Code:
public zp_round_started(round)
{
if (zp_get_human_count( ) < MINPEOPLE )
		return;
			
if(round == MODE_MULTI || round == MODE_INFECTION)
switch (random_num(0, 1))	
	{
		case 0:
		{
                             set_task(0.5,"make_heroine")	;
		}
                             case 1:
		{
                             set_task(0.5,"make_hero");	
		}
	}
           
}
That should do it right?
__________________
Contact: Steam
Videos: Youtube

Last edited by SkumTomteN; 12-28-2013 at 03:03.
SkumTomteN is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:38.


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