Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Please help me fix this script


🖕
 Share

Recommended Posts

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

 

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 by ZAZ
Link to comment
Share on other sites

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

 

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

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.