Resource icon

CLEO Release [CLEO PLUGIN] Dynamic Vars

CLEO related
Status
Not open for further replies.

0x_

Wtf I'm not new....
Administrator
Joined
Feb 18, 2013
Messages
1,118
Reaction score
166
Dynamic Variables
For CLEO 4.1

What is this?:
Dynamic Vars is meant to be a easy expansion for saving data but with an incredible easy interface (variable names).
It allows you todo many powerful things, as it uses variable "names" you can create any kind of combinations for setting & getting data.
Also, it has no limitations on how many variables you can have (only your available ram is your limit :p).

Now, is there any example?:
Yes, here's a example that contains some string and a "friend system" with sampfuncs and dynamic vars made by opcode.
Code:
{$CLEO .cs}
0000:

REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY
0B34: ".ADDFRIEND" @ADDFRIEND
0B34: ".DELFRIEND" @DELFRIEND
0FA5: set_var_as_string name "Credits" value "0x688, Opcode.eXe"



WHILE TRUE
    WAIT 0
    IF
    0AB0: 49 // 1?
    THEN
        0AC8: 0@ = allocate_memory_size 256
        0FA6: 0@ = get_var_as_string name "Credits" //GET
        0AD1: show_formatted_text_highpriority "Credits: %s" time 500 0@
        0AC9: free_allocated_memory 0@
    END
    
    IF
    0AB0: 50 // 2?
    THEN
        0FA9: 1@ = dump_vars to_file "CLEO\\DynVars\\Example.txt"
        0AD1: show_formatted_text_highpriority "Dumped %d vars!" time 500 1@
    END

    IF
    0AB0: 51 // 3?
    THEN
        0FAA: 1@ = load_vars from_file "CLEO\\DynVars\\Example.txt"
        0AD1: show_formatted_text_highpriority "Loaded %d vars!" time 500 1@
    END
    
    // FriendESP example:
    FOR 0@ = 0 TO 1000
        IF
        0B23:  samp is_player_connected 0@
        THEN
            IF
            0B20: samp 1@ = actor_handle_by_samp_player_id 0@
            THEN
                0B36: samp 2@ = get_player_nickname 0@    
                0FA4: 3@ = get_var_as_bool 2@//SET
                IF
                3@ == 1
                THEN
                    04C4: store_coords_to 4@ 5@ 6@ from_actor 1@ with_offset 0.0 0.0 0.0
                    0B55: convert_3D_coords 4@ 5@ 6@ to_screen 7@ 8@
                    0B69: render draw_box_pos 7@ 8@ size 50 50 color 0xFFFF0000                                
                END                     
            END
        END
    END
END

                              



:DELFRIEND
0B35: samp 31@ = get_last_command_params
IF
0AD4: $NO_USE = scan_string 31@ "%d" 30@
THEN
    IF
    0B23:  samp is_player_connected 30@
    THEN
        0B36: samp 29@ = get_player_nickname 30@
        0FA3: set_var_as_bool 29@ value 0 //SET                
        0AF8: samp add_message_to_chat "{FF0000}[DELFRIEND]{FFFFFF}Player {FF9500}%s{FFFFFF} is no longer your friend!" color 0xFFFFFF 29@
    END
    ELSE
    0AF8: samp add_message_to_chat "Please enter a ID!" color 0xFFFFFF
END
0B43: CMD_RETURN

:ADDFRIEND
0B35: samp 31@ = get_last_command_params
IF
0AD4: $NO_USE = scan_string 31@ "%d" 30@
THEN
    IF
    0B23:  samp is_player_connected 30@
    THEN
        0B36: samp 29@ = get_player_nickname 30@
        0FA3: set_var_as_bool 29@ value 1 //SET                
        0AF8: samp add_message_to_chat "{FF0000}[ADDFRIEND]{FFFFFF}Player {FF9500}%s{FFFFFF} is now your friend!" color 0xFFFFFF 29@
    END
    ELSE
    0AF8: samp add_message_to_chat "Please enter a ID!" color 0xFFFFFF
END
0B43: CMD_RETURN

Specifications (limits or anything worth to note):
- The current max length for string is fixed at 256 as i saw no need for more, if i'll expand it so it supports and unlimited range of charcters.
- Please, and oh please! Dont use integer's for things you dont need to like only 0/1 values use the bool one to save memory, it get's dynamically allocated.
- Every loaded CLEO Script has it's own pool of variables, I'm planning to allow access to other cleo's pools but as it stands for now it's not necessarry.

Downloads:
As always, you can find them in the attachments.

Try it yourself, cleo scripter's that know what they do also know what todo with this.
 

Attachments

  • Release_Package.zip
    19.2 KB · Views: 251
  • Like
Reactions: Zin

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
This is so awesome  :urtheman:
Now we dont need 0@ - 32@ Variables anymore  :dont_care:

Here's are the new opcodes that you can enter into opcodes.txt:
Code:
0FA0: DELETE_VAR "VARIABLE"
0FA1: VAR "Variable1" SET_INT_VALUE 1337 
0FA2: 0@ = INT_FROM_VAR "Variable1"
0FA3: VAR "Variable2" BOOL_value TRUE
0FA4: 0@ = BOOL_FROM_VAR "Variable2"
0FA5: VAR "Credits" SET_STRING "Made by; 0x688, UGBASE.eu"
0FA6: 0@ = STRING_FROM_VAR "Credits"
0FA7: VAR "Variable3" SET_FLOAT 1337.0
0FA8: 0@ = FLOAT_FROM_VAR "Variable3"
0FA0: DELETE_VAR "VARIABLE"
"VARIABLE" is now -1

0FA1: VAR "Variable1" SET_INT_VALUE 1337
0FA2: 0@ = INT_FROM_VAR "Variable1"
0@ is now 1337

0FA3: VAR "Variable2" value TRUE
0FA4: 0@ = BOOL_FROM_VAR "Variable2"
0@ is now TRUE

0FA5: VAR "Credits" SET_STRING "Made by; 0x688, UGBASE.eu"
0FA6: 0@ = STRING_FROM_VAR "Credits"
0@ is now "Made by; 0x688, UGBASE.eu"


0FA7: VAR "Variable3" SET_FLOAT 1337.0
0FA8: 0@ = FLOAT_FROM_VAR "Variable3"
0@ is now 1337.0
And here's my sascm format:
Code:
0FA0: DELETE_VAR %1s%
0FA1: VAR %1s% SET_INT_VALUE %2d%
0FA2: %2d% = INT_FROM_VAR %1s% 
0FA3: VAR %1s% BOOL_VALUE %2d%
0FA4: %2d% = BOOL_FROM_VAR %1s% 
0FA5: VAR %1s% SET_STRING %2s%
0FA6: %2d% = STRING_FROM_VAR %1s% 
0FA7: VAR %1s% SET_FLOAT %2d%
0FA8: %2d% = FLOAT_FROM_VAR %1s%
 

Vrana

Active member
Joined
Jun 24, 2014
Messages
128
Reaction score
0
Location
Serbia
I dont rly get this, is there any picture of this?
 

hake

New member
Joined
May 4, 2014
Messages
2
Reaction score
0
can someone explain what the fuck this is?

we don't all sit inside decompiling CLEO's all day like some of you
 

inZ

Well-known member
Joined
Apr 6, 2013
Messages
270
Reaction score
1
hake link said:
can someone explain what the fuck this is?

we don't all sit inside decompiling CLEO's all day like some of you
Skunkbag are you blind?
It's a cleo plugin used to load variables and saving data
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
If you're not a CLEO scripter then u should leave this thread.
This plugin gives you variables. Just like 0@, 1@ ... up to 32@.

The variables dont look like 0@, they look like: "SAVE", "IMAVARIABLE", "VARIABLE1", "VARIABLE2", "VAR3" - u can name them like you want.

Lets say i want to make a mod that shows all admin names:
I use the variable "Admins" to save it.

0FA5: VAR "Admins" SET_STRING "0x688, Opcode.eXe, TH3RMAL, SPRINGFIELD"

Now "Admin" contains "0x688, Opcode.eXe, TH3RMAL, SPRINGFIELD".

0FA6: 0@ = STRING_FROM_VAR "Admin"

0@ is now "0x688, Opcode.eXe, TH3RMAL, SPRINGFIELD"

Its really only for advanced scripters..
 

0x_

Wtf I'm not new....
Administrator
Joined
Feb 18, 2013
Messages
1,118
Reaction score
166
Update!
I've added a way to save & load them with 1 line, it's never been easier to save settings regarding your cleo!

New Opcodes:
Code:
0FA9=2,%2d% = dump_vars to_file %1s% //GET
0FAA=2,%2d% = load_vars from_file %1s% //GET
0FAB=2,var_set_temp %1s% %2d% //SET

The first ones (save,load) are self explanatory, they return the amount of vars saved / loaded the path is relativ to the gta:sa directory that means if you save type in the path "CLEO\\Vars.txt" it saves it in the CLEO directory.

If you don't want a var to be saved, set it with the Opcode 0FAB if you set this to 1 it won't save it set it back to 0 if you want it to get saved.

~ Good day ;d
 

inZ

Well-known member
Joined
Apr 6, 2013
Messages
270
Reaction score
1
Pic or it didn't happen hahaha x)
GJ
 

neoplay13

Member
Joined
Aug 28, 2018
Messages
5
Reaction score
0
RE: [CLEO PLUGIN] Dynamic Vars

What do that? i just come because in ophax i cant add friends, to friendsmode :sadpepe:
 
Status
Not open for further replies.
Top