CLEO Help [HELP] Toggle button for a script?

CLEO related
Status
Not open for further replies.

Superhans

New member
Joined
Jun 15, 2013
Messages
3
Reaction score
0
Good morning! (Well... evening or afternoon or night depending on where you live!)

I have recently started looking into SCM and CLEO after I couldn't make a script work the way I wanted to. Basically, I have no experience in this area at all (yet! ;) ;);) )
I also tried to copy what Opcode did in this thread: <!-- l topic1224.html<!-- l but it didn't work very well on mine.

Anyhow, let us get to the point. I can't seem to be able to make the toggle button work in SA-MP. You'll find the code below. There is one "00E1: player $PLAYER_CHAR pressed_key 116 " but in SA-MP, it only hides the map and the entire HUD instead of the actual text that the CLEO mod is making. Also, it is not a toggle. You need to hold the button down all the time if you want it to be hidden. If anyone could help me create a toggle button, I would be extremely happy!

Edit: The script is made by Wesser and is called Zonetext. I am simply making a minor edit and I hope he doesn't mind.

Code:
{$CLEO}

{
    Mod Name:   TownZone texts
    Author:     Wesser
    Credits:    Nope
}

const
   PX                = 1@ 
   PY                = 2@ 
   PZ                = 3@ 
   CURRENT_TOWN      = 7@ 
   WIDESCREEN_STATUS = 8@ 
   IS_IN_WIDESCREEN  = 9@ 
   ENTER_STATUS      = 10@ 
   IS_OPENING_DOOR   = 11@ 
   IS_IN_CUTSCENE    = 12@ 
   RADAR_MODE        = 13@ 
   RADAR_ENABLED     = 14@ 
   IS_RADAR_ONSCREEN = 15@ 
   INTO_INTERIOR     = 16@ 
   IS_IN_INTERIOR    = 17@ 
///--------------------------
   ZONE_TEXT         = s$93 
   TOWN_TEXT         = s$95 
   INTERIOR_TEXT     = v$99 
end

IS_IN_WIDESCREEN = FALSE 
IS_OPENING_DOOR = FALSE 
IS_IN_CUTSCENE = FALSE 
IS_RADAR_ONSCREEN = TRUE 
IS_IN_INTERIOR = FALSE 

0000: Starting code...

while true
    wait 0 
    gosub @WideScreenCheck 
    gosub @OpenDoorCheck 
    gosub @CutsceneCheck 
    gosub @GetRadarOnScreen 
    
    if  or
        IS_IN_WIDESCREEN == TRUE 
        IS_OPENING_DOOR == TRUE 
        IS_IN_CUTSCENE == TRUE 
        IS_RADAR_ONSCREEN == FALSE 
    then
        03F0: enable_text_draw 0 
    else
        if  and
            80DF:   not actor $PLAYER_ACTOR driving
            00E1:   player $PLAYER_CHAR pressed_key 116 
        then
            03F0: enable_text_draw 0 
        else
            03F0: enable_text_draw 1 
            gosub @ZoneTextDisplay 
            
        end
    end
end

:WideScreenCheck
0A8D: WIDESCREEN_STATUS = read_memory 0xB6F065 size 4 virtual_protect 0 
if 
    WIDESCREEN_STATUS == 1 
then
    IS_IN_WIDESCREEN = TRUE 
else
    IS_IN_WIDESCREEN = FALSE 
end
return 

:OpenDoorCheck
0A8D: ENTER_STATUS = read_memory 0x96A7CC size 4 virtual_protect 0 // I found this :)
if  or
    ENTER_STATUS == 1 
    ENTER_STATUS == 2 
then
    IS_OPENING_DOOR = TRUE 
else
    IS_OPENING_DOOR = FALSE 
end
return 

:CutsceneCheck
if 
    06B9:   cutscene_data_loaded 
then
    if 
        82E9:   not cutscene_reached_end
    then
        IS_IN_CUTSCENE = TRUE 
    end
else
    IS_IN_CUTSCENE = FALSE 
end
return 

:GetRadarOnScreen
0A8D: RADAR_MODE = read_memory 0xBA676C size 4 virtual_protect 0 
0A8D: RADAR_ENABLED = read_memory 0xBAA3FB size 4 virtual_protect 0 
if  and
    RADAR_MODE == 2 
    RADAR_ENABLED == 0 
then
    IS_RADAR_ONSCREEN = FALSE 
else
    IS_RADAR_ONSCREEN = TRUE 
end
return 

:ZoneTextDisplay
gosub @InteriorCheck 

if 
    IS_IN_INTERIOR == FALSE
then
    gosub @GetZoneText 
    gosub @TownTextDisplay 
    
    if  or
        05AD:   ZONE_TEXT == 'LA'  // Los Santos
        05AD:   ZONE_TEXT == 'SF'  // San Fierro
        05AD:   ZONE_TEXT == 'VE'  // Las Venturas
    then
        05A9: ZONE_TEXT = 'CT'  // Country
    end
    if 
        05AD:   ZONE_TEXT == 'SAN_AND'  // San Andreas
    then
        05A9: ZONE_TEXT = 'CN'  // Ocean
    end
    gosub @DrawZoneText 
    
else
    gosub @InteriorTextDisplay 
    
end
return 

:InteriorCheck
077E: get_active_interior_to INTO_INTERIOR 
if 
    INTO_INTERIOR == 0 
then
    IS_IN_INTERIOR = FALSE
else
    IS_IN_INTERIOR = TRUE
end
return 

:GetZoneText
00A0: store_actor $PLAYER_ACTOR position_to PX PY PZ 
0843: get_zone_at PX PY PZ nameA_to ZONE_TEXT // 8-byte string 
return 

:TownTextDisplay
gosub @GetCurrentTown 

if 
    CURRENT_TOWN == 0 
then
    05A9: TOWN_TEXT = 'CS'  // Country Side
end
if 
    CURRENT_TOWN == 1 
then
    05A9: TOWN_TEXT = 'LA'  // Los Santos
end
if 
    CURRENT_TOWN == 2 
then
    05A9: TOWN_TEXT = 'SF'  // San Fierro
end
if 
    CURRENT_TOWN == 3 
then
    05A9: TOWN_TEXT = 'VE'  // Las Venturas
end
if 
    05AD:   ZONE_TEXT == 'SAN_AND'  // San Andreas
then
    05A9: TOWN_TEXT = 'SAN_AND'  // San Andreas
end
if 
    05AD:   ZONE_TEXT == 'LA'  // Los Santos
then
    05A9: TOWN_TEXT = 'LA'  // Los Santos
end
if 
    05AD:   ZONE_TEXT == 'SF'  // San Fierro
then
    05A9: TOWN_TEXT = 'SF'  // San Fierro
end
if 
    05AD:   ZONE_TEXT == 'VE'  // Las Venturas
then
    05A9: TOWN_TEXT = 'VE'  // Las Venturas
end
gosub @DrawTownText 

return 

:DrawZoneText
03E0: unknown_text_draw_flag 1 
033F: set_text_draw_letter_size 0.3 1.2 
0342: enable_text_draw_centered 1 
081C: draw_text_outline 2 RGBA 0 0 0 255 
033E: set_draw_text_position 88.0 426.0 GXT ZONE_TEXT 
return 

:GetCurrentTown
0842: CURRENT_TOWN = player $PLAYER_CHAR town_number
return 

:DrawTownText
03E0: unknown_text_draw_flag 1 
033F: set_text_draw_letter_size 0.3 1.2 
0342: enable_text_draw_centered 1 
081C: draw_text_outline 2 RGBA 0 0 0 255 
033E: set_draw_text_position 88.0 326.0 GXT TOWN_TEXT 
return 

:InteriorTextDisplay
gosub @GetInteriorText 
gosub @DrawInteriorText // DrawZoneText as DrawInteriorText
gosub @DrawTownText 

return 

:GetInteriorText
094B: INTERIOR_TEXT = get_active_interior_name_from_actor $PLAYER_ACTOR // 16-byte string
return 

:DrawInteriorText
03E0: unknown_text_draw_flag 1 
033F: set_text_draw_letter_size 0.3 1.2 
0342: enable_text_draw_centered 1 
081C: draw_text_outline 2 RGBA 0 0 0 255 
033E: set_draw_text_position 88.0 426.0 GXT INTERIOR_TEXT 
return
 

Superhans

New member
Joined
Jun 15, 2013
Messages
3
Reaction score
0
Wait, so do you want ON/OFF? or what?

Yeah, exactly! So that by a switch of a button, I can turn the mod on and off. It's pretty handy for servers that don't allow CLEO mods and you need to record something.
 

Superhans

New member
Joined
Jun 15, 2013
Messages
3
Reaction score
0
Any update on this? I've tried myself in numerous different ways but it simply does not work. I tried <!-- l topic1224.html<!-- l too.

I want it so that if I press F8 it hides/removes the text and if I want the text back I press F9.
 

xzytro

God
Joined
Apr 1, 2013
Messages
2,294
Reaction score
7
If you press f8, you will take screenshot, and if you press f9, you will hide your kill list.
But anyway, tried it and it's hard because you don't easily see where the codes end, there's always "return" to a "gosub" line.
 
Status
Not open for further replies.
Top