Jump to content

Error when calling function in cleo script mobile


Gdzin

Recommended Posts

why when I run my script the game closes? Is there any error in my script?

_______________________________________________________________________

 

{$CLEO .csi}

 

//CPlayerPed::SetImmunities(CPlayerPed *this, int, int, int, int, int)

 

0DD0: $Func = get_label_addr @Func
0DD1: $Func= get_func_addr_by_cstr_name $Func

 

0DD3: context_set_reg 0 value $PLAYER_ACTOR
0DD3: context_set_reg 1 value 1
0DD3: context_set_reg 2 value 1
0DD3: context_set_reg 3 value 1
0DD3: context_set_reg 4 value 1
0DD3: context_set_reg 5 value 1
0DD2: context_call_func $Func
end_thread

 

:Func
hex
    "_ZN10CPlayerPed13SetImmunitiesEiiiii_ptr"
end

 

_______________________________________________________________________

Link to comment
Share on other sites

I cannot find your label in my mobile database.

The label name suggests this is a pointer. You'll want to read and use the address in the pointer for the function.

Why not just use opcode 02AB: set_char_proofs?

 

Using custom variable names in cleo scripts is liable to cause corruption. Stick with local variables.

Edited by OrionSR
Link to comment
Share on other sites

2 hours ago, OrionSR said:

I cannot find your label in m

2 hours ago, OrionSR said:

I cannot find your label in my mobile database.

The label name suggests this is a pointer. You'll want to read and use the address in the pointer for the function.

Why not just use opcode 02AB: set_char_proofs?

 

Using custom variable names in cleo scripts is liable to cause corruption. Stick with local variables.

I don't use this opcode because I'm just wanting to learn how to call functions, but other than that, is my code okay?

 

Link to comment
Share on other sites

you are not finding the label because it belongs to libSAMP.so, not libGTASA.so

Link to comment
Share on other sites

Gotcha. Then something like this should do the trick.

0DD0: $Func = get_label_addr @Func
0DD1: $Func= get_func_addr_by_cstr_name $Func
0DD8: $Func = read_mem_addr $Func size 4 add_ib 0
0DD3: context_set_reg 0 value $PLAYER_ACTOR
{...}

Try add_ib 1 if it gives you trouble. I forget which is which.

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
  • 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.