🖕 Posted December 11, 2020 Share Posted December 11, 2020 I made a script with the following features:  If you are <200 units away from Grove Street, spawn special car (added model, but I change it to Banshee in the code for those who wanna help) If you are >200 units away from car (not grove street) or if destroyed, delete car; If >5 units away from car, doors lock and every open door will close; If <5 units away, doors unlock so you can get in; If out of car, marker appears on radar; If in car, marker disappears.  THE PROBLEM: Game crash when using teleport.cs mod (that's what I came here for. if you see anything else please tell me)  Code:  // This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 6.14.2013 {$CLEO .cs} //-------------MAIN--------------- thread 'PV' wait 1000 :PV_10 $CREATE = false wait 0 if    Player.Defined($PLAYER_CHAR) then    Model.Load(#BANSHEE)    038B: load_requested_models    jump @PV_50 else    jump @PV_10 end :PV_50 wait 0 if and    Model.Available(#BANSHEE)    00FE:  actor $PLAYER_ACTOR sphere 0 near_point 2487.5 -1660.5 13.35 radius 200.0 200.0 200.0    not Actor.DrivingVehicleType($PLAYER_ACTOR, #BANSHEE)    80C2:  not is_point_on_screen 2487.5 -1660.5 13.35 radius 5.0 then    jump @PV_100 else    jump @PV_50 end :PV_100 $CREATE = true 0395: clear_area 1 at 2487.5 -1660.5 13.35 radius 5.0 $CAR = Car.Create(#BANSHEE, 2487.5, -1660.5, 13.35) Car.Angle($CAR) = 90.0 Car.SetImmunities($CAR, 1, 1, 1, 1, 1) 0423: set_car_improved_handling $CAR to 2.0 0224: set_car_health $CAR to 5000 Marker.CreateAboveCar($MARK, $CAR) 018B: set_marker $MARK radar_mode 2 0165: change_blip_colour $MARK to 3  jump @PV_300 :PV_300 wait 0 while $CREATE == true    wait 0    if or        8205:  not actor $PLAYER_ACTOR near_car $CAR radius 200.0 200.0 200.0 flag 0        Car.Wrecked($CAR)        02BF:  is_car_in_water $CAR    then        wait 0        if            82CA: not is_car_on_screen $CAR        then            break        else            continue        end    else        wait 0        if            0205:  actor $PLAYER_ACTOR near_car $CAR radius 5.0 5.0 5.0 flag 0        then            020A: lock_car_doors $CAR mode 1            wait 0            if                Actor.InCar($PLAYER_ACTOR, $CAR)            then                018B: set_marker $MARK radar_mode 0            else                018B: set_marker $MARK radar_mode 2            end        else            0508: close_all_car_doors $CAR            020A: lock_car_doors $CAR mode 2        end    end end :PV_500 wait 0 $CREATE = false 00A6: delete_car $CAR Model.Destroy(#BANSHEE) jump @PV_600 :PV_600 wait 0 jump @PV_10  Link to comment Share on other sites More sharing options...
ZAZ Posted December 12, 2020 Share Posted December 12, 2020 (edited)  Don't use Global Variables like $CAR in Cleo scripting Use Local Vars instead: [email protected] [email protected]  In addition, there's no need for $CREATE, unless you wanna controle it from another script  Use Constants construct to assigne names as Local Var Quote const    Lvar_C_A_R = [email protected]    Lvar_M_A_R_K = [email protected] end (this construct is just a placeholder management of sannybuilder, it disappear by recompiling) Check always if player $PLAYER_CHAR defined, if you wanna use codes depending to $PLAYER_CHAR or $PLAYER_ACTOR read tutorial  your script Quote {$CLEO .cs} thread 'PV' const    Lvar_C_A_R = [email protected]    Lvar_M_A_R_K = [email protected] end  while true    wait 0    if        0256:  player $PLAYER_CHAR defined    then        if and            00FE:  actor $PLAYER_ACTOR sphere 0 in_sphere 2487.5 -1660.5 13.35 radius 100.0 100.0 100.0            //not Actor.DrivingVehicleType($PLAYER_ACTOR, #BANSHEE)            80C2:  not sphere_onscreen 2487.5 -1660.5 13.35 radius 5.0        then            Model.Load(#BANSHEE)            038B: load_requested_models            0395: clear_area 1 at 2487.5 -1660.5 13.35 radius 5.0            Lvar_C_A_R = Car.Create(#BANSHEE, 2487.5, -1660.5, 13.35)            Car.Angle(Lvar_C_A_R) = 90.0            Car.SetImmunities(Lvar_C_A_R, 1, 1, 1, 1, 1)            0423: set_car_improved_handling Lvar_C_A_R to 2.0            0224: set_car_health Lvar_C_A_R to 5000            Marker.CreateAboveCar(Lvar_M_A_R_K, Lvar_C_A_R)            018B: set_marker Lvar_M_A_R_K radar_mode 2            0165: change_blip_colour Lvar_M_A_R_K to 3                                  while 0256:  player $PLAYER_CHAR defined                wait 0                if or                    8205:  not actor $PLAYER_ACTOR near_car Lvar_C_A_R radius 150.0 150.0 150.0 flag 0                    Car.Wrecked(Lvar_C_A_R)                    02BF:  is_car_in_water Lvar_C_A_R                then                    if                        82CA: not is_car_on_screen Lvar_C_A_R                    then                        break                    end                else                    if                        0205:  actor $PLAYER_ACTOR near_car Lvar_C_A_R radius 5.0 5.0 5.0 flag 0                    then                        020A: lock_car_doors Lvar_C_A_R mode 1                        wait 0                        if                            Actor.InCar($PLAYER_ACTOR, Lvar_C_A_R)                        then                            018B: set_marker Lvar_M_A_R_K radar_mode 0                        else                            018B: set_marker Lvar_M_A_R_K radar_mode 2                        end                    else                        0508: close_all_car_doors Lvar_C_A_R                        020A: lock_car_doors Lvar_C_A_R mode 2                    end                end                                              end            0164: disable_marker Lvar_M_A_R_K            00A6: delete_car Lvar_C_A_R            Model.Destroy(#BANSHEE)                             end    end end  Edited December 12, 2020 by ZAZ 🖕 1 CLEO MODS   CLEO Script Tutorial Link to comment Share on other sites More sharing options...
🖕 Posted December 13, 2020 Author Share Posted December 13, 2020 18 hours ago, ZAZ said: snip Damn! You the real MVP!  Can you please explain how you made it work? Thanks. Link to comment Share on other sites More sharing options...
ZAZ Posted December 13, 2020 Share Posted December 13, 2020  I haven't tested your script because of the globals and the beginning with model load Did it crash? I started the script by new and tried to implement your code as good as possible  It's a simple script, good for learning  Consider a few important things  - Don't use Global Variables like $CAR in Cleo scripting, it can cause bugs and crashes, except $PLAYER_CHAR $PLAYER_ACTOR and $ONMISSION, these are the 3 valid Globals  - Check always if player $PLAYER_CHAR defined, if you wanna use codes depending to $PLAYER_CHAR or $PLAYER_ACTOR - Built as first a conditional check that must be passed to can run code for the mod feature - put minimum wait time (wait 0) inside of each Loop   CLEO MODS   CLEO Script Tutorial Link to comment Share on other sites More sharing options...
🖕 Posted December 13, 2020 Author Share Posted December 13, 2020 Works everytime I tried. And yes I'm gonna remember all those.  Link to comment Share on other sites More sharing options...
ZAZ Posted December 13, 2020 Share Posted December 13, 2020 make shure to have newest sannybuilder and look for Sanny Builder 3(install_dir)\help\examples\Tutorials_by_ZAZ\Example_Scripts CLEO MODSÂ Â Â CLEO Script Tutorial 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