Bad.boy! Posted January 30, 2012 Share Posted January 30, 2012 I'm having problem with high end struct, especially with while true. My code doesn't compile: {$CLEO .cs}thread 'HARDER':HARDERrepeatwait 0until Player.Defined($PLAYER_CHAR)repeatwait [email protected] = Player.WantedLevel($PLAYER_CHAR)until [email protected] == 6if Actor.Driving($PLAYER_ACTOR) then if Actor.DrivingPlane($PLAYER_ACTOR) then Model.Load(#ARMY) Model.Load(#HYDRA) while true wait 0 if and Model.Available(#ARMY) Model.Available(#HYDRA) then [email protected] = 2 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 50.0 50.0 50.0 [email protected] = Car.Create(#HYDRA, [email protected], [email protected], [email protected]) 0745: set_hydra [email protected] thrust_to_horizontal 08E6: set_plane [email protected] landing_gear 0 0742: unknown_plane [email protected] unknown_set 0.5 08A2: set_hydra [email protected] attack_with_rockets_car_of_player $PLAYER_CHAR radius 30.0 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset -50.0 50.0 50.0 [email protected] = Car.Create(#HYDRA, [email protected], [email protected], [email protected]) 0745: set_hydra [email protected] thrust_to_horizontal 08E6: set_plane [email protected] landing_gear 0 0742: unknown_plane [email protected] unknown_set 0.5 08A2: set_hydra [email protected] attack_with_rockets_car_of_player $PLAYER_CHAR radius 30.0 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 0249: release_model #ARMY 0249: release_model #HYDRA while true wait 0 gosub @CHECK if and Car.Wrecked([email protected]) Car.Wrecked([email protected]) then gosub @CLEANUP jump @HARDER end end else Model.Load(#ARMY) Model.Load(#HUNTER) while true wait 0 if and Model.Available(#ARMY) Model.Available(#HUNTER) then [email protected] = 1 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 50.0 50.0 50.0 [email protected] = Car.Create(#HUNTER, [email protected], [email protected], [email protected]) 0841: flying_vehicle [email protected] use_secondary_gun 1 0724: heli [email protected] follow_and_attack_player $PLAYER_CHAR radius 50.0 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset -50.0 50.0 50.0 [email protected] = Car.Create(#HUNTER, [email protected], [email protected], [email protected]) 0841: flying_vehicle [email protected] use_secondary_gun 0 0724: heli [email protected] follow_and_attack_player $PLAYER_CHAR radius 50.0 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 0249: release_model #ARMY 0249: release_model #HUNTER while true wait 0 gosub @CHECK if and Car.Wrecked([email protected]) Car.Wrecked([email protected]) then gosub @CLEANUP jump @HARDER end end end else // <-- PROBLEM jump @HARDERend:CHECKwait [email protected] = Player.WantedLevel($PLAYER_CHAR)if [email protected] == 6 then if [email protected] == 2 then if Actor.DrivingPlane($PLAYER_ACTOR) then return else gosub @CLEANUP jump @HARDER end else if [email protected] == 1 then if and not Actor.DrivingPlane($PLAYER_ACTOR) Actor.Driving($PLAYER_ACTOR) then return else gosub @CLEANUP jump @HARDER end end end else jump @CLEANUP jump @HARDERend :CLEANUPCar.RemoveReferences([email protected])Car.RemoveReferences([email protected])Actor.RemoveReferences([email protected])Actor.RemoveReferences([email protected])return Link to comment Share on other sites More sharing options...
spaceeinstein Posted January 30, 2012 Share Posted January 30, 2012 (edited) When using high end structure, make sure you line up the if..then...else...end so that you can find errors more easily. if Actor.Driving($PLAYER_ACTOR)then if Actor.DrivingPlane($PLAYER_ACTOR) then Model.Load(#ARMY) Model.Load(#HYDRA) while true wait 0 if and Model.Available(#ARMY) Model.Available(#HYDRA) then [email protected] = 2 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 50.0 50.0 50.0 [email protected] = Car.Create(#HYDRA, [email protected], [email protected], [email protected]) 0745: set_hydra [email protected] thrust_to_horizontal 08E6: set_plane [email protected] landing_gear 0 0742: unknown_plane [email protected] unknown_set 0.5 08A2: set_hydra [email protected] attack_with_rockets_car_of_player $PLAYER_CHAR radius 30.0 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset -50.0 50.0 50.0 [email protected] = Car.Create(#HYDRA, [email protected], [email protected], [email protected]) 0745: set_hydra [email protected] thrust_to_horizontal 08E6: set_plane [email protected] landing_gear 0 0742: unknown_plane [email protected] unknown_set 0.5 08A2: set_hydra [email protected] attack_with_rockets_car_of_player $PLAYER_CHAR radius 30.0 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 049: release_model #ARMY 0249: release_model #HYDRA while true wait 0 gosub @CHECK if and Car.Wrecked([email protected]) Car.Wrecked([email protected]) then gosub @CLEANUP jump @HARDER end end else Model.Load(#ARMY) Model.Load(#HUNTER) while true wait 0 if and Model.Available(#ARMY) Model.Available(#HUNTER) then [email protected] = 1 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 50.0 50.0 50.0 [email protected] = Car.Create(#HUNTER, [email protected], [email protected], [email protected]) 0841: flying_vehicle [email protected] use_secondary_gun 1 0724: heli [email protected] follow_and_attack_player $PLAYER_CHAR radius 50.0 04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset -50.0 50.0 50.0 [email protected] = Car.Create(#HUNTER, [email protected], [email protected], [email protected]) 0841: flying_vehicle [email protected] use_secondary_gun 0 0724: heli [email protected] follow_and_attack_player $PLAYER_CHAR radius 50.0 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 0129: [email protected] = create_actor_pedtype 7 model #ARMY in_car [email protected] driverseat 0249: release_model #ARMY 0249: release_model #HUNTER while true wait 0 gosub @CHECK if and Car.Wrecked([email protected]) Car.Wrecked([email protected]) then gosub @CLEANUP jump @HARDER end end end else // As you can see, now that it's lined up (I think I did that right), you're missing a few ends there. The problem area is that you didn't end the while loop. Edited January 30, 2012 by spaceeinstein Link to comment Share on other sites More sharing options...
Bad.boy! Posted January 30, 2012 Author Share Posted January 30, 2012 Thanks for the help, my script works. I don't know if everyone already knows what this opcode means: 0742: unknown_plane [email protected] unknown_set 0.5 But I just found out that if the value is set 0.5 and use opcode 08A2 (hydra attacks with rockets), the hydra will shoot heetseakers instead of normal rockets. Link to comment Share on other sites More sharing options...
ZAZ Posted January 30, 2012 Share Posted January 30, 2012 Thanks for the help, my script works. I don't know if everyone already knows what this opcode means: 0742: unknown_plane [email protected] unknown_set 0.5 But I just found out that if the value is set 0.5 and use opcode 08A2 (hydra attacks with rockets), the hydra will shoot heetseakers instead of normal rockets. I used that code as I made a script where Hydras are shooting throw San Fierro Downtown >click< It's an x_angle, the Hydra lifts up with 17.5 after removeing reference and continues flying like an Aerobatics CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Bad.boy! Posted January 30, 2012 Author Share Posted January 30, 2012 Strange, because withouth that opcode hydra's don't shoot heatseekers, at all. And if I increase the number from 0.5 to 1.0 the rockets are stronger heatseeking. Also the mission where the opcode was originally used (with hydra, from vertical bird): 0742: unknown_plane [email protected]([email protected],3i) unknown_set 0.5 08A2: set_hydra [email protected]([email protected],3i) attack_with_rockets_car_of_player $PLAYER_CHAR radius 30.0 Another mission (zero, rc sh*t): 04D2: set_plane [email protected]([email protected],10i) fly_autopilot_around_point [email protected]([email protected],4f) [email protected]([email protected],4f) [email protected] altitude_between -1.0 and 13.5 0742: unknown_plane [email protected]([email protected],10i) unknown_set -0.8 The code might just do both, but I think it's about the contex where it is written. Because in the first example, the heatseek would make more sense than aerobatics. But in the second script, the heatseek doesn't make any sense at all. You can test it yourself Hydra's won't launch heatseekers withouth that code. 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