Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (ozgur, Ayumi, VHX, monarch), 1,161 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
syntax error #295552
10/26/09 01:56
10/26/09 01:56
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Could someone please tell me what is wrong with this code.

Code:
var place = 0;


//Function for creating pickups
function pickups_places()
{
	place = int(random(6));
	if (place == 1)
	{ent_create("pass.mdl",vector(-192,-192,0),NULL);}
	if (place == 2)
	{ent_create("pass.mdl",vector(-160,-192,0),NULL);}
	if (place == 3)
	{ent_create("pass.mdl",vector(-128,-192,0),NULL);}
	if (place == 4)
	{ent_create("pass.mdl",vector(-96,-192,0),NULL);}
	if (place == 5)
	{ent_create("pass.mdl",vector(-64,-192,0),NULL);}
}


pickups_places(); //this is in the main function



Re: syntax error [Re: JGGamer] #295555
10/26/09 03:26
10/26/09 03:26
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
place = integer(random(6));


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: syntax error [Re: EvilSOB] #295703
10/27/09 00:13
10/27/09 00:13
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Thanks. I would never have found that out. I was using the manual and I never came across this. Thanks again.

edit

Sorry to be a bother. I am not gettin any results from the code. When I just do

Code:
ent_create("pass.mdl",vector(-192,-192,0),NULL);



I get results. The 'pass' model appears, but when I use the code above, the model doesn't appear. Is everything ok with my code or have I done something wrong?

Last edited by JGGamer; 10/27/09 00:26.
Re: syntax error [Re: JGGamer] #295707
10/27/09 01:02
10/27/09 01:02
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
sometimes comparing a var with a real numberm as you are doing doesnt work.
Its buried deep in the manual somewhere, from memory, it goes something like
...sometimes a var will not contain the expected integer, but contain a near value,
where one is expecting a 1.000, you will in fact get a 1.000001 which causes the if to fail...
or something to that effect.

try this instead. (untested)
Code:
//Function for creating pickups
function pickups_places()
{
	place = random(6);
	if (integer(place) == 1)
	{ent_create("pass.mdl",vector(-192,-192,0),NULL);}
	if (integer(place) == 2)
	{ent_create("pass.mdl",vector(-160,-192,0),NULL);}
	if (integer(place) == 3)
	{ent_create("pass.mdl",vector(-128,-192,0),NULL);}
	if (integer(place) == 4)
	{ent_create("pass.mdl",vector(-96,-192,0),NULL);}
	if (integer(place) == 5)
	{ent_create("pass.mdl",vector(-64,-192,0),NULL);}
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: syntax error [Re: EvilSOB] #295711
10/27/09 02:50
10/27/09 02:50
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
I had tried that, and it didn't work either.

Re: syntax error [Re: JGGamer] #295712
10/27/09 03:01
10/27/09 03:01
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline
User
badapple  Offline
User

Joined: Apr 2006
Posts: 624
DEEP 13
maybe try it like this


if((place >= 0)&&(place < 2))
{ent_create("pass.mdl",vector(-192,-192,0),NULL);}

if((place >= 2)&&(place < 3))
{ent_create("pass.mdl",vector(-160,-192,0),NULL);}

if((place >= 3)&&(place < 4))
{ent_create("pass.mdl",vector(-128,-192,0),NULL);}

if((place >= 4)&&(place < 5))
{ent_create("pass.mdl",vector(-96,-192,0),NULL);}

if(place >= 5)
{ent_create("pass.mdl",vector(-64,-192,0),NULL);}

Re: syntax error [Re: badapple] #295716
10/27/09 03:52
10/27/09 03:52
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
I also tried that and it didn't work either. However, I made a little progress. I debugged the variable place, and realized that it never moved from zero, so I tried using a while loop and the model appeared but in all 5 places.

I then tried this:

Code:
var place;
var trigger_num = 0;

	var trigger_mod;
	if (trigger_num == 0)
	{
		trigger_mod = ent_create("pass.mdl",vector(0,0,0),pickups_places);
		trigger_num = 1;
	}

//Function for creating pickups
function pickups_places()
{
	while (place == 0)
	{
		place = integer(random(6));
		if (place == 1)
		{ent_create("pass.mdl",vector(-192,192,0),NULL);}
		if (place == 2)
		{ent_create("pass.mdl",vector(-160,192,0),NULL);}
		if (place == 3)
		{ent_create("pass.mdl",vector(-128,192,0),NULL);}
		if (place == 4)
		{ent_create("pass.mdl",vector(-96,192,0),NULL);}
		if (place == 5)
		{ent_create("pass.mdl",vector(-64,192,0),NULL);}
		wait(1);
	}

}



This time only one model appears, but it always appear in the same position. The variable 'place' is always 3. Any ideas on this?

Re: syntax error [Re: JGGamer] #295720
10/27/09 04:24
10/27/09 04:24
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
I don't get it. I removed the interger and used:


Code:
//Function for creating pickups
function pickups_places()
{
	while (place == 0)
	{
		place = random(6);
		wait(1);
	}
	if (place > 0 && place < 2)
	{ent_create("pass.mdl",vector(-192,192,0),NULL);}
	else if (place >= 2 && place < 3)
	{ent_create("pass.mdl",vector(-160,192,0),NULL);}
	else if (place >= 3 && place < 4)
	{ent_create("pass.mdl",vector(-128,192,0),NULL);}
	else if (place >= 4 && place < 5)
	{ent_create("pass.mdl",vector(-96,192,0),NULL);}
	else if (place >= 5 && place < 6)
	{ent_create("pass.mdl",vector(-64,192,0),NULL);}
}



and now variable place is 0.995 all the time.

Could someone who knows whats going on here please help me with this. It's sending me crazy. Thanks for your help guys.

Re: syntax error [Re: JGGamer] #295733
10/27/09 07:24
10/27/09 07:24
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Try this one, and let us know IF it fixes the problem, if it does then I'll explain it.
Im not good with c-script so it may need adjusting to be c-script friendly.
Code:
//Function for creating pickups
function pickups_places()
{
	random_seed(0);
	var place = integer(random(5)+1);
	if(place==1)	{ent_create("pass.mdl",vector(-192,192,0),NULL);}
	if(place==2)	{ent_create("pass.mdl",vector(-160,192,0),NULL);}
	if(place==3)	{ent_create("pass.mdl",vector(-128,192,0),NULL);}
	if(place==4)	{ent_create("pass.mdl",vector(-96,192,0),NULL);}
	if(place==5)	{ent_create("pass.mdl",vector(-64,192,0),NULL);}
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: syntax error [Re: EvilSOB] #295752
10/27/09 11:53
10/27/09 11:53
Joined: Oct 2007
Posts: 11
J
JM89 Offline
Newbie
JM89  Offline
Newbie
J

Joined: Oct 2007
Posts: 11
Do you use the function randomize() in your code?

JM

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1