CLEO Help Help with scan_string

CLEO related
Status
Not open for further replies.

DuFF

Member
Joined
Apr 5, 2014
Messages
20
Reaction score
0
Hello,
I'm trying to make a script for RP server. When I see in the chat, that player needs my services, I have to use command "/zakaznik <ID of player>" to teleport to him and offer him my services(RP command).
So I made this script:

Code:
{$CLEO .cs}

thread 'SERVICES'

:Load
wait 200 
if
  SAMP.Available
else_jump @Load

0B34: samp register_client_command "onzakaznik" to_label @START
0B34: samp register_client_command "offzakaznik" to_label @STOP

0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260
0AC8: 3@ = allocate_memory_size 260
0AC8: 4@ = allocate_memory_size 260

while true
    wait 0
    if
    31@ == 1
    then
        SAMP.GetChatString(99, 1@, 2@, 3@, 4@)
        if or
        0AD4: 30@ = scan_string 1@ format "Hráč {FFFFFF}%s(%d) {7171FF} potřebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s." 5@ 6@ 7@ 8@ 9@ 10@
        0AD4: 30@ = scan_string 1@ format "Hráč {FFFFFF}%s(%d) {7171FF} potřebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s %s." 5@ 6@ 7@ 8@ 9@ 10@ 11@
        0AD4: 30@ = scan_string 1@ format "Hráč {FFFFFF}%s(%d) {7171FF} potřebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s %s %s." 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@
        then
            alloc 29@ 64
            format 29@ "/zakaznik %d" 6@
            0AF9: samp say_msg 29@
            31@ = 0
            0AF8: samp add_message_to_chat "OFF" color -1
        end   
    end
SAMP.CmdRet()
end

:START
31@ = 1
0AF8: samp add_message_to_chat "ON" color -1
SAMP.CmdRet()


:STOP
31@ = 0
0AF8: samp add_message_to_chat "OFF" color -1
SAMP.CmdRet()

But it doesn't work. I can give you examples of the messages from chat.

Hráč {FFFFFF}[D]eniSVK(74) {7171FF} potřebuje Vaše služby (129 167 530$ v bance). Nachází se v {FFFFFF}Shady Creeks.

In my language this means that player [D]eniSVK(his ID - this is, what I need) needs my services (his money in the bank), he is located in (location - 1-3 words)
The most of players have 1 000 000 - 999 999 999$ in the bank, so you don't have to fix it for players with more money than 999 999 999 and less than 1 000 000

You can find the same problem in this post:
http://ugbase.eu/help-7/get-player-id/

I still don't know how to use 0AD4, so, could you try to fix my code?

Thank you for the help and please, excuse my poor english grammar.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
What doesn't work?
If it doesn't send the command in chat, most likely you have the wrong format(if or == false), you can test to be sure by showing a simple chat/text message if the condition is true.
If it does but it's incorrect, it's because of 0AD4 can only output strings to long variables(@v).

Something like this should work:
Code:
0AD4: 30@ = scan_string 1@ format "Hráč {FFFFFF}%s(%d) {7171FF} potřebuje Vaše služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s." 15@v 24@ 25@ 26@ 27@ 20@v

Code:
    end
SAMP.CmdRet() //this doesn't belong here
end
 

0B36

Expert
Joined
Jan 6, 2014
Messages
1,324
Reaction score
8
Code:
{$CLEO}

thread "SERVICES"

repeat
wait 0
until SAMP.Available()

0B34: "onzakaznik" @START
0B34: "offzakaznik" @STOP

alloc 1@ = 260
alloc 2@ = 260
alloc 3@ = 260
alloc 4@ = 260

while true
wait 0
    if
        31@ == 1
    then
        SAMP.GetChatString(99, 1@, 2@, 3@, 4@)
        if or
              0AD4: 30@ = scan_string 1@ format "Hrác {FFFFFF}%s(%d) {7171FF} potrebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s." 5@v 10@ 11@ 12@ 13@ 14@v
              0AD4: 30@ = scan_string 1@ format "Hrác {FFFFFF}%s(%d) {7171FF} potrebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s %s." 5@v 10@ 11@ 12@ 13@ 14@v 19@v
              0AD4: 30@ = scan_string 1@ format "Hrác {FFFFFF}%s(%d) {7171FF} potrebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s %s %s." 5@v 10@ 11@ 12@ 13@ 14@v 19@v 24@v
        then
              alloc 29@ 64
              format 29@ "/zakaznik %d" $NOTUSED
              0AF9: 29@
              free 29@
        end   
    end
end

:START
wait 0
31@ = 1
0AF8: samp add_message_to_chat "ON" color -1
SAMP.CmdRet()


:STOP
wait 0
31@ = 0
0AF8: samp add_message_to_chat "OFF" color -1
SAMP.CmdRet()

Try that. Remove the colour codes from 0AD4 if it doesn't scan with them.
 

DuFF

Member
Joined
Apr 5, 2014
Messages
20
Reaction score
0
Well, I made a simple debug script:

Code:
#include <a_samp>
#include <zcmd>

new sstring[128];
new rand;

CMD:debug(playerid)
{
	rand = random(500);
	format(sstring, sizeof(sstring), "ID = %d", rand);
	SendClientMessage(playerid, -1, sstring);
	return 1;
}

When I use this code:

Code:
{$CLEO .cs}

thread 'SERVICES'

:Load
wait 200 
if
  SAMP.Available
else_jump @Load

0B34: samp register_client_command "onzakaznik" to_label @START
0B34: samp register_client_command "offzakaznik" to_label @STOP

0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260
0AC8: 3@ = allocate_memory_size 260
0AC8: 4@ = allocate_memory_size 260

while true
    wait 0
    if
    31@ == 1
    then
        SAMP.GetChatString(99, 1@, 2@, 3@, 4@)
        if
        0AD4: 30@ = scan_string 1@ format "ID = %d" 6@
        then
            alloc 29@ 64
            format 29@ "/zakaznik %d" 6@
            0AF9: samp say_msg 29@
            31@ = 0
            0AF8: samp add_message_to_chat "OFF" color -1
        end   
    end
end

:START
31@ = 1
0AF8: samp add_message_to_chat "ON" color -1
SAMP.CmdRet()


:STOP
31@ = 0
0AF8: samp add_message_to_chat "OFF" color -1
SAMP.CmdRet()

It works perfectly, it sends the command after I type /debug, but this code doens't detect message with colors, if I want to detect message: {7171FF}ID = {FFFFFF}45, I have to use this: 0AD4: 30@ = scan_string 1@ format "{7171FF}ID = {FFFFFF}%d" 6@

-----------------------------------------------

When I use this code:

Code:
{$CLEO .cs}

thread 'SERVICES'

:Load
wait 200 
if
  SAMP.Available
else_jump @Load

0B34: samp register_client_command "onzakaznik" to_label @START
0B34: samp register_client_command "offzakaznik" to_label @STOP

0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260
0AC8: 3@ = allocate_memory_size 260
0AC8: 4@ = allocate_memory_size 260

while true
    wait 0
    if
    31@ == 1
    then
        SAMP.GetChatString(99, 1@, 2@, 3@, 4@)
        if or
        0AD4: 30@ = scan_string 1@ format "ID = %d" 6@
        0AD4: 30@ = scan_string 1@ format "Hráč {FFFFFF}%s(%d) {7171FF} potřebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s." 5@v 6@ 7@ 8@ 9@ 10@v
        0AD4: 30@ = scan_string 1@ format "Hráč {FFFFFF}%s(%d) {7171FF} potřebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s %s." 5@v 6@ 7@ 8@ 9@ 10@v 11@v
        0AD4: 30@ = scan_string 1@ format "Hráč {FFFFFF}%s(%d) {7171FF} potřebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v {FFFFFF}%s %s %s." 5@v 6@ 7@ 8@ 9@ 10@v 11@v 12@v
        then
            alloc 29@ 64
            format 29@ "/zakaznik %d" 6@
            0AF9: samp say_msg 29@
            31@ = 0
            0AF8: samp add_message_to_chat "OFF" color -1
        end   
    end
end

:START
31@ = 1
0AF8: samp add_message_to_chat "ON" color -1
SAMP.CmdRet()


:STOP
31@ = 0
0AF8: samp add_message_to_chat "OFF" color -1
SAMP.CmdRet()

It doesn't work at all. So the problem is in "if or" condition, but I have no idea how to fix it. What do you think about it?

...............
The second problem:
PAWN CODE
Code:
CMD:debug2(playerid)
{
	rand = random(500);
	format(sstring, sizeof(sstring), "Hráč Test_Player(%d)  potřebuje VaÅ¡e služby (123 456 789$ v bance). Nachází se v {FFFFFF}Montgomery.", rand);
	SendClientMessage(playerid, -1, sstring);
	return 1;
}

Sanny Builder:
Code:
{$CLEO .cs}

thread 'SERVICES'

:Load
wait 200 
if
  SAMP.Available
else_jump @Load

0B34: samp register_client_command "onzakaznik" to_label @START
0B34: samp register_client_command "offzakaznik" to_label @STOP

0AC8: 1@ = allocate_memory_size 260
0AC8: 2@ = allocate_memory_size 260
0AC8: 3@ = allocate_memory_size 260
0AC8: 4@ = allocate_memory_size 260

while true
    wait 0
    if
    31@ == 1
    then
        SAMP.GetChatString(99, 1@, 2@, 3@, 4@)
        if
        0AD4: 30@ = scan_string 1@ format "Hráč %s(%d)  potřebuje VaÅ¡e služby (%d %d %d$ v bance). Nachází se v %s." 5@v 6@ 7@ 8@ 9@ 10@v
        then
            alloc 29@ 64
            format 29@ "/zakaznik %d" 6@
            0AF9: samp say_msg 29@
            31@ = 0
            0AF8: samp add_message_to_chat "OFF" color -1
        end   
    end
end

:START
31@ = 1
0AF8: samp add_message_to_chat "ON" color -1
SAMP.CmdRet()


:STOP
31@ = 0
0AF8: samp add_message_to_chat "OFF" color -1
SAMP.CmdRet()

And it doesn't send the command after /debug1. So, where do you see the problem?
 
Status
Not open for further replies.
Top