Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Contract
      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

CLEO - Detect when ped fires a weapon / Attacks with melee


CalvinC
 Share

Recommended Posts

Is there a way to detect when a ped fires a gun or punches somebody?
I'm trying to make police attack peds who are shooting or fighting eachother, i know how to make the police chase them and stuff.

Only problem is detecting if he's firing/punching.
Right now i've set the police to chase peds with a gun, but gang members usually walk around with their guns out, so it just creates riots all the time.

Link to comment
Share on other sites

opcode 0470: returns the weapon number of the actor, numbers smaller than 16 indicates melee and gift weapons
opcode 02E0: checks if actor use fire or throw weapon

if    02E0:   actor [email protected] firing_weaponthen    //actor use fire or throw weaponend



to check if actor attacks by using melee weapon needs to check if the other actor gets damage from first actor
opcode 051A: check if an actor is damaged by another actor
Note:
this code returns always true if an actor was damged
to check if the actor was damaged again needs to restore first the actors damage state by opcode 054E:

0470: [email protected] = actor [email protected] current_weaponif    051A:   actor [email protected] damaged_by_actor [email protected]    if        16 > [email protected]    then        //result = actor [email protected] used melee or gift weapon to damgage actor [email protected]    end    //then it needs to restore the actors damage state    054E: clear_actor [email protected] damageend
Link to comment
Share on other sites

I'm very new at scripting, but with the help of looking at some other scripts I've tried creating this:

{$CLEO}0000: STARTvar    [email protected] : intend:GetActor    0A8D: [email protected] = read_memory 0xB74490 size 4 virtual_protect 0    [email protected] += 0x4    0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0    for [email protected] = 0 to 27904 step 0x100        0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0        000A: [email protected] += 0x1        if and            0029: [email protected] >= 0x00             001B: 0x80 > [email protected]        then        005A: [email protected] += [email protected]        if 8118: not actor [email protected] dead           jf continue        gosub @Main        end         end:Main    if        02E0: actor [email protected] firing_weapon    then        09B6: set_char_wanted_by_police [email protected] to 1     end    return

Doesn't seem to work though.
Link to comment
Share on other sites

I fixed the script and replaced the codes of the "Main" block

{$CLEO}thread 'RANDACT'wait 2000var    [email protected] : intendwhile truewait 0    0A8D: [email protected] = read_memory 0xB74490 size 4 virtual_protect 0    [email protected] += 0x4    0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0    for [email protected] = 0 to 27904 step 0x100        wait 0        0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0        000A: [email protected] += 0x1        if and            0029: [email protected] >= 0x00             001B: 0x80 > [email protected]        then        005A: [email protected] += [email protected]        if  and            056D:   actor [email protected] defined             803C:   not  $PLAYER_ACTOR == [email protected] // (int)              8118: not actor [email protected] dead           jf continue        gosub @Main        end         endend:Main04C4: 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 return

The smoke codes let appear red smoke at each ped that the script can find.

Test it to see that it works.

 

Then change the "Main" block, remove the smoke codes with this code 09B6: set_char_wanted_by_police [email protected] to 1

:Main        09B6: set_char_wanted_by_police [email protected] to 1 return

or just add this code, so that each founded ped will be wanted by police

Link to comment
Share on other sites

  • 2 months later...

Hey, sorry for the late reply i haven't been able to play GTA SA before now.

The script seems to work if you make everyone wanted, but if i try to check if they're shooting it doesn't work, judging by the smoke the script is too slow at checking if the ped is firing a shot, unless you're extremely lucky.

This is what i got so far:

{$CLEO}thread 'RANDACT'wait 0var    [email protected] : intendwhile truewait 0    0A8D: [email protected] = read_memory 0xB74490 size 4 virtual_protect 0    [email protected] += 0x4    0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0    for [email protected] = 0 to 27904 step 0x100        wait 0        0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0        000A: [email protected] += 0x1        if and            0029: [email protected] >= 0x00             001B: 0x80 > [email protected]        then        005A: [email protected] += [email protected]        if  and            056D:   actor [email protected] defined             803C:   not  $PLAYER_ACTOR == [email protected] // (int)              8118: not actor [email protected] dead           jf continue        gosub @Main        end         endend:Main    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 1.0  1.0  1.0 size 0.5 last_factor 0.1 // white    if        02E0: actor [email protected] firing_weapon    then            09B6: set_char_wanted_by_police [email protected] to 1                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    end return

Any way to make it quick enough?

Link to comment
Share on other sites

I noticed that 09B6: have not much effect
As i said, change the main block to this

:Main        09B6: set_char_wanted_by_police [email protected] to 1 return

without check for firing_weapon, so every ped that was found should wanted by police

but police do nothing

Link to comment
Share on other sites

  • 3 years later...
The Eagle Eye

Hello everyone, i am new here and new gta mod maker. First of all i want to know how to make mod run on start-up/with the game.

Second, how to spawn vehicle near PED or PLAYER ? But vehicle should has driver, for example, if car destroyed...then spawn F.truck near car to extinguish fire.

Link to comment
Share on other sites

Igor Bogdanoff

Create new topic for that in this subsection, instead of bumping old one

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.