Code Snippets Discussion
-
- Lunatic
- Posts: 456
- Joined: 19 Jul 2008, 14:14
- GH nick: Razor, R
- Location: Poland / Szczecin
- Contact:
Code Snippets Discussion
Hi, I would ile to see here discussion about all Code Snippets. Just simple quote and paste here if you want to discuss sth ;>
-
- Lunatic
- Posts: 456
- Joined: 19 Jul 2008, 14:14
- GH nick: Razor, R
- Location: Poland / Szczecin
- Contact:
Re: Code Snippets Discussion
Passager Discussion wrote:Nice one! I didnt know SET_CHAR_OBJECTIVE worked with players. I actually thought about trying but never tried, I forgot doing soPyro wrote:Player passengers in cars...Code: Select all
STORE_CAR_CHARACTER_IS_IN ( p1 , p1_current_car ) IF ( ( CHECK_CHAR_CURR_WEAPON ( p2 , ELECTRO_BATON ) ) AND ( IS_CHAR_PRESSING_HORN ( p1 ) ) ) SET_CHAR_OBJECTIVE ( p2 , ENTER_CAR_AS_PASSENGER , p1_current_car ) ENDIF
Nice one again.
EDIT: Tried to compile, but it crashes the official compiler and gta2_mispadvike.exe compiler freezes at "Checking Compiler Output". Probably because of the set_objective to player thing :I
Still, here's the script:Conversation:Code: Select all
PLAYER_PED player1 = ( 52.5 , 179.5 , 2.0 ) -1 270 PLAYER_PED player2 = ( 52.5 , 179.5 , 2.0 ) -1 270 counter loop = 1 CAR_DATA p1_current_car CAR_DATA p2_current_car LEVELSTART IF ( CHECK_CHARACTER_HEALTH ( player1 , 0 ) ) SET_CHAR_GRAPHIC_TYPE ( player1 , DUMMY_GRAPHIC , -1 ) ENDIF IF (CHECK_CHARACTER_HEALTH(player2,0)) SET_CHAR_GRAPHIC_TYPE (player2,DUMMY_GRAPHIC,-1) ENDIF IF (CHECK_CHARACTER_HEALTH(player1,0)) GIVE_WEAPON (player1,ELECTRO_BATON,20) ENDIF IF (CHECK_CHARACTER_HEALTH(player2,0)) GIVE_WEAPON (player2,ELECTRO_BATON,20) ENDIF IF (IS_CHARACTER_IN_ANY_CAR(player1)) STORE_CAR_CHARACTER_IS_IN (player1, p1_current_car) ENDIF IF ( ( CHECK_CHAR_CURR_WEAPON ( player2 , ELECTRO_BATON ) ) AND ( IS_CHAR_PRESSING_HORN ( player1 ) ) ) SET_CHAR_OBJECTIVE ( player2 , ENTER_CAR_AS_PASSENGER , p1_current_car ) ENDIF IF (IS_CHARACTER_IN_ANY_CAR(player2)) STORE_CAR_CHARACTER_IS_IN (player2, p2_current_car) ENDIF IF ( ( CHECK_CHAR_CURR_WEAPON ( player1 , ELECTRO_BATON ) ) AND ( IS_CHAR_PRESSING_HORN ( player2 ) ) ) SET_CHAR_OBJECTIVE ( player1 , ENTER_CAR_AS_PASSENGER , p2_current_car ) ENDIF
Pyro wrote:The code is fine (even though you didn't put it in a WHILE loop) and compiles for me. But I had the same problem before if you remember and for some reason it won't compile any new scripts I make even with the most basic code (same error as before and the one you have). I used this code in a MIS file I know compiles and works.
This compiling bug is very strangeGustavob wrote:O lol I just noticed I didnt have the while loop and levelend. It happens frequently to me (forgetting the levelend) actually
It still didnt compiled, but I saved it in another file and now it compiled. No time to test atm, I will test it tomorrow. Maybe the size of the name was too big (player passengers.mis) or it just couldnt have spaces at script names.
-
- Immortal
- Posts: 889
- Joined: 16 May 2009, 06:14
- GH nick: BenMillard
- Location: London, UK
- Contact:
Re: Code Snippets Discussion
This approach seems less useful than the natural way a forum normally works, imho.
GTA5 Race, DM & Capture | GTA2 Levels & Coding | GTA2 YouTube Videos
Gran Turismo 6 custom track club(Sign in with PSN details, then follow link again.)
Gran Turismo 6 custom track club(Sign in with PSN details, then follow link again.)
-
- Lunatic
- Posts: 456
- Joined: 19 Jul 2008, 14:14
- GH nick: Razor, R
- Location: Poland / Szczecin
- Contact:
Re: Code Snippets Discussion
i dont like comment mess in snippets. Whi i have to read 3 pages of comments if i just can search for snippets? If sb has problem with script can paste it here. Also it eliminates post like "nice one, great job" etc.
-
- Immortal
- Posts: 889
- Joined: 16 May 2009, 06:14
- GH nick: BenMillard
- Location: London, UK
- Contact:
Re: Code Snippets Discussion
Normally someone posts an idea or a script, people comment and improve it. Then the original message gets updated. Or it adds a link to a web page which published a tutorial about it.
Anyway, let's try your way out:
(I wonder what happens now...)
Anyway, let's try your way out:
- I have a comment on the above player passenger script.
- How do I add my thoughts to that discussion?
- I can't edit that message.
- So I guess I make a new post here?
(I wonder what happens now...)
GTA5 Race, DM & Capture | GTA2 Levels & Coding | GTA2 YouTube Videos
Gran Turismo 6 custom track club(Sign in with PSN details, then follow link again.)
Gran Turismo 6 custom track club(Sign in with PSN details, then follow link again.)
- Gustavob
- Immortal
- Posts: 407
- Joined: 18 May 2009, 21:40
- GH nick: Gustavob
|Gustavob| - Location: Nowhere.
- Contact:
Re: Code Snippets Discussion
Yup, script files cant have more than 32 characters in its name (including .SCR extension) and cant have spaces and probably accents (àáóòéèúùíì etc) etc, but it still happens even if script name is alright sometimesBenMillard wrote: Gustavob & Pyro, I've had that compiler bug. It was due to filename being too long or containing a special character.
You just lost the game.
Re: Code Snippets
i have a code that really generates random numbers and i dont understand why u use nested ifs. why not just if(var=val)?T.M. wrote:Who wants random car remap?! lool. ahahaha epic.
I had to use binary tree to speed it up around 3x compared to without it!
NOTE: you must call this subroutine after you had created a car named "auto" !
Note: its not actually a binary tree because MIS syntax doesnt support ELSE's at all. (lol). I also tried to optimize it by using GOSUB after CHANGE_CAR_REMAP, but it actually made it slower!
[mis]
random_car_remap:
if(randomizer < 16) // 0-15
if(randomizer < 8) // 0-7
if(randomizer < 4) // 0-3
if(randomizer < 2)
if(randomizer = 0)
CHANGE_CAR_REMAP(auto, 0)
ENDIF
if(randomizer = 1)
CHANGE_CAR_REMAP(auto, 1)
ENDIF
ENDIF
if(randomizer >= 2)
if(randomizer = 2)
CHANGE_CAR_REMAP(auto, 2)
ENDIF
if(randomizer = 3)
CHANGE_CAR_REMAP(auto, 3)
ENDIF
ENDIF
ENDIF
if(randomizer >= 4) // 4-7
if(randomizer < 6)
if(randomizer = 4)
CHANGE_CAR_REMAP(auto, 4)
ENDIF
if(randomizer = 5)
CHANGE_CAR_REMAP(auto, 5)
ENDIF
ENDIF
if(randomizer >= 6)
if(randomizer = 6)
CHANGE_CAR_REMAP(auto, 6)
ENDIF
if(randomizer = 7)
CHANGE_CAR_REMAP(auto, 7)
ENDIF
ENDIF
ENDIF
ENDIF
if(randomizer >= 8) // 8-15
if(randomizer < 12) // 8-11
if(randomizer < 10)
if(randomizer = 8)
CHANGE_CAR_REMAP(auto, 8)
ENDIF
if(randomizer = 9)
CHANGE_CAR_REMAP(auto, 9)
ENDIF
ENDIF
if(randomizer >= 10)
if(randomizer = 10)
CHANGE_CAR_REMAP(auto, 10)
ENDIF
if(randomizer = 11)
CHANGE_CAR_REMAP(auto, 11)
ENDIF
ENDIF
ENDIF
if(randomizer >= 12) // 12-15
if(randomizer < 14)
if(randomizer = 12)
CHANGE_CAR_REMAP(auto, 12)
ENDIF
if(randomizer = 13)
CHANGE_CAR_REMAP(auto, 13)
ENDIF
ENDIF
if(randomizer >= 14)
if(randomizer = 14)
CHANGE_CAR_REMAP(auto, 14)
ENDIF
if(randomizer = 15)
CHANGE_CAR_REMAP(auto, 15)
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
if(randomizer >= 16) // 16-31
if(randomizer < 24) // 16-23
if(randomizer < 20) // 16-19
if(randomizer < 18)
if(randomizer = 16)
CHANGE_CAR_REMAP(auto, 16)
ENDIF
if(randomizer = 17)
CHANGE_CAR_REMAP(auto, 17)
ENDIF
ENDIF
if(randomizer >= 18)
if(randomizer = 18)
CHANGE_CAR_REMAP(auto, 18)
ENDIF
if(randomizer = 19)
CHANGE_CAR_REMAP(auto, 19)
ENDIF
ENDIF
ENDIF
if(randomizer >= 20) // 20-23
if(randomizer < 22)
if(randomizer = 20)
CHANGE_CAR_REMAP(auto, 32) // different
ENDIF
if(randomizer = 21)
CHANGE_CAR_REMAP(auto, 21)
ENDIF
ENDIF
if(randomizer >= 22)
if(randomizer = 22)
CHANGE_CAR_REMAP(auto, 22)
ENDIF
if(randomizer = 23)
CHANGE_CAR_REMAP(auto, 23)
ENDIF
ENDIF
ENDIF
ENDIF
if(randomizer >= 24) // 24-31
if(randomizer < 28) // 24-27
if(randomizer < 26)
if(randomizer = 24)
CHANGE_CAR_REMAP(auto, 24)
ENDIF
if(randomizer = 25)
CHANGE_CAR_REMAP(auto, 25)
ENDIF
ENDIF
if(randomizer >= 26)
if(randomizer = 26)
CHANGE_CAR_REMAP(auto, 26)
ENDIF
if(randomizer = 27)
CHANGE_CAR_REMAP(auto, 27)
ENDIF
ENDIF
ENDIF
if(randomizer >= 28) // 28-31
if(randomizer < 30)
if(randomizer = 28)
CHANGE_CAR_REMAP(auto, 34) // different
ENDIF
if(randomizer = 29)
CHANGE_CAR_REMAP(auto, 29)
ENDIF
ENDIF
if(randomizer >= 30)
if(randomizer = 30)
CHANGE_CAR_REMAP(auto, 35) // different
ENDIF
if(randomizer = 31)
CHANGE_CAR_REMAP(auto, 31)
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
// make so sequential calls will have different remap too:
++randomizer
if(randomizer > 31)
SET randomizer = 0
ENDIF
RETURN
[/mis]
[mis]
// Usage:
COUNTER randomizer = 0
FORWARD random_car_remap:
COUNTER done = 0
LEVELSTART
WHILE_EXEC(done = 0)
/////////////////////
// put this if you want to make it even more random:
++randomizer
if(randomizer > 31)
SET randomizer = 0
ENDIF
////
// rest of your code here
////
ENDWHILE
LEVELEND
// you can paste random_car_remap: subroutine here
[/mis]
yur sa'nok ngeyä
Re: Code Snippets
because i cant do "CHANGE_CAR_REMAP(auto, var)"
and that if(var = val) has nothing to do with this actually... i wouldnt need that if at all if i could just type "CHANGE_CAR_REMAP(auto, var)"
btw dare to post your random number generator?
and that if(var = val) has nothing to do with this actually... i wouldnt need that if at all if i could just type "CHANGE_CAR_REMAP(auto, var)"
btw dare to post your random number generator?
Last edited by T.M. on 26 Nov 2011, 18:02, edited 2 times in total.
My GTA2 related projects:
Re: Code Snippets
i will try to. you can see a random generator on bc_awkward cargo and a random multicolor sprayshop in tiny face off army(at least most of the spray shop code is in an external mis file).
it requires a pseudo random input. that input is different on each map and depends on the level design, so for that post i would have to explain a bit.
it requires a pseudo random input. that input is different on each map and depends on the level design, so for that post i would have to explain a bit.
Last edited by elypter on 25 Nov 2011, 19:29, edited 1 time in total.
yur sa'nok ngeyä
Re: Code Snippets
random generator != random car remap generator.
i couldnt even see a spray shop in tiny face off. stop wasting my time and show your code if you have some points to make regarding my code.
i couldnt even see a spray shop in tiny face off. stop wasting my time and show your code if you have some points to make regarding my code.
Please show the code that makes a random number depending on GMP file.. because i dont believe GTA2 supports such.it requires a pseudo random input. that input is different on each map and depends on the level design, so for that post i would have to explain a bit
My GTA2 related projects:
Re: Code Snippets
tiny face off army ofc, and yes it is. and leveldesign not gmp file.
yur sa'nok ngeyä
Re: Code Snippets
so you call hardcoded number random? i thought of using some other than zero intial value, but thought it would be pointless since it would always start from the same value. so i just use zero instead.
it doesnt really matter if it changes on each map: its still the same every time you play the map.
when are you going to post your code?
it doesnt really matter if it changes on each map: its still the same every time you play the map.
sorry, couldnt find from there either, in fact i dont even have that mis file, but luckily i could decompile it and no shops there at all.elypter wrote:tiny face off army ofc, and yes it is. and leveldesign not gmp file.
when are you going to post your code?
My GTA2 related projects:
Re: Code Snippets
i never said thatT.M. wrote:so you call hardcoded number random? i thought of using some other than zero intial value, but thought it would be pointless since it would always start from the same value. so i just use zero instead.
all my maps have script included and are hosted on the map pageT.M. wrote: when are you going to post your code?
http://gta2dare.omnitude.net/maplist/li ... ap=tyfo.7z
there is even a link for direct view of .mis and subs folder
yur sa'nok ngeyä
Re: Code Snippets
Is this it? I couldnt find any match to "shop", but "rand" found this:
How is that random? youre doing exactly this:
I used exactly that method on my code at the first place, but realised its pointless since taking something from already randomized stack doesnt make it any more random, e.g. the remap colors are already random colors, doesnt matter which order it take from it, user wont see a difference, and on top of that: i cycle the randomizer value each frame, so that will make it feel more random since it gives different result depending when you call that subroutine.
btw, that 3 liner code of yours doesnt seem to even do anything in your script! no other references to "rand" variable.
Edit: btw i found out recently editplus supports mis style code folding, you might be interested; www.editplus.com
Code: Select all
SET temp = ( rand / 3 )
SET temp = ( temp * 3 )
SET rand = ( rand - temp )
Code: Select all
SET rand = ( rand MOD 3)
btw, that 3 liner code of yours doesnt seem to even do anything in your script! no other references to "rand" variable.
Edit: btw i found out recently editplus supports mis style code folding, you might be interested; www.editplus.com
Last edited by T.M. on 26 Nov 2011, 00:53, edited 1 time in total.
My GTA2 related projects:
Re: Code Snippets
T.M. wrote:Edit: btw i found out recently editplus supports mis style code folding, you might be interested; http://www.editplus.com
My ScriptPad also supports folding. I can add support for any folding case if needed.
And it's freeware.
Who of the GTA2 modders will buy shareware app? I think no-one.
Always wear safety glasses while programming.
Re: Code Snippets
editplus code folding is epic: it detects the tabs (or 4 spaces) and adds folding options regarding to that. (i think its because it doesnt recognize the language so its the default code folding method). i was quite surprised how well it actually works with any language! although, as ive seen, almost nobody here uses proper indenting on their mis scripts... and you cant indent multiple lines at once in mispad, unlike in editplus, it even converts 4 spaces into tab automatically (if you indent them). it has like million other useful features i still keep finding out!B-$hep wrote:My ScriptPad also supports folding. I can add support for any folding case if needed.
And it's freeware.
heh. its not just for gta2. ive been using it for years and it has never pissed me off, unlike every other tool around the world such as notepad++ and other free/opensource software there is.B-$hep wrote:Who of the GTA2 modders will buy shareware app? I think no-one.
My GTA2 related projects:
Re: Code Snippets Discussion
sounds interesting. i could make a powerup for this on tiny face off army if i'm getting to update it next timeCarThief wrote:Cause explosion on Player when pressing Car Horn:Code: Select all
...
yur sa'nok ngeyä
Code Snippets
can i create 2 phones in one map?
cuz when i compile it says symbol already declared answer_phone:
cuz when i compile it says symbol already declared answer_phone:
The fuck you looking at?
Re: Code Snippets Discussion
http://gtamp.com/forum/viewtopic.php?p=7189#p7189
good to have that in the code snippets but could you at least post the author of the script...
good to have that in the code snippets but could you at least post the author of the script...
yur sa'nok ngeyä