CLEO Help Help autocall

CLEO related
Status
Not open for further replies.

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
Hello.. I have a problem.. I'm trying to make a mod which scan a string and get for exemple 7 numbers from it, then use it as /call ..

take a look and can you please tell me what I am doing wrong? I mean, maybe I didn't understand very well  how to scan strang and get numbers from it but i'd like to learn. Thank you very much! appreciate!

Code:
0B34: samp register_client_command "call" to_label @call

//0AF8: samp add_message_to_chat "{660000}autosms..cs - Working" color 0x660000

wait 1000
thread "autocall"

:Noname_05
wait 0
jump @Noname_05


:call
  SAMP.IsCommandTyped(0@)
IF 0AD4: 1@ = scan_string 0@ format "%d" 2@
JF @ERROR
IF SAMP.IsPlayerConnected(2@)
JF @ERROR_2
3@ = SAMP.GetPlayerNickname(2@)
Say "/number %s" 3@
jump @scan                                           
SAMP.CmdRet


 : scan 
alloc 0@ = 145
alloc 1@ = 25
0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to -1 prefix_color_to -1 //citesti linia din chat, 99 = ultima
    if
    0C29: 3@ = stristr string1 0@ string2 "{999999}Name: %s, Phone number: %s%s%s-%s%s%s%s" 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ //cauti un string in alt string, cauti \'potato\' in ultimul mesaj din chat
  then
  Say "/call %s%s%s%s%s%s%s" 6@ 7@ 8@ 9@ 10@ 11@ 12@
  end 
  
free 0@
free 1@





:error
chatmsg "nu-i buna sintaxa, iti tre' un id" -1
samp.CmdRet()

:error_2
chatmsg "crash" -1
samp.CmdRet()

// I was thinking to make it write into .ini the number then read it from .ini file.. but I don't know how to get info from string exactly and then write it elsewhere.. And I also don't understand how alocating memory works.. Thank you very much!
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
Look what i'd like to learn.. I'm thinking to compile it with .ini,
for example, if on chat it's exists a line like " Rough isi baga: banii",
string could be autoscanned from secvence " Rough isi baga... " and take the information positioned after the two dots, like " Rough isi baga: %s" and take it intr-o .ini the information, i mean the %s that's what i like to learn..



Thank you very much and merry christmas!
 
D

Deleted member 34507

Guest
Rough said:
Uite ce as vrea sa inteleg mai exact.. m-am gandit sa-l fac cu ini,
daca pe chat scrie " Rough isi baga: banii",
sa se scaneze automat stringul cu " Rough isi baga... " si sa ia  ce-i dupa : puncte, adica " Rough isi baga: %s" si sa-l treaca intr-un string.. asta as vrea sa inteleg cum se face..

si inca o chestie, cum se baga wait intr-un samp.cmdret()

Multumesc mult si craciun fericit!
http://ugbase.eu/Thread-General-UGBASE-EU-Rules 1.4 Don't speak your language! Speak English.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
Opcode 0C29 searches for an already formatted string, like "Name: Rough". If you want to extract decimals, strings etc. use 0AD4(you can google
"C sscanf", to understand more of 0AD4 syntax and use).

Allocating memory means you request memory(in vm space) which you can use how you like. If you have a string that's 200 chars, you need
to store it somewhere, so you must request storage/space for it. Freeing the memory means you'll no longer use that storage/space and it can be reused/reallocated by the game.
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
:call         // pune numarul celui sunat in string
  SAMP.IsCommandTyped(0@)
IF 0AD4: 1@ = scan_string 0@ format "%d" 2@
JF @ERROR
IF SAMP.IsPlayerConnected(2@)
JF @ERROR_2
3@ = SAMP.GetPlayerNickname(2@)
Say "/number %s" 3@
jump @scan                                           
                                                                                           // "{999999}Name: %s, Phone number: %d%d%d-%d%d%d%d"

:scan      // scaneaza stringul
0AC8: 0@ = allocate_memory_size 256
0AC8: 1@ = allocate_memory_size 128
0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to -1 prefix_color_to -1 //citesti linia din chat, 99 = ultima
if 0C29: 3@ = stristr string1 0@ string2 "Phone number" //cauti un string in alt string, cauti \'potato\' in ultimul mesaj din chat
0AD4: 4@ = scan_string 0@v format "Phone number: %d%d%d-%d%d%d%d" 5@ 6@ 7@ 8@ 9@ 10@ 11@  //IF and SET
 0AF9: "/say %d%d%d%d%d%d%d" 5@ 6@ 7@ 8@ 9@ 10@ 11@
samp.CmdRet()




    //0AD4: 4@ = scan_string 99 format "{999999}Name: %s, Phone number: %d%d%d-%d%d%d%d" 7@ 8@
    //0AF5: write_string 3@ to_ini_file "cleo\autosms.ini" section "Section" key "string"
 
free 0@
free 1@





:error
chatmsg "nu-i buna sintaxa, iti tre' un id" -1
samp.CmdRet()

:error_2
chatmsg "crash" -1
samp.CmdRet()



@Springfield this is what i've made so far, but i have a problem, i replaced /call with /say, and the number are 0000000 can you tell me why is that? i have no idea
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
It's writing the number 0000000 on chat, what da?!


Well, :call // pune numarul celui sunat in string
SAMP.IsCommandTyped(0@)
IF 0AD4: 1@ = scan_string 0@ format "%d" 2@
JF @ERROR
IF SAMP.IsPlayerConnected(2@)
JF @ERROR_2
3@ = SAMP.GetPlayerNickname(2@)
Say "/number %s" 3@
jump @scan
// "{999999}Name: %s, Phone number: %d%d%d-%d%d%d%d"

:scan // scaneaza stringul
0AC8: 0@ = allocate_memory_size 256
0AC8: 1@ = allocate_memory_size 128
//0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to -1 prefix_color_to -1 //citesti linia din chat, 99 = ultima
//if 0C29: 3@ = stristr string1 0@ string2 "Phone number" //cauti un string in alt string, cauti \'potato\' in ultimul mesaj din chat
0AD4: 4@ = scan_string 0@ format "{999999}Name: %s, Phone number: %d%d%d-%d%d%d%d" 12@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ //IF and SET
chatmsg "/say %d%d%d%d%d%d%d" -1 5@ 6@ 7@ 8@ 9@ 10@ 11@
samp.CmdRet()

the result is this

/say 0000000

[16:15:13] {999999}Name: Taykiro., Phone number: 908-8336

well †
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
springfield said:
Opcode 0C29 searches for an already formatted string, like "Name: Rough". If you want to extract decimals, strings etc. use 0AD4(you can google
"C sscanf", to understand more of 0AD4 syntax and use).

Allocating memory means you request memory(in vm space) which you can use how you like. If you have a string that's 200 chars, you need
to store it somewhere, so you must request storage/space for it. Freeing the memory means you'll no longer use that storage/space and it can be reused/reallocated by the game.

Ok, can u explain me why this shet working:
[shcode=cpp]0AD4: $moc = scan "Name: LaurentiuLXG, Phone number: 947-2035" format "%s %s %s %s %d %d" 18@ 19@ 20@ 21@ 22@ 23@[/shcode]

but this, nope
[shcode=cpp]0B75: samp get_chat_string $TEXT text_to $PREFIX prefix_to 3@ color_to 4@ prefix_color_to 5@
wait 50
//0AD4: $moc = scan "Name: LaurentiuLXG, Phone number: 947-2035" format "%s %s %s %s %d %d" 18@ 19@ 20@ 21@ 22@ 23@
0AD4: $moc = scan $TEXT format "%s %s %s %s %d %d" 17@ 18@ 19@ 20@ 21@ 22@ 23@
CHATMSG "NR ESTE %d%d " -1 22@ 23@[/shcode]

This is the string, copy paste from chatlog.txt 
[shcode=cpp][17:43:44] {999999}Name: GabiRazvi, Phone number: 510-3665[/shcode]

Probably my example not working bcs of the color so i tried :
[shcode=cpp]0AD4: $moc = scan $TEXT format "%d %s %s %s %s %d %d" 16@ 17@ 18@ 19@ 20@ 21@ 22@ 23@[/shcode]

and still not working :). damn this shet
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
mistery said:
how shall i give a hand? its ahk not cleo, completely different

doroftel said:
mistery said:
lol i did this in ahk in like half an hour

scan string /number %d ,from rpg.b-zone.ro then

string %d?
tell me exactly the text you want to scan

http://imgur.com/a/AvdZ7 last text, here you have copy paste from chatlog.txt ( timestamp on ):  [20:23:29] {999999}Name: Greddy., Phone number: 747-8747

String %d ? u got it wrong, when i write in chat "/number %d" %d = integer then sv will show me number of the %d player
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
From my old phonebook cleo, for the same server you guys are trying.

[shcode=cpp]
if or
   0AD4: 29@ = scan 20@ format "{999999}Name: %s Phone number: %s" 21@v 25@s
   0AD4: 29@ = scan 20@ format "{999999}Nume: %s Numar de telefon: %s" 21@v 25@s
then
   do_stuff
end
[/shcode]
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
mistery said:
yep i tested works fine

i hope you'l burn in hell


springfield said:
From my old phonebook cleo, for the same server you guys are trying.

[shcode=cpp]
if or
   0AD4: 29@ = scan 20@ format "{999999}Name: %s Phone number: %s" 21@v 25@s
   0AD4: 29@ = scan 20@ format "{999999}Nume: %s Numar de telefon: %s" 21@v 25@s
then
   do_stuff
end
[/shcode]

fck of u should say "idiots it is easy try more " :| ty i got it :)) really is :>> i wont write numbers anymore:>

[shcode=cpp]{$CLEO .cs}

:Noname_02
wait 0

:Noname_03
wait 0
IF SAMP.Available()
JF @Noname_03
                    0b63: "cal" 
0b34: "cal" @teste    
0C6A: 26@ = create_custom_thread_at_label @while
1@ = 0

:Noname_04
wait 0
jump @Noname_04

:teste
SAMP.IsCommandTyped($drq)
$while = 1
say "/number %s" $drq
SAMP.CmdRet()
:while
while true
wait 0
if 
$while == 1
then
wait 300
   alloc 20@ 360
    SAMP.GetChatString(99, 20@, 2@, 2@, 2@)
if 
   0AD4: 29@ = scan 20@ format "{999999}Name: %s Phone number: %s" 21@v 25@s
then
say "/call %s" 25@s
else
chatmsg "nu pot ba nu pot!" -1
end  
free 20@
$while = 0 
end
end
Code:
[/shcode]
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
springfield said:
From my old phonebook cleo, for the same server you guys are trying.

[shcode=cpp]
if or
   0AD4: 29@ = scan 20@ format "{999999}Name: %s Phone number: %s" 21@v 25@s
   0AD4: 29@ = scan 20@ format "{999999}Nume: %s Numar de telefon: %s" 21@v 25@s
then
   do_stuff
end
[/shcode]

Thank you very much for your help! :)

You are the best!
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
@springfield

[shcode=cpp]
{$CLEO .cs}
:Noname_03
wait 0

:Noname_04
wait 0
IF SAMP.Available
jf @Noname_04

0B34: samp register_client_command "call" to_label @call
0AF8: samp add_message_to_chat "{660000}autosms..cs - Working" color 0x660000

wait 1000
thread "autocall"

:Noname_05
wait 0
jump @Noname_05

:call         // pune numarul celui sunat in string
  SAMP.IsCommandTyped(0@)
IF 0AD4: 1@ = scan_string 0@ format "%d" 2@
JF @ERROR
IF SAMP.IsPlayerConnected(2@)
JF @ERROR_2
3@ = SAMP.GetPlayerNickname(2@)                                                             
Say "/number %s" 3@
jump @scan                                           
                                                                                         
:scan      // scaneaza stringul
alloc 20@ 360
   0B75: samp get_chat_string 99 text_to 20@ prefix_to 2@ color_to 2@ prefix_color_to -1

if or
   0AD4: 29@ = scan 20@ format "{999999}Nume: %s Numar de telefon: %s" 21@v 25@s
   0AD4: 29@ = scan 20@ format "{999999}Name: %s Phone number: %s" 21@v 25@s
then                                                             
say "/call %s" 25@s

end
samp.CmdRet()
free 20@
 
:error
chatmsg "nu-i buna sintaxa, iti tre' un id" -1
samp.CmdRet()

:error_2
chatmsg "crash" -1
samp.CmdRet()

[/shcode]
i have to type /call [id] 2 times to make the /call because i think from the first /call the string isn't readed, can you tell me why? thanks!
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
When you call 0B75 the chat hasn't been update yet, since the time between the "Say "/number %s" 3@" and " 0B75: samp get_chat_string 99" is ZERO.
Use the command to set up stuff, and in the main loop (noname_5) check the last string.
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
Rough, read it:

[shcode=cpp]     {$CLEO}

    :Noname_03
    wait 0

    :Noname_04
    WAIT 0
    IF SAMP.Available()  // IF SAMP IS NOT LOADED THEN SCRIPT WILL GO AT LABEL :NONAME_04 UNTIL IT GET LOADED
    JF @Noname_04

    0C6A: $CUSTOM_THREAD = create_custom_thread_at_label @Call_Function // THIS OPCODE CREATE ANOTHER THREAD SO SCRIPT WILL ALL TIME READ CALL LABEL + BASE SCRIPT ! // "0C6A: CREATE ANOTHER "HEAD" "
    0B34: samp register_client_command "call" to_label @Call
    CHATMSG "Rough smecher dala mare ! " -1 // -1 = COLOR
    $Call_FUNCTION = FALSE
   
    :Noname_05 // IF YOU DON'T WRITE 0B34 IN GAME THEN SCRIPT WILL READ NONAME_05 ALL TIME
    WAIT 0
    JUMP @Noname_05

   :Call
   SAMP.IsCommandTyped(0@)
   Say "/number %s" 0@ // 0@ = STRING SO WE CAN USE /call %d OR %s IN GAME , EXAMPLE: /call springfield OR /call 561
   $Call_FUNCTION = TRUE // We need make a condition in @Call_Function, IF $CALL_Function is TRUE THEN WRITE IT, IF NOT THEN SCRIPT WILL READ ONLY FIRST LINES "wait 0, if $var == true, "JF" @Call_function" ALL TIME
   SAMP.CmdRet // IF WE USE HERE WAIT SCRIPT WONT READ IT BECAUSE WE USED SAMP.CmdRet

   :Call_Function
   WHILE TRUE // WE USE IT BECAUSE WE NEED USE WAIT, CHECK WHAT SPRINGFIELD SAID
   WAIT 0
   IF $Call_FUNCTION == TRUE // IF NOT THEN THIS "HEAD" WILL READ ALL TIME THESE THREE LINES"
     THEN
     0AC8: $TEXT = allocate_memory_size 69 // OR alloc $TEXT = 69 , IT DOING SAME THING  , YOU NEED ALLOCATE MEMORY FOR IT
     0B75: samp get_chat_string 99 text_to $TEXT prefix_to 3@ color_to 4@ prefix_color_to 5@   // I USE ONLY GLOBAL VARS BECAUSE WHEN I ALLOC MEMORY FOR IT I DONT NEED ANYMORE TO use FREE/0AC9 for IT !
     WAIT 300 MS // BECAUSE WHEN SCRIPT WRITE /number, IT WILL APPEAR LATER AND 0AD4 WONT READ THE GOOD TEXT
     IF OR  // CREDITS : SPRINGFIELD
     0AD4: $SCAN_EN = scan $TEXT format "{999999}Name: %s Phone number: %s" 21@v 25@s // CREDITS : SPRINGFIELD
     0AD4: $SCAN_RO = scan $TEXT format "{999999}Nume: %s Numar de telefon: %s" 21@v 25@s //  CREDITS : SPRINGFIELD
        THEN
        SAY "/call %s" 25@s
        $Call_FUNCTION = FALSE // WE STOP IT
      END
     END
   END   [/shcode]

I used the same technique as Duraxel because it is easy to understand :).
 
Status
Not open for further replies.
Top