Quantcast

Jump to content

» «
Photo

create_searchlight on car

Best Answer ZAZ, 3 weeks ago

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 true
wait 0
03F0: enable_text_draw 1
045A: 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 2000

while 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           
    end
end
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:
Spoiler


but these are also working
 
056D:   actor [email protected] defined

8118:   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_method
thread 'RAFSTEP'

while true
wait 0
if
0256:   player $PLAYER_CHAR defined 
then
for [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
    end
end
end
end
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
Spoiler


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


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_Cleo4
thread 'RANDACT'

while true
wait 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
    end
end
Go to the full post


15 replies to this topic
Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#1

Posted 4 weeks ago

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: NOP

while 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
    end
end

Thanks !


Sanmodder
  • Sanmodder

    Fan script

  • Members
  • Joined: 11 Sep 2017
  • Poland

#2

Posted 4 weeks ago

TRY YES

0407: store_coords_to $A1 $A2 $A3 from_car [email protected] with_offset 0.0 1.5 0.6 
06B1: [email protected] = create_searchlight_at $A1 $A2 $A3 radius 5.0 target $A4 $A5 $A6 radius 25.0 
06B6: set_searchlight [email protected] follow_actor $PLAYER_ACTOR speed 0.2 

Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#3

Posted 4 weeks ago Edited by Garwan50, 4 weeks ago.

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 !

ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#4

Posted 3 weeks ago

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: [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
    end
end

Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#5

Posted 3 weeks ago Edited by Garwan50, 3 weeks ago.

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
    end
end

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 !


Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#6

Posted 3 weeks ago

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
    end
end

ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#7

Posted 3 weeks ago

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.0
06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0

[email protected] -= 1.0
06B5: set_searchlight [email protected] travel_to [email protected] [email protected] [email protected] speed 3.0

 

I did it in that way

:PmCspx_SLTable2
0871: 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_SLT01
0002: jump @PmCspx_SLTout1

:PmCspx_SLT11
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 0.0 4.0 [email protected]
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 2.0 3.0 [email protected]
06B4: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.5
0002: jump @PmCspx_SLTout1

:PmCspx_SLT22
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 3.0 2.0 [email protected]
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 3.0 0.0 [email protected]
06B4: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.5
0002: jump @PmCspx_SLTout1

:PmCspx_SLT33
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 3.0 -2.0 [email protected]
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 2.0 -3.0 [email protected]
06B4: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.5
0002: jump @PmCspx_SLTout1

:PmCspx_SLT44
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset 0.0 -3.0 [email protected]
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -2.0 -4.0 [email protected]
06B4: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.5
0002: jump @PmCspx_SLTout1

:PmCspx_SLT55
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -3.0 -2.0 [email protected]
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -3.0 0.0 [email protected]
06B4: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.5
0002: jump @PmCspx_SLTout1

:PmCspx_SLT66
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -2.0 2.0 [email protected]
0407: create_coordinate [email protected] [email protected] [email protected] from_car [email protected] offset -2.0 4.0 [email protected]
06B4: set_searchlight [email protected] path_between [email protected] [email protected] [email protected] and [email protected] [email protected] [email protected] speed 15.5
0002: jump @PmCspx_SLTout1

:PmCspx_SLTout1
0002: jump @PmCspx_4
0051: return

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


Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#8

Posted 3 weeks ago

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.discorda...2/sa-mp-133.png

https://cdn.discorda...6/sa-mp-134.png


ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#9

Posted 3 weeks ago

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

Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#10

Posted 3 weeks ago

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
    end
end

Do you have any tips for me to debug it ?

Or any idea what i've done wrong ?

 

Thanks for your time 


ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#11

Posted 3 weeks ago Edited by ZAZ, 3 weeks ago.

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
    end
end

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

:delete_projecteur
wait 0
jump @delete_projecteur

Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#12

Posted 3 weeks ago Edited by Garwan50, 3 weeks ago.

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.


ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#13

Posted 3 weeks ago Edited by ZAZ, 3 weeks ago.

yes, the first digit of the opcode from 0 to 8

Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#14

Posted 3 weeks ago Edited by Garwan50, 3 weeks ago.

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:


ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#15

Posted 3 weeks ago   Best Answer Edited by ZAZ, 3 weeks ago.

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 true
wait 0
03F0: enable_text_draw 1
045A: 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 2000

while 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           
    end
end
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:
Spoiler


but these are also working
 
056D:   actor [email protected] defined

8118:   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_method
thread 'RAFSTEP'

while true
wait 0
if
0256:   player $PLAYER_CHAR defined 
then
for [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
    end
end
end
end
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
Spoiler


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


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_Cleo4
thread 'RANDACT'

while true
wait 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
    end
end
  • Garwan50 likes this

Garwan50
  • Garwan50

    Player Hater

  • Members
  • Joined: 29 Apr 2011
  • France

#16

Posted 3 weeks ago

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*:

  • ZAZ likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users