Jump to content

Sanny builder


D J C
 Share

Recommended Posts

Hello and do not be tired.

 

1. If anyone would like to teach me this script of the cleo about textdraws, please introduce me to the basics. Or tell me if you see a suitable place to learn this code.

 

2. I want to create a binder that receives something from the .ini file via a command and sends it to the ingame + In addition, instead of changing the text in the .ini file every time(menual), we do not have to manually change it, EX: /changetext Hello -> chatmsg "{FFFFFF}Hello text has been saved in .ini file" -1

 

{$CLEO}

0662: "made by djc"
thread "0.1"
wait 2500

0B34: samp register_client_command "text" to_label @cmd_0
0B34: samp register_client_command "changetext" to_label @SetSentence

:cmd_39
wait 0   
jump @cmd_39

:cmd_0
0AC8: 19@ = allocate_memory_size 260
0AF4: 19@ = read_string_from_ini_file "CLEO\Shortcuts.ini" section "Shortcuts" key "chat"
0AF9: samp say_msg 19@
free 19@
cmdret
  
:SetSentence
SAMP.IsCommandTyped(2@)
0AD4: 4@ = scan_string 2@ format "%x" 1@
0AF1: write_int 1@ to_ini_file "CLEO\Shortcuts.ini" section "Shortcuts" key "chat"      
chatmsg "{FFFFFF}Sentence has been saved.: {FF0000}%x" 1000 1@
cmdret

 

Edited by DjC
Link to comment
Share on other sites

Hello,
1. 
https://blast.hk/wiki/opcodes:sampfuncs:list, ctrl + F > textdraw and you will get every useful opcode including examples.
2. Here is an example to edit text from game through /settext :

0B34: "settext" to_label @settext

:settext
if SAMP.IsCommandTyped(20@)
then
	0AF5: write_string 20@ to_ini_file "cleo\FileName.ini" section "SectionName" key "stringKey"
	chatmsg "Text "%s" has been saved to FileName.”" 20@ -1  
else
	chatmsg "SYNTAX : /settext ”new text”" -1
end
SAMP.CmdRet()
Link to comment
Share on other sites

chatmsg "Text "%s" has been saved to FileName.”" 20@ -1 //Doesn't work
chatmsg "Text has been saved to FileName.”" 20@ -1 //Work

It makes the game crash. because of the (%s), I guess have you forget something there.

 

 I just could write that text draw is works via command I also wrote something that after 2 seconds this text will be deleted from the middle of the page. But it does not work , as can you see the code below,

{$CLEO}

0662: "made by djc"
thread "0.1"
wait 2500

0B34: samp register_client_command "ok" to_label @sag

:cmd_39
wait 0   
jump @cmd_39

:sag         
0C48: samp textdraw 550 create "Hello!" pos 240.0 200.0
0C52: samp textdraw 550 set_letter_size 1.00 4.00 color -14110752
0C4C: samp textdraw 550 set_style 1                     
0C4D: samp textdraw 550 set_shadow 1 color -16448251
wait 2000
0C5E: samp textdraw 550 delete
cmdret

And that there is another way to find a screen pos ?! plus Text letter sizes. If possible, I want to know the solutions to this

 

Need basic text-draw code so When we run the game, that text will also appear on the game screen automatically with (Hello) text if it's possible,

Edited by DjC
Link to comment
Share on other sites

On 9/1/2020 at 4:36 PM, DjC said:

chatmsg "Text "%s" has been saved to FileName.”" 20@ -1 //Doesn't work
chatmsg "Text has been saved to FileName.”" 20@ -1 //Work

It makes the game crash. because of the (%s), I guess have you forget something there.

 

characters in a 20@ string are very limited so if the chat message is longer than the limit will cause a crash.
I have tried to allocate the memory and use a variable 20@v which is longer than the other.
It will still crash if the string outnumbers the limit, but this may makes it work: 

:settext
if SAMP.IsCommandTyped(20@v)
then
	0AC8: 0@ = allocate_memory_size 260
  	0AF5: write_string 20@v to_ini_file "cleo\FileName.ini" section "SectionName" key "stringKey"
	chatmsg "Text: %s" 20@v -1 
  	0AC9: free_allocated_memory 0@
else
	chatmsg "SYNTAX : /settext ”new text”" -1
end
SAMP.CmdRet()  

 

Edited by CouldnoT
Link to comment
Share on other sites

Hello,

 

Function 'wait' can only be used in a loop that repeats itself indefinitely, can't be used in commands. For create a textdraw which disappears after 2 seconds use this code :

 

:loop

if 0@ == 1
then
	0@ = 0

	0C48: samp textdraw 100 create "Hello! pos 240.0 200.0  
  	0C4E: samp textdraw 100 set_outline 1 color 0xFF000000 
  	0C4A: samp textdraw 100 set_align 3
  	0C4C: samp textdraw 100 set_style 1
  	0C52: samp textdraw 100 set_letter_size 1.00 4.000 color 0xFFFFFFFF
  	0C4B: samp textdraw 100 set_proportional true
	
	wait 2000
	
	if 0C5D: samp textdraw 100 is_exists
	then
		0C5E: samp textdraw 100 delete
	end
end

wait 0
jump @loop

 

Create a command which set the variable 0@ to 1 and is done. If you need the textdraw to always remain on the screen, remove that 'wait' and everything that contains checking if textdraw exists and textdraw no more disappear.

To find screen pos for creating textdraw at those coordinates or something else you cand use this code :

:loop

if 0C7E:	is_console_active
then
	0B5E: get_cursor_pos 1@ 2@
	
	log "PosX : %f | PosY : %f" 1@ 2@
	wait 1000 //for anti-spam
end

wait 0
jump @loop

Active SAMPFUNCS console (press ` on keyboard) and the mouse cursor coordinates will appear in that console in the form of floats every one second.

 

 

On 9/1/2020 at 5:36 PM, DjC said:

chatmsg "Text "%s" has been saved to FileName.”" 20@ -1 //Doesn't work

chatmsg "Text has been saved to FileName.”" 20@ -1 //Work

To resolve this try this: 

chatmsg "Text %s has been saved to FileName.”" -1 20@

And full command if you need:

:savetext
if SAMP.IsCommandTyped(0@)
then
  	0AF5: write_string 0@ to_ini_file "cleo\FileName.ini" section "SectionName" key "stringKey"
	chatmsg "{FFFFFF}Text %s has been saved to FileName." -1 0@
else
	chatmsg "{FFFFFF}Use: /savetext <text>" -1
end
SAMP.CmdRet

 

I hope I helped you. If you have any more questions, let me know

Edited by Tupi
Link to comment
Share on other sites

On 9/1/2020 at 4:36 PM, DjC said:

 


{$CLEO}

0662: "made by djc"
thread "0.1"
wait 2500

0B34: samp register_client_command "ok" to_label @sag

:cmd_39
wait 0   
jump @cmd_39

:sag         
0C48: samp textdraw 550 create "Hello!" pos 240.0 200.0
0C52: samp textdraw 550 set_letter_size 1.00 4.00 color -14110752
0C4C: samp textdraw 550 set_style 1                     
0C4D: samp textdraw 550 set_shadow 1 color -16448251
wait 2000
0C5E: samp textdraw 550 delete
cmdret

 


wait instruction works only inside a loop.
it has to be like this :

 

 

{$CLEO .cs}
{$INCLUDE SF}

//-------------MAIN---------------
thread "Djo" 
:Djo_69
wait 0 
if 
   SAMP.Available
else_jump @Djo_69 
SAMP.UnregisterClientCommand("ok")
0B34: samp register_client_command "ok" to_label @Djo

while true
wait 0
    if 1@ == 1 then 
        0C48: samp textdraw 550 create "Hello!" pos 240.0 200.0
        0C52: samp textdraw 550 set_letter_size 1.00 4.00 color -14110752
        0C4C: samp textdraw 550 set_style 1                     
        0C4D: samp textdraw 550 set_shadow 1 color -16448251
        wait 2000
        0C5E: samp textdraw 550 delete
        1@ = 0
    end     
end

:Djo
1@ = 1
samp.CmdRet()

ret 0

 

Edited by CouldnoT
Link to comment
Share on other sites

9 hours ago, CouldnoT said:


wait instruction works only inside a loop.
it has to be like this :

 

 


{$CLEO .cs}
{$INCLUDE SF}

//-------------MAIN---------------
thread "Djo" 
:Djo_69
wait 0 
if 
   SAMP.Available
else_jump @Djo_69 
SAMP.UnregisterClientCommand("ok")
0B34: samp register_client_command "ok" to_label @Djo

while true
wait 0
    if 1@ == 1 then 
        0C48: samp textdraw 550 create "Hello!" pos 240.0 200.0
        0C52: samp textdraw 550 set_letter_size 1.00 4.00 color -14110752
        0C4C: samp textdraw 550 set_style 1                     
        0C4D: samp textdraw 550 set_shadow 1 color -16448251
        wait 2000
        0C5E: samp textdraw 550 delete
        1@ = 0
    end     
end

:Djo
1@ = 1
samp.CmdRet()

ret 0

 

9 hours ago, CouldnoT said:

characters in a 20@ string are very limited so if the chat message is longer than the limit will cause a crash.
I have tried to allocate the memory and use a variable 20@v which is longer than the other.
It will still crash if the string outnumbers the limit, but this may makes it work: 


:settext
if SAMP.IsCommandTyped(20@v)
then
	0AC8: 0@ = allocate_memory_size 260
  	0AF5: write_string 20@v to_ini_file "cleo\FileName.ini" section "SectionName" key "stringKey"
	chatmsg "Text: %s" 20@v -1 
  	0AC9: free_allocated_memory 0@
else
	chatmsg "SYNTAX : /settext ”new text”" -1
end
SAMP.CmdRet()  

 

So I think we should not worry about showing the text I entered earlier there

9 hours ago, Tupi said:

Hello,

 

Function 'wait' can only be used in a loop that repeats itself indefinitely, can't be used in commands. For create a textdraw which disappears after 2 seconds use this code :

 


:loop

if 0@ == 1
then
	0@ = 0

	0C48: samp textdraw 100 create "Hello! pos 240.0 200.0  
  	0C4E: samp textdraw 100 set_outline 1 color 0xFF000000 
  	0C4A: samp textdraw 100 set_align 3
  	0C4C: samp textdraw 100 set_style 1
  	0C52: samp textdraw 100 set_letter_size 1.00 4.000 color 0xFFFFFFFF
  	0C4B: samp textdraw 100 set_proportional true
	
	wait 2000
	
	if 0C5D: samp textdraw 100 is_exists
	then
		0C5E: samp textdraw 100 delete
	end
end

wait 0
jump @loop

 

Create a command which set the variable 0@ to 1 and is done. If you need the textdraw to always remain on the screen, remove that 'wait' and everything that contains checking if textdraw exists and textdraw no more disappear.

To find screen pos for creating textdraw at those coordinates or something else you cand use this code :


:loop

if 0C7E:	is_console_active
then
	0B5E: get_cursor_pos 1@ 2@
	
	log "PosX : %f | PosY : %f" 1@ 2@
	wait 1000 //for anti-spam
end

wait 0
jump @loop

Active SAMPFUNCS console (press ` on keyboard) and the mouse cursor coordinates will appear in that console in the form of floats every one second.

 

 

To resolve this try this: 


chatmsg "Text %s has been saved to FileName.”" -1 20@

And full command if you need:


:savetext
if SAMP.IsCommandTyped(0@)
then
  	0AF5: write_string 0@ to_ini_file "cleo\FileName.ini" section "SectionName" key "stringKey"
	chatmsg "{FFFFFF}Text %s has been saved to FileName." -1 0@
else
	chatmsg "{FFFFFF}Use: /savetext <text>" -1
end
SAMP.CmdRet

 

I hope I helped you. If you have any more questions, let me know

 

Thank you very much. If I still have a problem I will try topic new. You can close the Topic. ❤️

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.