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. Forum Support

    3. Suggestions

How to store result of CVector and pass it into another function?


firedihm
 Share

Recommended Posts

My current scripts works as following:

05E2: call_function_return 0x4A1030 num_params 0 pop 0 [email protected] //FindPlayerCoors
05E1: call_function 0x40AA30 num_params 1 pop 1 [email protected] //CStreaming::StreamZoneModels

The first function returns player coordinates as CVector. The second one accepts it as it's only argument. The game crashes with code.

 

Link to comment
Share on other sites

I'm not familiar with these functions but, wouldn't you need more variables?

struct CVector 
{ 
    float x;
    float y;
    float z;
};

 

Link to comment
Share on other sites

13 hours ago, firedihm said:

My current scripts works as following:

05E2: call_function_return 0x4A1030 num_params 0 pop 0 [email protected] //FindPlayerCoors
05E1: call_function 0x40AA30 num_params 1 pop 1 [email protected] //CStreaming::StreamZoneModels

The first function returns player coordinates as CVector. The second one accepts it as it's only argument. The game crashes with code.

 

Usually in scm CVector is defined like this:

[email protected] [email protected] [email protected]    //  coordinates
[email protected]         //  CVector 

so:

{$CLEO}
0000:  

repeat
    wait 250
until 0256:   player $PLAYER_CHAR defined 

while true
    wait 0
    0054: store_player $PLAYER_CHAR position_to [email protected] [email protected] [email protected]
    05E1: call 0x40AA30 num_params 1 pop 1 [email protected] 
end

I didn't use the 1st function though.

EDIT: Also new versions of cleo should support opcode IDs such as:

00A0: store_actor $PLAYER_ACTOR position_to $sound_x $sound_y $sound_z //  0054 
0A8C: write_memory 0xC0BC15 size 4 value 1 virtual_protect 0    //  05DF
0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0         //    05E0  
0A96: [email protected] = actor $PLAYER_ACTOR struct //  05E6
0AA5: call $hPROC num_params 1 pop 1 $param //  05E1
0AA6: call_method $Destroy struct [email protected] num_params 0 pop 0 //  05E2
0AA7: call_function 0x569660 num_params 2 pop 2 $COORD_Y $COORD_X $GROUND   //  05E3
0AA8: call_function_method 0x4048E0 struct [email protected] num_params 1 pop 0 $MyCar [email protected]    //  05E4
.
.
.

 

Edited by Jack
Link to comment
Share on other sites

Thanks for the replies, everyone. I/ve instead decided to call CStreaming::Update and it did the trick

Link to comment
Share on other sites

7 hours ago, firedihm said:

@OrionSR I've tried that – it still crashes. The first function only returns CVector

I've got one working example of using CVector in a function. The key lesson I learned was to pop the arguments in the reverse order - something to do with how variables are arranged on the stack.

 

From DK22Pac's plugin reference for CWanted:

    static int WorkOutPolicePresence(CVector posn, float radius);

Function is expecting CVector and radius.

 

Relevant codes in my scripts:

  00A0: store_actor $PLAYER_ACTOR position_to x_float y_float z_float
  0AA7: WorkOutPolicePresence num_params 4 pop 4 civil z_float y_float x_float num_cops

So, popping radius, Z, Y, X and expecting an integer of cops within the radius.

 

Full script displays cops in range above the hud (GTASA PCv1):

Spoiler

 

{$CLEO .cs}
//CopRange.txt

const
  WorkOutPolicePresence = 0x5625F0
  civil = 14.0
  in_range = 18.0
  criminal = 30.0
  federal = 60.0
//  x_pos = 20.0
//  y_pos = 430.0
  x_pos = 505.0
  y_pos = 14.0
  
  x_float = [email protected]
  y_float = [email protected]
  z_float = [email protected]
  num_cops = [email protected]
end

03A4: name_thread 'CRANGE'
wait 6000
0ADF: add_dynamic_GXT_entry "Range00" text "~1~ Police > 60m"
0ADF: add_dynamic_GXT_entry "Range14" text "~1~ Police < 14m"
0ADF: add_dynamic_GXT_entry "Range18" text "~1~ Police < 18m"
0ADF: add_dynamic_GXT_entry "Range30" text "~1~ Police < 30m"
0ADF: add_dynamic_GXT_entry "Range60" text "~1~ Police < 60m"

while true
  wait 0

  00A0: store_actor $PLAYER_ACTOR position_to x_float y_float z_float
  0AA7: WorkOutPolicePresence num_params 4 pop 4 civil z_float y_float x_float num_cops
  03F0: enable_text_draw 1
  081C: draw_text_outline 1 RGBA 0 0 0 255
  0343: set_text_draw_linewidth 640.0
  033F: set_text_draw_letter_size 0.36 0.84
  if
    num_cops > 0
  then  
    045A: draw_text_1number x_pos y_pos GXT 'Range14' number num_cops
  else
    0AA7: WorkOutPolicePresence num_params 4 pop 4 in_range z_float y_float x_float num_cops
    if
      num_cops > 0
    then  
      045A: draw_text_1number x_pos y_pos GXT 'Range18' number num_cops
    else
      0AA7: WorkOutPolicePresence num_params 4 pop 4 criminal z_float y_float x_float num_cops
      if
        num_cops > 0
      then  
        045A: draw_text_1number x_pos y_pos GXT 'Range30' number num_cops
      else
        0AA7: WorkOutPolicePresence num_params 4 pop 4 federal z_float y_float x_float num_cops
        if
          num_cops > 0
        then  
          045A: draw_text_1number x_pos y_pos GXT 'Range60' number num_cops
//        else
//          045A: draw_text_1number x_pos y_pos GXT 'Range00' number num_cops
        end
      end
    end
  end
end

 

 

Edited by OrionSR
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.