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

Happy Holidays from the GTANet team!

create_searchlight on car


Garwan50
 Share

Recommended Posts

Hello !

 

I tried to use create_searchlight on a police maverick and it worked fine.

 

I tried to use it on a lspd police car but it didn't worked, it crashes the game.

Any idea why ?

{$CLEO .cs}0000: NOPwhile true    wait 0 ms    while  actor.DrivingVehicleType($PLAYER_ACTOR, 596)        wait 0 ms        if            0AB0: key_pressed 17        then            wait 0 ms            if                06B3: does_searchlight_exist [email protected]            then            else                0ACD: show_text_highpriority "Initialisation du projecteur" time 500                wait 1000 ms                03C0: [email protected] = actor $PLAYER_ACTOR car                06C1: create_searchlight [email protected] on_car [email protected] with_offset 0.0 2.3 -0.7 radius 0.2 target 0.0 0.0 0.0 radius 12.5            end        end                if and             0AB0: key_pressed 80            06B3: does_searchlight_exist [email protected]                    then            06B2: delete_searchlight [email protected]        end    endend

Thanks !

Link to comment
Share on other sites

Hello,

 

thanks for the answer, it works a little better.

In a LSPD police car it crashes, but it another vehicle it kinda works.

 

I made a loop so that the searchlight is created on the new car position.

 

However this actor.DrivingVehicleType($PLAYER_ACTOR, MODEL) doesn't really seems to work, is there an alternative ?

 

Also, how come those have the same OPCODE but they're used differently

06B1: create_searchlight [email protected] [email protected] [email protected] to 0.0 0.0 0.0 radius 0.2 radius 5.0 store_to [email protected]
06B1: [email protected] = create_searchlight_at [email protected] [email protected] [email protected] radius 0.2 target 0.0 0.0 0.0 radius 3.0
?
Thanks !
Edited by Garwan50
Link to comment
Share on other sites

Also, how come those have the same OPCODE but they're used differently

06B1: create_searchlight [email protected] [email protected] [email protected] to 0.0 0.0 0.0 radius 0.2 radius 5.0 store_to [email protected]

06B1: [email protected] = create_searchlight_at [email protected] [email protected] [email protected] radius 0.2 target 0.0 0.0 0.0 radius 3.0

 

It's because of different versions of sascm.ini , parameter order changed from older to newer version

Lastest Sannybuilder came with sascm.ini where it looks like this:

06B1=9,%9d% = create_searchlight_at %1d% %2d% %3d% radius %8d% target %4d% %5d% %6d% radius %7d%

script code looks then like this

06B1: [email protected] = create_searchlight_at 2568.1 -1287.2 1059.15 radius 0.2 target 2558.7058 -1285.3613 1055.5 radius 8.5

Searchlight on COPCARLA works for me without problem

Try script below and note: you should always check if player_char is defined and if the car isn't wrecked

{$CLEO .cs}thread 'SLIGHT'while true    wait 0    if        0256:   player $PLAYER_CHAR defined    then        if  and            0AB0: key_pressed 17// 	ctrl key            actor.DrivingVehicleType($PLAYER_ACTOR, 596)        then            0ACD: show_text_highpriority "Initialisation du projecteur" time 500            wait 1000 ms            03C0: 2[email protected] = actor $PLAYER_ACTOR car            0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 0.0 20.0 0.0            06C1: create_searchlight [email protected] on_car [email protected] with_offset 0.0 2.3 -0.7 radius 0.2 target [email protected] [email protected] [email protected] radius 12.5                    while  0256:   player $PLAYER_CHAR defined                wait 0                if or                     0AB0: key_pressed 80// 	p key                    0119:   car [email protected] wrecked                            then                    break                end            end                        06B2: delete_searchlight [email protected]        end    endend
Link to comment
Share on other sites

Hey, thanks for your answer !

 

Changing vehid from 596 to 597 (or anything else) works, but 596 crashes the game, so that's strange.

It works but sometimes it crashes (without any warning) while i'm driving.

Cleo is very hard to debug :(.

 

Also, how can i know what version of sascm.ini i'm using please ?

 

 

It doesn't seem to crash anymore.

I'm trying to move the searchlight with the numpad :

{$CLEO .cs}thread 'SLIGHT'while true    wait 0    if        0256:   player $PLAYER_CHAR defined    then        if  and            0AB0: key_pressed 17// 	ctrl key            actor.DrivingVehicleType($PLAYER_ACTOR, 597)        then            0ACD: show_text_highpriority "Initialisation du projecteur" time 500            wait 1000 ms            03C0: [email protected] = actor $PLAYER_ACTOR car            0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 0.0 0.0 5.0            06C1: create_searchlight [email protected] on_car [email protected] with_offset -1.3 1.0 0.2 radius 0.2 target [email protected] [email protected] [email protected] radius 1.0                    while  0256:   player $PLAYER_CHAR defined                wait 0                                if                    0AB0: key_pressed 98 // 	2 numlock key                then                    0ACD: show_text_highpriority "bas" time 500                    wait 500 ms                    0624: add -1.0 to_float_stat [email protected]                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 100 // 	4 numlock key                then                    0624: add 1.0 to_float_stat [email protected]                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 102 // 	6 numlock key                then                    0624: add -1.0 to_float_stat [email protected]                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 104 // 	8 numlock key                then                    0ACD: show_text_highpriority "haut" time 500                    wait 500 ms                    0624: add 1.0 to_float_stat [email protected]                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                    if or                     0AB0: key_pressed 80// 	p key                    0119:   car [email protected] wrecked                            then                    break                end            end                        06B2: delete_searchlight [email protected]        end    endend

i see the text but nothing else happen, i suppose i'm using the wrong opcode again ?

 

Again, thanks for your help, I really appreciate it !

Edited by Garwan50
Link to comment
Share on other sites

Hey

 

I've used different OPCODE and now it works fine !

The control of the searchlight is a little awkward, i wish I could improve it.

 

But I guess it works !

{$CLEO .cs}thread 'SLIGHT'while true    wait 0    if        0256:   player $PLAYER_CHAR defined    then        if  and            0AB0: key_pressed 17// 	ctrl key            actor.DrivingVehicleType($PLAYER_ACTOR, 597)        then            0ACD: show_text_highpriority "Initialisation du projecteur" time 500            wait 1000 ms            03C0: [email protected] = actor $PLAYER_ACTOR car            0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 0.0 0.0 5.0            06C1: create_searchlight [email protected] on_car [email protected] with_offset -1.3 1.0 0.2 radius 0.2 target [email protected] [email protected] [email protected] radius 9.0                    while  0256:   player $PLAYER_CHAR defined                wait 0                                if                    0AB0: key_pressed 97 // 	1 numlock key                then                    000B: [email protected] += 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 98 // 	2 numlock key                then                    000F: [email protected] -= 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 99 // 	3 numlock key                then                    000F: [email protected] -= 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 100 // 	4 numlock key                then                    000F: [email protected] -= 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 102 // 	6 numlock key                then                    000B: [email protected] += 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                if                    0AB0: key_pressed 104 // 	8 numlock key                then                    000B: [email protected] += 0.2                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                    if or                     0AB0: key_pressed 80// 	p key                    0119:   car [email protected] wrecked                            then                    break                end            end                        06B2: delete_searchlight [email protected]        end    endend
Link to comment
Share on other sites

Changing vehid from 596 to 597 (or anything else) works, but 596 crashes the game, so that's strange.

It works but sometimes it crashes (without any warning) while i'm driving.

Test the script on an unmodded installation with only cleo installed

 

Also, how can i know what version of sascm.ini i'm using please ?

sascm.ini is placed in Sannbuilder install directory/data/sa

when you decompile a cleo script, then info about sascm.ini will be shown at first line of decompiled script text

GTA SA came out 13 years ago, at that time Bart waterduck published the first sascm.ini together with his BW Missionbuilder and Sannybuilder came later

Several coders were helping to discover the main.scm all the time and they had the discussion, that modern codes needs to be written in that way that the main parameter should be written at beginning

from

06B1: create_searchlight [email protected] [email protected] [email protected] to 0.0 0.0 0.0 radius 0.2 radius 5.0 store_to [email protected]

to

06B1: [email protected] = create_searchlight_at [email protected] [email protected] [email protected] radius 0.2 target 0.0 0.0 0.0 radius 3.0

 

that caused a confusion and if you find a script anywhere in the internet, it can have codes with changed parameter order than your current sascm.ini

 

At least, Deji was shure to discover the main.scm by the originally R* code description, maybe 5 years ago), you can find it here(website isn't available anymore). It has also codes where the parameter order has changed

 

 

 

 

i see the text but nothing else happen, i suppose i'm using the wrong opcode again ?

opcode 0624: is wrong, it depends to the player statistics, look in Sanny Builder Help > SCM Documentation > GTA SA > Statistics ID

you just need to write [email protected] += 1.0 or [email protected] -= 1.0 instead

[email protected] += 1.006B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed [email protected] -= 1.006B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0

 

 

I did it in that way

:PmCspx_SLTable20871: init_jump_table [email protected] total_jumps  7  0 @PmCspx_SLT01 jumps  0 @PmCspx_SLT01  1 @PmCspx_SLT11  2 @PmCspx_SLT22  3 @PmCspx_SLT33  4 @PmCspx_SLT44  5 @PmCspx_SLT55 6 @PmCspx_SLT66:PmCspx_SLT010002: jump @PmCspx_SLTout1:PmCspx_SLT110407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 0.0 4.0 [email protected]: create_coordinate [email protected] [email protected] [email protected] from_car 2@ offset 2.0 3.0 [email protected]: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.50002: jump @PmCspx_SLTout1:PmCspx_SLT220407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 3.0 2.0 [email protected]: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 3.0 0.0 [email protected]: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.50002: jump @PmCspx_SLTout1:PmCspx_SLT330407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 3.0 -2.0 [email protected]: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 2.0 -3.0 [email protected]: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.50002: jump @PmCspx_SLTout1:PmCspx_SLT440407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 0.0 -3.0 [email protected]: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -2.0 -4.0 [email protected]: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.50002: jump @PmCspx_SLTout1:PmCspx_SLT550407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -3.0 -2.0 [email protected]: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -3.0 0.0 [email protected]: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.50002: jump @PmCspx_SLTout1:PmCspx_SLT660407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -2.0 2.0 [email protected]: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -2.0 4.0 [email protected]: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.50002: jump @PmCspx_SLTout1:PmCspx_SLTout10002: jump @PmCspx_40051: return

The searchlight rotates around while car is driving, so it needs permanently new coords for path

Link to comment
Share on other sites

Hello,

 

again, thanks for your answer, and for the informations on sascm.ini !

 

I'm a little confused by your code, what, what does set_searchlight path_between does exactly ? It take the middle of two set of coordinates ?

What about the jump_table and all the labels ? I have to admit i can't really understand how it works.

 

thanks tho i made some good progress thanks to you :

https://cdn.discordapp.com/attachments/227087657577086976/426743392244989952/sa-mp-133.png

https://cdn.discordapp.com/attachments/227087657577086976/426743387572535296/sa-mp-134.png

Link to comment
Share on other sites

06B4: let the light beam move from one target to the other and back, it wanders all the time

i didn't know what you're trying, your screenshot shows now more and 06B5: is fine for that, but using 0407: or 04C4: to get coords for target, makes sense

 

read here about jumptable

Link to comment
Share on other sites

Hello, good morning.

 

At first I was just playing around, now I have a mod idea :

You can control the searchlight with the numpad (done)

You can also press the ctrl key again to search for a nearby actor, the searchlight will then follow the actor until you press the "p" key (having issue)

My current code crashes the game before it even loads, I think it's related to the else condition of the first if.

{$CLEO .cs}thread 'SLIGHT'while true    wait 0    if        0256:   player $PLAYER_CHAR defined    then        if  and            0AB0: key_pressed 17// 	ctrl key            actor.DrivingVehicleType($PLAYER_ACTOR, 597)            06B3: not searchlight [email protected] active        then            0ACD: show_text_highpriority "Initialisation du projecteur" time 500            03C0: [email protected] = actor $PLAYER_ACTOR car            0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -2.0 3.0 -1.0            06C1: create_searchlight [email protected] on_car [email protected] with_offset -1.2 1.0 0.4 radius 0.2 target [email protected] [email protected] [email protected] radius 9.0                    while 0256: player $PLAYER_CHAR defined                wait 0                                if                    0AB0: key_pressed 97 // 	1 numlock key                then                    000B: [email protected] += 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                if                    0AB0: key_pressed 98 // 	2 numlock key                then                    000F: [email protected] -= 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                if                    0AB0: key_pressed 99 // 	3 numlock key                then                    000F: [email protected] -= 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                if                    0AB0: key_pressed 100 // 	4 numlock key                then                    000F: [email protected] -= 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                if                    0AB0: key_pressed 102 // 	6 numlock key                then                    000B: [email protected] += 0.1                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                if                    0AB0: key_pressed 104 // 	8 numlock key                then                    000B: [email protected] += 0.2                    06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0                end                                    if or                     0AB0: key_pressed 80// 	p key                    0119: car [email protected] wrecked                    NOT actor.DrivingVehicleType($PLAYER_ACTOR, 597)                            then                    break                end                    end            :delete_projecteur            06B2: delete_searchlight [email protected]        else            actor.StorePos($PLAYER_ACTOR, [email protected], [email protected], [email protected])            for [email protected] = 0 to 3000                wait 0                if and                    0039: NOT [email protected] == $PLAYER_ACTOR // l'actor n'est pas celui du joueur                    NOT actor.Dead([email protected])            // lactor nest pas mort                                                         NOT actor.Driving([email protected])         // lactor n'est pas au volant                    00FE: actor [email protected] sphere 0 in_sphere [email protected] [email protected] [email protected] radius 15.0 15.0 15.0  // actor pas trop loin                then                    0ACD: show_text_highpriority "find" time 500                    0006: [email protected] = [email protected]                    06B6: set_searchlight [email protected] follow_actor [email protected] speed 9.0                    break                end            end                        while 0256: player $PLAYER_CHAR defined                wait 0                actor.StorePos($PLAYER_ACTOR, [email protected], [email protected], [email protected])                if or                    actor.Driving([email protected])                    actor.Dead([email protected])                    00FE: not actor [email protected] sphere 0 in_sphere [email protected] [email protected] [email protected] radius 15.0 15.0 15.0                then                    0ACD: show_text_highpriority "lost" time 500                    break                end                                if or                     0AB0: key_pressed 80// 	p key                    0119: car [email protected] wrecked                    NOT actor.DrivingVehicleType($PLAYER_ACTOR, 597)                            then                    jump @delete_projecteur                end            end        end    endend

Do you have any tips for me to debug it ?

Or any idea what i've done wrong ?

 

Thanks for your time

Link to comment
Share on other sites

this isn't really a NOT condition

06B3: not searchlight [email protected] active

to make it as NOT condition needs to change the zero into eight 06B3: -> 86B3:
this is true for every conditions, unless you're using classes like this:

not actor.DrivingVehicleType($PLAYER_ACTOR, 597)

but also if written right, in case if search_light exist or actor isn't in car or key 17 isn't pressed, then the code goes to the else block where the not existing search_light should move

{$CLEO .cs}thread 'SLIGHT'while true    wait 0    if        0256:   player $PLAYER_CHAR defined    then        if  and            0AB0: key_pressed 17// 	ctrl key            actor.DrivingVehicleType($PLAYER_ACTOR, 597)            86B3: not searchlight [email protected] active        then            06C1: create_searchlight [email protected] on_car [email protected] with_offset -1.2 1.0 0.4 radius 0.2 target [email protected] [email protected] [email protected] radius 9.0                    while 0256: player $PLAYER_CHAR defined                wait 0                    end            :delete_projecteur            06B2: delete_searchlight [email protected]        else            actor.StorePos($PLAYER_ACTOR, [email protected], [email protected], [email protected])            for [email protected] = 0 to 3000                wait 0                if and                    0039: NOT [email protected] == $PLAYER_ACTOR // l'actor n'est pas celui du joueur                    NOT actor.Dead([email protected])            // lactor nest pas mort                                                         NOT actor.Driving([email protected])         // lactor n'est pas au volant                    00FE: actor [email protected] sphere 0 in_sphere [email protected] [email protected] [email protected] radius 15.0 15.0 15.0  // actor pas trop loin                then                    0ACD: show_text_highpriority "find" time 500                    0006: [email protected] = [email protected]                    06B6: set_searchlight [email protected] follow_actor [email protected] speed 9.0 <-----------------------   [email protected] doesn't exist                    break                end            end        end    endend

In addition, if code should jump up to a previous label, requires a wait

:delete_projecteurwait 0jump @delete_projecteur
Edited by ZAZ
Link to comment
Share on other sites

I'm not sure I understand how it works.

Everytime I want to make a not condition I have to change the first digit of the opcode from 0 to 8 ?

 

Or all the 0 into 8 ?

 

 

Anyway thanks for the tips man, i'm gonna improve my script.

Edited by Garwan50
Link to comment
Share on other sites

Thanks :)

 

Is it possible to debug the value of a variable ? (display it in game) I'd like to improve the manual movement of the searchlight, because right now according to the angle of your car, the command can be reversed, and weird to use for the user, i'd like to see the angle of the car in game, so from this angle move the searchlight accordingly ?

 

What opcode do you have to use to make sure that an actor handle is valid ?

because using some opcode on invalid actor handle make the game crashes (like actor [email protected] sphere 0 in_sphere [email protected] [email protected] [email protected] radius 7.0 7.0 7.0)

 

Also what's the normal time of a for loop that goes to 3000 ?

It took like 12 seconds to end it looks huge but can't tell why :blink:

Edited by Garwan50
Link to comment
Share on other sites

Is it possible to debug the value of a variable ? (display it in game)

yes, i often do that with 03F0: and 045A:

set 03F0: to 1 and let it with 045A: running in a loop

 

 

 

{$CLEO .cs}thread 'DRAWTXT'while truewait 003F0: enable_text_draw 1045A: draw_text_1number 20.0 250.0 GXT 'NUMBER' number [email protected] // ~1~end

 

 

 

Also what's the normal time of a for loop that goes to 3000 ?

It took like 12 seconds to end it looks huge but can't tell why :blink:

remove the wait inside the for loop and try it

it exist in main.scm loops without wait, that works for some cases

it's originally source code was writen by for loops

check the script below, it displays a running value, test it, then disable the wait and test it again

 

{$CLEO .cs}thread 'DRAWTXT'wait 2000while true    wait 0    [email protected] = 20.0    [email protected] = 10.0    for [email protected] = 0 to 700        wait 0  //  <--------------- disable wait by comment slashes: //wait 0        03F0: enable_text_draw 1        045A: draw_text_1number [email protected] [email protected] GXT 'NUMBER' number [email protected]        045A: draw_text_1number 320.0 430.0 GXT 'NUMBER' number [email protected]        [email protected] += 1        [email protected] += 30.0        if            [email protected] > 500.0        then            [email protected] = 0            [email protected] = 20.0            [email protected] += 10.0            wait 0// without that wait it crashes for me        end               endend
the loop runs without wait till the line end of 500.0 is reached, then restore values, change line height and a wait, without that wait it crashes for me

 

 

 

What opcode do you have to use to make sure that an actor handle is valid ?

 

because using some opcode on invalid actor handle make the game crashes (like actor [email protected] sphere 0 in_sphere [email protected] [email protected] [email protected] radius 7.0 7.0 7.0)

my favourite check is

 

8039: not [email protected] == -1

works for shure,

a snippet:

 

 

 

04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 10.0 0.008E5: get_actor_in_sphere [email protected] [email protected] [email protected] radius 80.5 handle_as [email protected] 10if    8039:   not  [email protected] == -1then    //your codeend

 

 

but these are also working

 

 

056D:   actor [email protected] defined8118:   not actor [email protected] dead
your method to count and check if value is handle of an actor, i got the template from Deji

 

{$CLEO .cs}:RandomActor_for_to_step_methodthread 'RAFSTEP'while truewait 0if0256:   player $PLAYER_CHAR defined thenfor [email protected] = 0 to 35584 step 256    0085: [email protected] = [email protected]    for [email protected] = 0 to 127        if and            056D:   actor [email protected] defined  // if we've got an actor            803C:   not $PLAYER_ACTOR == [email protected]  // make sure we've not got the player.        then            0321: kill_actor [email protected]            break        end        000A: [email protected] += 1    endendendend
The template kills all peds and actors, but if they should stay alive and they should do something needs a modification

Important is, to differentiate, if you need to find only one or more or find a specific ped

 

I wrote a script that indicates all possible peds around by showing smoke because smoke opcode 095C: doesn't need additinal ID variables

I recompiled Dejis template and wrote a low level script, that works fine

It checks for max. 24 peds around and get their coords to show red smoke there

 

 

 

{$CLEO .cs}:RandomActor_CounterCheck_SMOKE_LowLVthread 'RACTSMK':RACTSMK_11wait 0 if 0256:   player $PLAYER_CHAR defined jf @[email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1 [email protected] = -1gosub @RACTSMK_175 wait 0 gosub @RACTSMK_336jump @RACTSMK_11 :[email protected] = 0 [email protected] = 0 :RACTSMK_1890085: [email protected] = [email protected] // (int) [email protected] = 0 :RACTSMK_204if and056D:   actor [email protected] defined 803C:   not  $PLAYER_ACTOR == [email protected] // (int)  jf @RACTSMK_270 0085: [email protected]([email protected],32i) = [email protected] // (int)04C4: create_coordinate [email protected] [email protected] [email protected] from_actor [email protected] offset 0.0 0.0  1.2095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 1.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red 095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 3.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red 095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 5.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red [email protected] += 1 jump @RACTSMK_298 :[email protected] += 1 [email protected] += 1 [email protected] > 127 jf @RACTSMK_204 :[email protected] += 256 if [email protected] > 24 [email protected] > 35584 jf @RACTSMK_189 return :[email protected] = 0 :RACTSMK_343wait 0 if 25 > [email protected] jf @RACTSMK_397if    not [email protected]([email protected],32i) == -1 jf @RACTSMK_345  01C2: remove_references_to_actor [email protected]([email protected],32i) // Like turning an actor into a random pedestrian :[email protected] += 1 jump @RACTSMK_343 :RACTSMK_397return

 

 

Then i made same in HighLevel but the low script script works better

 

 

 

{$CLEO .cs}:RandActor_CounterCheck_SMOKE_HighLVthread 'RAFSTEP'while truewait 0    if        0256:   player $PLAYER_CHAR defined     then        gosub @restore        gosub @RACTSMK_getSUB        gosub @RACTSMK_freeSUB    endend:restorefor [email protected] = 0 to 24 step [email protected]([email protected],32i) = -1    //03F0: enable_text_draw 1    //045A: text_draw_1number  150.0  130.0 'NUMBER' 0    // [email protected] = 0return:RACTSMK_getSUBfor [email protected] = 0 to 35584 step 256    0085: [email protected] = [email protected] // (int)        for [email protected] = 0 to 127            if and                056D:   actor [email protected] defined  // if we've got an actor                803C:   not $PLAYER_ACTOR == [email protected]  // make sure we've not got the player.            then                0085: [email protected]([email protected],32i) = [email protected] // (int)                04C4: create_coordinate [email protected] [email protected] [email protected] from_actor [email protected] offset 0.0 0.0  1.2                095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 1.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red                 095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 3.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red                 095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 5.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red                 [email protected] += 1                break            end        000A: [email protected] += 1        end        if                [email protected] > 24        then            break        end                 //03F0: enable_text_draw 1    //045A: text_draw_1number  150.0  130.0 'NUMBER' [email protected]    // valueendreturn:[email protected] = 0 for [email protected] = 0 to 24 step 1//wait 0    if         not [email protected]([email protected],32i) == -1     then          01C2: remove_references_to_actor [email protected]([email protected],32i) // Like turning an actor into a random pedestrian     end    //03F0: enable_text_draw 1    //045A: text_draw_1number  50.0  50.0 'NUMBER' [email protected]    // value    [email protected]([email protected],32i) = [email protected] = 0 [email protected] = 0return

 

 

btw. these scripts are also working without wait inside for loop

 

 

but in your case, if you need just one specific ped, i would use 0AE1:

aiming as condition makes it easy

 

{$CLEO .cs}:RandomActor_Cleo4thread 'RANDACT'while truewait 0    if        0256:   player $PLAYER_CHAR defined     then        if   and            044B:   actor $PLAYER_ACTOR on_foot            00E1:   player 0 pressed_key 6//--- aim key        then                04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 2.0 0.0            if                0AE1:   [email protected] = random_actor_near_point [email protected] [email protected] [email protected] in_radius 12.0 find_next 0 pass_deads 1 // CLEO 4 opcode            then                if                    8118:   not actor [email protected] dead                 then                        if                        0457:   player $PLAYER_CHAR aiming_at_actor [email protected]                    then                        0321: AS_actor [email protected] die_headshotted                    end                end            end        end    endend
Edited by ZAZ
Link to comment
Share on other sites

Hey man, thanks again for your time :)

 

My for loop went 100 times faster by taking off the wait 0 so thanks it's awesome.

And then I replaced it by 0AE1 like you've recommended, so it's even better, i've just put it in a for loop of 10 in case some actors are invalid.

 

So the only way for an actor to be invalid is if the actor handler is below 0 ?

I personnaly like 056D: actor [email protected] defined

 

thanks for testing the loops, interesting that low script works better, i like high script a little better since it's easier to read tho, but it's not a bad idea to refactor the code one finished I guess !

 

So anyway i finished my cleo script, i'm glad i managed to finish it.

Obviously thanks to you Zaz you were such a huge help, I really appreciate you answered all my questions without loosing patience :lol: you're great

I'll stay around I still have a lot to learn but in 4 days i've learned a lot thanks! :r*:

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.