Coding

 Reply to this postStart new topic

Detecting health/armor loss

iRage
post Aug 4 2013, 08:30 AM
Post #1


The New Guy!

Posts: 2
Joined: 4-August 13



I was wondering if there's a way to detect health/armor loss, since I'm new to CLEO scripting and couldn't find the corresponding Opcodes, thank you.
Go to the top of the page
 
+Quote Post
Deji
post Aug 4 2013, 09:18 AM
Post #2


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



These a couple of ways to do this:

1. Use 031D to check for a damage type. This could be ANY weapon ID as well as one of these damage types:
49 - WEAPONTYPE_RAMMEDBYCAR (car collided victim)
50 - WEAPONTYPE_RUNOVERBYCAR (car rolled over victim)
51 - WEAPONTYPE_EXPLOSION
52 - WEAPONTYPE_UZI_DRIVEBY (victim was hit by ANY driveby)
53 - WEAPONTYPE_DROWNING
54 - WEAPONTYPE_FALL
55 - WEAPONTYPE_UNIDENTIFIED
56 - WEAPONTYPE_ANYMELEE (using this will account for all melee attack)
57 - WEAPONTYPE_ANYWEAPON (using this will account for all weapons)
58 - WEAPONTYPE_FLARE (unlikely)

2. Store the characters health (0226) to a var each frame and check if it's changed by the next.


--------------------
Go to the top of the page
 
+Quote Post
iRage
post Aug 5 2013, 03:45 AM
Post #3


The New Guy!

Posts: 2
Joined: 4-August 13



Thank you mate!
I used the 2nd method and what I was trying to accomplish is successful.

I need more help though, I'm trying to make a toggling system but cannot manage to make it work.

For example, pressing F2 to enable the mod, then F2 again to disable it.
Go to the top of the page
 
+Quote Post
uokka
post Aug 5 2013, 09:27 AM
Post #4


Actually living entity

Posts: 143
From: Earth
Joined: 15-January 11



You can use loops.

This one Toggles vehicle engine.
Reactivates only when key is released after pressing the key once more - to prevent uncotrolled on/off toggling while key is pressed.
CODE
{$CLEO .cs}

03A4: name_thread 'CENGINE'

:Engine
WHILE TRUE
    wait 10
    if
    Player.Defined($PLAYER_CHAR)
    jf continue
    
    if and
    Actor.Driving($PLAYER_ACTOR)
    not actor.DrivingVehicleType($PLAYER_ACTOR #BMX)
    not actor.DrivingVehicleType($PLAYER_ACTOR #BIKE)
    not actor.DrivingVehicleType($PLAYER_ACTOR #MTBIKE)        
    jf continue
    
    if
    0AB0:  key_pressed 0x49 // 'I'
    then
        03C0: 0@ = actor $PLAYER_ACTOR car    
        0A97: 1@ = car 0@ struct
        0A8E: 2@ = 1@ + 1064  //->  Engine state

        IF
        0ABE:   vehicle 0@ engine_on
        THEN
            0A8C: write_memory 2@ size 1 value 0x0 virtual_protect 0

            0AD1: show_formatted_text_highpriority "- Engine OFF -" time 1500

            0001: wait 250
            while true
                wait 0
                if
                0AB0:  key_pressed 0x49 // 'I'
                jf break
            END                    
        ELSE
            while true
                if
                0AB0:  key_pressed 0x49 // 'I'
                jf break
                0AD1: show_formatted_text_highpriority "- Engine STARTING -" time 100
                
                0A8C: write_memory 2@ size 1 value 0x0 virtual_protect 0
                wait 20
                0A8C: write_memory 2@ size 1 value 0x10 virtual_protect 0
                wait 80
            end
            IF
            0ABE:   vehicle 0@ engine_on
            THEN            
                0AD1: show_formatted_text_highpriority "- Engine ON -" time 1500

                0A8E: 2@ = 1@ + 1300  //->  honking
                0A8C: write_memory 2@ size 4 value 1 virtual_protect 0                
                
                0001: wait 250
            END
        END
    end    
END


--------------------
My english is just perfekt. I am only not sure, whether I it rightly utilize..
. . .
Go to the top of the page
 
+Quote Post
ricardelily
post Sep 30 2013, 04:48 AM
Post #5


The New Guy!

Posts: 2
Joined: 29-September 13



Confused on where I would put these codes on. Please help.


--------------------
Go to the top of the page
 
+Quote Post
Deji
post Sep 30 2013, 11:00 AM
Post #6


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



QUOTE (ricardelily @ Sep 30 2013, 05:48 AM) *
Confused on where I would put these codes on. Please help.

The same place you were putting your other code.


--------------------
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

3 User(s) are reading this topic (3 Guests and 0 Anonymous Users)
0 Members: