Jack Posted February 14, 2012 Share Posted February 14, 2012 For VC: Is it possible to double or even triple a scrypt using gosub and return commands, for example something like this: :Gosubs wait 0 gosub @1 gosub @2 gosub @3 jump @Gosubs end_thread :1 wait 0 Some vehicle follow player jump @1 return :2 wait 0 The same operation (like in :1) jump @2 return :3 wait 0 The same operation (like in :1) jump @3 return The problem is that I didn't saw similar scrypt method anywhere in main.scm. I just woke up one morning and this idea crossed my mind, so I need someone to confirm that this is the correct method. I think that the first return from label :1 should go to the gosub @1, the second return from label :2 to gosub @2...So, em I right? Or maybe all of the return commands will slam into the "gosub @3" which would be a disaster? Maybe there's some better and easier method to make a huge number of the same evants in one scrypt without mixing themselves. And there's also a question of speed of the whole thing-What if I decide to make a much biger number of vehicles (like 15) to start follow a player? Will this kind of a scrypt be able to play all 15 events at the same time with a normal speed? Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
Deji Posted February 14, 2012 Share Posted February 14, 2012 No, it's not possible to double a script using gosub commands. Link to comment Share on other sites More sharing options...
Jack Posted February 14, 2012 Author Share Posted February 14, 2012 Why not? Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
Deji Posted February 14, 2012 Share Posted February 14, 2012 Well, there's no reason why it would be possible. Your script will just be stuck in a loop in the first subroutine. Link to comment Share on other sites More sharing options...
Jack Posted February 14, 2012 Author Share Posted February 14, 2012 I red this from coding tutorial: :MS_GAME_BEEFYBARON $ONMISSION = 1 // integer values 00BA: text_styled 'BEEFY' 1000 ms 2 // Beefy Baron gosub @SUB_FADE_500MS start_mission 10 // Beefy Baron jump @END_CASE_VIDEO_GAME :SUB_FADE_500MS 0169: set_fade_color 0 0 0 fade 0 500 :LITCAS_282 if fading else_jump @LITCAS_306 wait 0 jump @LITCAS_282 :LITCAS_306 Return So it jumps with a "gosub" to ":SUB_FADE_500MS". When it reaches the "return" command (under ":LITCAS_306"), it goes back to the gosub. After the return, the code will continue with "start_mission 10"). So after my first return, "gosub @2" will be next operation. Also, I just tested this idea and I didn't noticed errors yet. Are you sure that it's not possible? Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
Ashwin.Star Posted February 14, 2012 Share Posted February 14, 2012 sure, when game will read the return it will start reading from where its Gosub was written, but in your first script you made a loop by using jump so it was impossible to read return for the game, try this :Gosubs //labelwait 0 gosub @1 jump @Gosubs end_thread // no need of it:1Some vehicle follow player // do anything but don't jump to :gosubreturn Link to comment Share on other sites More sharing options...
Bad.boy! Posted February 14, 2012 Share Posted February 14, 2012 You notice nothing because :2 and :3 are the same as :1 Link to comment Share on other sites More sharing options...
Jack Posted February 14, 2012 Author Share Posted February 14, 2012 (edited) It's pretty hard to notice an error in this kind of a scrypt. I expeled the jump commands from 1, 2, 3 labels: :Gosubs wait 0 gosub @1 gosub @2 gosub @3 jump @Gosubs end_thread :1 wait 0 Some vehicle follow player return :2 wait 0 The same operation (like in :1) return :3 wait 0 The same operation (like in :1) return and it seems fine in game. I hope you are all agree with Ashwin (that this scrypt structure should work now). If some of you think that something is still wrong then gimme the worst case scenario what will happen in game because finding these erros is not easy even when I start playing. Like Bad.boy! said-the evants in these labels are the same. Also the main reason I started this topic is because I was hoping that maybe someone knows how to duplicate scrypt evants with some regular (already existed) method which was used in originaly main.scm file. But still, you helped a lot so thank you for your replies. Edited February 14, 2012 by JACK JONES Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
Jack Posted February 18, 2012 Author Share Posted February 18, 2012 (edited) I'm sorry for double post but my scrypt (based on the idea from above) have some error. Besides that error everything works fine so please help me to find it. I tried to find it myself but without luck. Here's the problem: The idea is that SWAT teams attack a player in VCPDHQ. If a player kill them all they'll recreate themselves in 5 seconds (only if they are all dead). When a plyer do all that for exactly 7 times, the game crashes in a moment when SWAT teams create themselves again (7th time of their creation). Maybe it has something to do with "Model.Destroy(#SOMETHING)" command but I'm not sure what. Please help, I can't find this error. Here's that scrypt: :TACTEAM thread 'SWAT' :LOAD wait 250 if and Player.Defined($PLAYER_CHAR) Player.WantedLevel($PLAYER_CHAR) > 3 0056: player $PLAYER_CHAR 0 354.3227 -484.1484 380.0685 -475.388 else_jump @LOAD Model.Load(#ENFORCER) Model.Load(#SWAT) Model.Load(#ARMY) Model.Load(#M4) Model.Load(#MP5LNG) Model.Load(#TEC9) 038B: load_requested_models :STUFF wait 0 if and Model.Available(#ENFORCER) Model.Available(#SWAT) Model.Available(#ARMY) Model.Available(#M4) Model.Available(#MP5LNG) Model.Available(#TEC9) else_jump @STUFF 020C: create_explosion_with_radius 11 at 395.982 -473.508 12.343 Camera.Shake(1000)[email protected] = Actor.Create(CivMale, #SWAT, 386.9318, -484.7817, 12.34322) [email protected] = Actor.Create(CivMale, #SWAT, 388.7173, -482.7012, 12.34322) [email protected] = Actor.Create(CivMale, #SWAT, 390.2015, -480.854, 12.34322) [email protected] = Actor.Create(CivMale, #SWAT, 393.5883, -476.6203, 12.34322) 02AB: set_actor [email protected] immunities 0 1 0 0 0 02AB: set_actor [email protected] immunities 0 1 0 0 0 02AB: set_actor [email protected] immunities 0 1 0 0 0 02AB: set_actor [email protected] immunities 0 1 0 0 0 02A9: set_actor [email protected] immune_to_nonplayer 1 02A9: set_actor [email protected] immune_to_nonplayer 1 02A9: set_actor [email protected] immune_to_nonplayer 1 02A9: set_actor [email protected] immune_to_nonplayer 1 01B2: give_actor [email protected] weapon 25 ammo 9999 // Load the weapon model before using this 01B2: give_actor [email protected] weapon 25 ammo 9999 // Load the weapon model before using this 01B2: give_actor [email protected] weapon 25 ammo 9999 // Load the weapon model before using this 01B2:: give_actor [email protected] weapon 25 ammo 9999 // Load the weapon model before using this 02E2: set_actor [email protected] weapon_accuracy_to 10 02E2: set_actor [email protected] weapon_accuracy_to 10 02E2: set_actor [email protected] weapon_accuracy_to 10 02E2:: set_actor [email protected] weapon_accuracy_to 10 0502: unknown_actor [email protected] sprint_to 382.1172 -491.1101 0502: unknown_actor [email protected] sprint_to 381.8355 -488.5485 0502: unknown_actor [email protected] sprint_to 382.1172 -491.1101 0502: unknown_actor [email protected] sprint_to 381.8355 -488.5485 Model.Destroy(#ENFORCER) Model.Destroy(#SWAT) Model.Destroy(#ARMY) Model.Destroy(#M4) Model.Destroy(#MP5LNG) Model.Destroy(#TEC9) :GOSUBS wait 0 if or not Player.Wasted($PLAYER_CHAR) Player.WantedLevel($PLAYER_CHAR) > 3 else_jump @SWAT_1756 gosub @SWAT_3 gosub @SWAT_4 gosub @SWAT_5 gosub @SWAT_6 jump @GOSUBS end_thread :SWAT_3 wait 0 if or 80ED: not actor [email protected] 0 383.4081 -486.859 radius 0.4 0.4 80ED: not actor [email protected] 0 387.024 -482.5168 radius 0.4 0.4 80ED: not actor [email protected] 0 385.2087 -488.4312 radius 0.4 0.4 80ED: not actor [email protected] 0 388.8536 -484.0807 radius 0.4 0.4 else_jump @SWAT_801 if 0123: actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_842 if not Actor.Dead([email protected]) else_jump @SWAT_1680 01CA: actor [email protected] kill_player $PLAYER_CHAR jump @SWAT_889 :SWAT_801 0502: unknown_actor [email protected] sprint_to 382.5863 -491.2727 if 8123: not actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_889 jump @SWAT_842 :SWAT_842 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 0502: unknown_actor [email protected] sprint_to [email protected] [email protected] jump @SWAT_889 :SWAT_889 return :SWAT_4 wait 0 if or 80ED: not actor [email protected] 0 383.4081 -486.859 radius 0.4 0.4 80ED: not actor [email protected] 0 387.024 -482.5168 radius 0.4 0.4 80ED: not actor [email protected] 0 385.2087 -488.4312 radius 0.4 0.4 80ED: not actor [email protected] 0 388.8536 -484.0807 radius 0.4 0.4 else_jump @SWAT_1064 if 0123: actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_1105 if not Actor.Dead([email protected]) else_jump @SWAT_1680 01CA: actor [email protected] kill_player $PLAYER_CHAR jump @SWAT_1152 :SWAT_1064 0502: unknown_actor [email protected] sprint_to 382.5863 -491.2727 if 8123: not actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_1152 jump @SWAT_1105 :SWAT_1105 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 0502: unknown_actor [email protected] sprint_to [email protected] [email protected] jump @SWAT_1152 :SWAT_1152 return :SWAT_5 wait 0 if or 80ED: not actor [email protected] 0 383.4081 -486.859 radius 0.4 0.4 80ED: not actor [email protected] 0 387.024 -482.5168 radius 0.4 0.4 80ED: not actor [email protected] 0 385.2087 -488.4312 radius 0.4 0.4 80ED: not actor [email protected] 0 388.8536 -484.0807 radius 0.4 0.4 else_jump @SWAT_1327 if 0123: actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_1368 if not Actor.Dead([email protected]) else_jump @SWAT_1680 01CA: actor [email protected] kill_player $PLAYER_CHAR jump @SWAT_1415 :SWAT_1327 0502: unknown_actor [email protected] sprint_to 382.5863 -491.2727 if 8123: not actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_1415 jump @SWAT_1368 :SWAT_1368 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 0502: unknown_actor [email protected] sprint_to [email protected] [email protected] jump @SWAT_1415 :SWAT_1415 return :SWAT_6 wait 0 if or 80ED: not actor [email protected] 0 383.4081 -486.859 radius 0.4 0.4 80ED: not actor [email protected] 0 387.024 -482.5168 radius 0.4 0.4 80ED: not actor [email protected] 0 385.2087 -488.4312 radius 0.4 0.4 80ED: not actor [email protected] 0 388.8536 -484.0807 radius 0.4 0.4 else_jump @SWAT_1590 if 0123: actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_1631 if not Actor.Dead([email protected]) else_jump @SWAT_1680 01CA: actor [email protected] kill_player $PLAYER_CHAR jump @SWAT_1678 :SWAT_1590 0502: unknown_actor [email protected] sprint_to 382.5863 -491.2727 if 8123: not actor [email protected] spotted_player $PLAYER_CHAR else_jump @SWAT_1678 jump @SWAT_1631 :SWAT_1631 04C4: create_coordinate [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR offset 1.0 1.0 0.0 0502: unknown_actor [email protected] sprint_to [email protected] [email protected] jump @SWAT_1678 :SWAT_1678 return :SWAT_1680 if Actor.Dead([email protected]) else_jump @SWAT_889 if Actor.Dead([email protected]) else_jump @SWAT_1152 if Actor.Dead([email protected]) else_jump @SWAT_1415 if Actor.Dead([email protected]) else_jump @SWAT_1678 wait 5000 jump @SWAT_1756 :SWAT_1756 Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) jump @LOAD Edited February 18, 2012 by JACK JONES Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
ZAZ Posted February 18, 2012 Share Posted February 18, 2012 (edited) :SWAT_1678 return :SWAT_1680 if Actor.Dead([email protected]) else_jump @SWAT_889 <--- bullsh*tif Actor.Dead([email protected]) else_jump @SWAT_1152 <--- bullsh*t if Actor.Dead([email protected]) else_jump @SWAT_1415 <--- bullsh*t if Actor.Dead([email protected]) else_jump @SWAT_1678 <--- bullsh*t wait 5000 jump @SWAT_1756<--- bullsh*t :SWAT_1756 Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) jump @LOAD these are jumps to previous labels above of the jumpinstruction so these labels need a wait but they don't have any SWAT_889, SWAT_1152, SWAT_1415, SWAT_1678 in addition is this scriptpart a part of a subscript and must end with return at the end but it should jump to SWAT_1756 if all actors are dead but the part of SWAT_1756 isn't a subscript, it jumps back instead to beginning remove the actor dead check at that place and put it in your "GOSUB"-Loop :GOSUBS wait 0 if or not Player.Wasted($PLAYER_CHAR) Player.WantedLevel($PLAYER_CHAR) > 3 else_jump @SWAT_1756 gosub @SWAT_3 gosub @SWAT_4 gosub @SWAT_5 gosub @SWAT_6 if and Actor.Dead([email protected]) Actor.Dead([email protected]) Actor.Dead([email protected]) Actor.Dead([email protected])else_jump @GOSUBSActor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) jump @LOAD:SWAT_1678 return :SWAT_1680 return:SWAT_1756 Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) Actor.DestroyInstantly([email protected]) jump @LOAD Edited February 18, 2012 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Jack Posted February 18, 2012 Author Share Posted February 18, 2012 I didn't have a chance to check my topic earlier. And yes, this solved the problem - the crashing stoped. You have no idea how much you helped man. Thanks ZAZ. Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now