GTAMP.com

Grand Theft Auto Media Press
It is currently Thu Jun 20, 2013 11:20 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Wed Jan 12, 2011 5:44 pm 
Offline
Mugger

Joined: Wed Jan 12, 2011 2:28 pm
Posts: 11
Hi, I added a respawning trailer to Tiny Town and I want it to have different color every respawn. How can i acomplish that?

I tried this way:

Code:
...
COUNTER col = 6
...
LEVELSTART
...
SET col = ( col + 1 )
tr = CREATE_CAR ( 61.45 , 196.5  ) col 180 TRUKCONT END  //here is an error, if there is a number instead of "col" it compiles well
...


...but compiler throws an error.
How can I give a car random or sequential color?


Top
 Profile  
 
PostPosted: Wed Jan 12, 2011 6:04 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 984
Location: GTAMP.com
You can't do it that way since the limited compiler requires a constant integer and won't allow a variable/counter.

You'd have to have one create_car command for every color you want to select from.


Top
 Profile  
 
PostPosted: Wed Jan 12, 2011 6:14 pm 
Offline
Mugger

Joined: Wed Jan 12, 2011 2:28 pm
Posts: 11
Too bad... I'll make the location of respawn sequential also then!
Thanks.


Top
 Profile  
 
PostPosted: Wed Jan 12, 2011 6:19 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 984
Location: GTAMP.com
Coordinates and many other values also need to be constants.


Top
 Profile  
 
PostPosted: Wed Jan 12, 2011 6:27 pm 
Offline
Mugger

Joined: Wed Jan 12, 2011 2:28 pm
Posts: 11
Yes, but it's not a problem since I must write multiple create_car lines anyway.


Top
 Profile  
 
PostPosted: Wed Jan 12, 2011 6:44 pm 
Offline
Mugger

Joined: Wed Jan 12, 2011 2:28 pm
Posts: 11
BTW, can I set a counter to random value somehow?


Top
 Profile  
 
PostPosted: Wed Jan 12, 2011 6:59 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 933
There is no Random function in GTA2 but you can do a workarround (a modulo operation)

Code:
   SET temp = ( rand / 33 )
   SET temp = ( temp * 33 )
   SET surp_sel= ( rand - temp )

33 is the maximum random value

rand is a counter that is increased every WHILE_EXEC cycle and reset on pseudo random events.
It is important that it is a value that is different in every game and that the seed(rand) happens more often than event(surp_sel) otherwise you could get a repeating pattern.
If you use the same seed for multiple events ensure that the max values do not have a common divisor otherwise you will have correlations.

You can look how it works on BC Awkward Cargo

_________________
yur sa'nok ngeyƤ


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group