CLEO Help 0AD4 - Doesn't seem to support the '/' character.

CLEO related
Status
Not open for further replies.

HooThaFuck

Active member
Joined
Apr 18, 2015
Messages
51
Reaction score
0
This is an important development for this thread. I discovered something awful...
Code:
        //DEBUGGER
        IF
            0AD4: 28@ = scan_string 0@ format "Use {FF0000}/%s" 27[member=21661]S[/member]
        THEN
            0AF8: samp add_message_to_chat "1 %s = %s" 0xFF00FFFF 0@ 27[member=21661]S[/member] 
            wait 5000
        ELSE  
            IF
                0AD4: 28@ = scan_string 0@ format "Use {FF0000}%s" 27[member=21661]S[/member]
            THEN
                0AF8: samp add_message_to_chat "2 %s = %s" 0xFF00FFFF 0@ 27[member=21661]S[/member]   
                wait 5000
            END
        END 
        //DEBUGGER
Doing this I only receive the '2' message when I should be successfully receiving the 1st. I guess 0AD4 doesn't support '/'. How can we get around this? I was thinking of cutting the beginning of the string off, but I don't think this is possible in CLEO (unless of course someone added a string splitting opcode).
 

HooThaFuck

Active member
Joined
Apr 18, 2015
Messages
51
Reaction score
0
Ah! Now it works. I actually thought of that before but I didn't expect it to support characters. Anyways, now I have this:
Code:
        ///*==========[DEBUG]===========*\ 
        
        IF
            0AD4: 28@ = scan_string 0@ format "Use {FF0000}%c%s" 26@ 27[member=21661]S[/member]
        THEN
            0AF8: samp add_message_to_chat "[D] %s" 0xFF00FFFF 27[member=21661]S[/member] 
            wait 5000
        END  
        
        //\*============================*/
And the string comes out "FF00[" for "Use {FF0000}/answer{00FFFF} to solve this question: {FF00CC}1 * 2 ?". That seems to be a fuck up.
       
Even with that fixed though, I'm running into another brick wall. These still don't work...
Code:
        IF
            0AD4: 28@ = scan_string 0@ format "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d ?" 15@ 2@ 3@
        THEN
            0AF8: samp add_message_to_chat "Calculating: %d * %d" 0xFF00FFFF 2@ 3@ 
            006A: 2@ *= 3@
            0AF8: samp add_message_to_chat "Result: %d" 0xFF00FFFF 2@    
            0AF9: samp say_msg "/answer %d" 2@ 
            wait 5000
        END       
        
        IF
            0AD4: 28@ = scan_string 0@ format "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d * %d ?" 15@ 2@ 3@ 4@
        THEN
            0AF8: samp add_message_to_chat "Calculating: %d * %d * %d" 0xFF00FFFF 2@ 3@ 4@ 
            006A: 2@ *= 3@
            006A: 2@ *= 4@ 
            0AF8: samp add_message_to_chat "Result: %d" 0xFF00FFFF 2@    
            0AF9: samp say_msg "/answer %d" 2@ 
            wait 5000
        END 
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Test this, it's a simple debug script to see if all works okay for you.
Compile it, press 1(not numpad) and if it auto says in chat "ANSWER IS <n>" then 0AD4 works fine.

Code:
{$CLEO}
0000:

REPEAT
    WAIT 69
UNTIL SAMP.Available()

var
2@ : string
3@ : string
6@ : int
7@ : int
end

WHILE TRUE
    WAIT 0
    0AC8: 2@ = 145
    0AC8: 3@ = 24
    0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d ?" $NUL2 6@ 7@
    THEN
        6@ *= 7@
        0AF9: "ANSWER IS %d" 6@
        WAIT 1000
    END
    IF 0AB0: 49 //VK_NUM1
    THEN 
        0209: 8@ = random_int_in_ranges 1 33
        0209: 9@ = random_int_in_ranges 1 33
        0AF8: "Use {FF0000}/answer{00FFFF} to solve this question: {FF00CC}%d * %d ?" -1 8@ 9@
        WAIT 10
    END
    0AC9: 2@
    0AC9: 3@
END

If it works, here are some reasons why yours won't work;
- pointer to string is changed/null
- wrong color codes
- wrong format
- missing color codes(usually the first color code won't show up in chatlog)
 

HooThaFuck

Active member
Joined
Apr 18, 2015
Messages
51
Reaction score
0
Apparently it's the color codes. My script was running alongside yours and when i typed your plain message (pressing 1) my script got the answer. It wouldn't do that if the string had colors in it. It's odd though, my script has the color codes in its string scan still so how did it match a plain string?

Anyways, I have no clue what the fuck is going on in your debug script. I'm going to try to learn from it but it'd be nice if you could explain how it works (just the basics at least :3). Here is my code if you would please fix the color codes...
Code:
{$CLEO .cs}
0000:

WHILE TRUE
    WAIT 0
    IF
        SAMP.Available()
    THEN                     
        0AC8: 0@ = allocate_memory_size 260
        0AC8: 1@ = allocate_memory_size 260
        0AB1: @GETCHATENTRYTEXT 1 id 98 to 0@ 
        
        IF
            0AD4: 28@ = scan_string 0@ format "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d ?" 15@ 2@ 3@
        THEN
            0AF8: samp add_message_to_chat "Calculating: %d * %d" 0xFF00FFFF 2@ 3@ 
            006A: 2@ *= 3@
            0AF8: samp add_message_to_chat "Result: %d" 0xFF00FFFF 2@    
            0AF9: samp say_msg "/answer %d" 2@ 
            wait 5000
        END       
        
        IF
            0AD4: 28@ = scan_string 0@ format "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d * %d ?" 15@ 2@ 3@ 4@
        THEN
            0AF8: samp add_message_to_chat "Calculating: %d * %d * %d" 0xFF00FFFF 2@ 3@ 4@ 
            006A: 2@ *= 3@
            006A: 2@ *= 4@ 
            0AF8: samp add_message_to_chat "Result: %d" 0xFF00FFFF 2@    
            0AF9: samp say_msg "/answer %d" 2@ 
            wait 5000
        END  
        
        0AC9: free_allocated_memory 0@
        0AC9: free_allocated_memory 1@ 
    END 
END

:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x212A6C
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: ret 1 1@

The string actually received is:
"Use {FF0000}/answer{00FFFF} to solve this question: {FF00CC}#HERE * #HERE ?"
And the main color is 00FFFF (so 'use' is 00FFFF). I can add other operations easily with a fixed version.


EDIT: I just came up with an idea. I want to make it so that it says "The answer is %d, press 5 to send the answer". The answer will be stored globally and you press 5 to send it.

EDIT_2: This is what I tried, but it appears to do absolutely nothing.
Code:
{$CLEO}
0000:

REPEAT
    WAIT 69
UNTIL SAMP.Available()

var
2@ : string
3@ : string
6@ : int
7@ : int
8@ : int
end

$ANSWER == 53

WHILE TRUE
    WAIT 0
    0AC8: 2@ = 145
    0AC8: 3@ = 24
    0B75: samp get_chat_string 98 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@
                           
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d + %d + %d ?" $NUL2 6@ 7@ 8@
    THEN
        6@ += 7@
        6@ += 8@    
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d + %d ?" $NUL2 6@ 7@
    THEN
        6@ += 7@  
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END
          
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d - %d - %d ?" $NUL2 6@ 7@ 8@
    THEN
        6@ -= 7@
        6@ -= 8@  
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d - %d ?" $NUL2 6@ 7@
    THEN
        6@ -= 7@ 
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END
        
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d * %d ?" $NUL2 6@ 7@ 8@
    THEN
        6@ *= 7@
        6@ *= 8@  
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d ?" $NUL2 6@ 7@
    THEN
        6@ *= 7@  
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END
    
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d / %d / %d ?" $NUL2 6@ 7@ 8@
    THEN
        6@ /= 7@
        6@ /= 8@    
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END   
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d / %d ?" $NUL2 6@ 7@
    THEN
        6@ /= 7@
        //0AF9: samp say_msg "/answer %d" 6@ 
        008A: $ANSWER = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    END
    
    IF AND
        0AB0: key_pressed 53
        NOT $ANSWER == 53
    THEN 
        0AF9: samp say_msg "/answer %d" $ANSWER 
        $ANSWER = 53
        WAIT 10
    END
    
    0AC9: 2@
    0AC9: 3@
END
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
I can't fix your color codes since i don't know what colors/format your server uses. You could use cheatEngine to exactly find out.
About my code, what parts of it you don't understand?
 

HooThaFuck

Active member
Joined
Apr 18, 2015
Messages
51
Reaction score
0
springfield link said:
I can't fix your color codes since i don't know what colors/format your server uses. You could use cheatEngine to exactly find out.
About my code, what parts of it you don't understand?
1. I said the main color was 00FFFF as in 0x00FFFFFF. I also showed the exact like retrieved as shown in the chatlog file. The format is as shown.
2. I think I understand it after playing with it, but I don't know what I got wrong in my edited version of your code (shown above).
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Everything works, if it doesn't work with the server message then you have either wrong format or color codes.

Code:
{$CLEO}
0000:

REPEAT
    WAIT 69
UNTIL SAMP.Available()

var
2@ : string
3@ : string
6@ : int
7@ : int
8@ : int
end

30@ == 53

WHILE TRUE
    WAIT 0
    0AC8: 2@ = 145
    0AC8: 3@ = 24
    0B75: samp get_chat_string 98 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@
    
    //line 98 is not the last, are you sure it's ok?
                           
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d + %d + %d ?" $NUL2 6@ 7@ 8@
    THEN
        6@ += 7@
        6@ += 8@   
        008A: 30@ = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    ELSE
        IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d + %d ?" $NUL2 6@ 7@
        THEN
            6@ += 7@ 
            008A: 30@ = 6@
            0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
            WAIT 0
        ELSE        
            IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d - %d - %d ?" $NUL2 6@ 7@ 8@
            THEN
                6@ -= 7@
                6@ -= 8@ 
                008A: 30@ = 6@
                0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                WAIT 0
            ELSE
                IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d - %d ?" $NUL2 6@ 7@
                THEN
                    6@ -= 7@
                    008A: 30@ = 6@
                    0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                    WAIT 0
                ELSE  
                    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d * %d ?" $NUL2 6@ 7@ 8@
                    THEN
                        6@ *= 7@
                        6@ *= 8@                       
                        008A: 30@ = 6@
                        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                        WAIT 0
                    ELSE
                        IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d ?" $NUL2 6@ 7@
                        THEN
                            6@ *= 7@ 
                            008A: 30@ = 6@
                            0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                            WAIT 0
                        ELSE  
                            IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d / %d / %d ?" $NUL2 6@ 7@ 8@
                            THEN
                                6@ /= 7@
                                6@ /= 8@   
                                008A: 30@ = 6@
                                0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                                WAIT 0
                            ELSE 
                                IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d / %d ?" $NUL2 6@ 7@
                                THEN
                                    6@ /= 7@
                                    008A: 30@ = 6@
                                    0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                                    WAIT 0
                                END
                            END
                        END
                    END
                END
            END
        END
    END
   
    IF AND
        0AB0: key_pressed 53
        30@ <> 53
    THEN
        0AF9: samp say_msg "/answer %d" 30@
        30@ = 53
        WAIT 10
    END 
    0AC9: 2@
    0AC9: 3@
END
 

HooThaFuck

Active member
Joined
Apr 18, 2015
Messages
51
Reaction score
0
springfield link said:
Everything works, if it doesn't work with the server message then you have either wrong format or color codes.

Code:
{$CLEO}
0000:

REPEAT
    WAIT 69
UNTIL SAMP.Available()

var
2@ : string
3@ : string
6@ : int
7@ : int
8@ : int
end

30@ == 53

WHILE TRUE
    WAIT 0
    0AC8: 2@ = 145
    0AC8: 3@ = 24
    0B75: samp get_chat_string 98 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@
    
    //line 98 is not the last, are you sure it's ok?
                           
    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d + %d + %d ?" $NUL2 6@ 7@ 8@
    THEN
        6@ += 7@
        6@ += 8@   
        008A: 30@ = 6@
        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
        WAIT 0
    ELSE
        IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d + %d ?" $NUL2 6@ 7@
        THEN
            6@ += 7@ 
            008A: 30@ = 6@
            0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
            WAIT 0
        ELSE        
            IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d - %d - %d ?" $NUL2 6@ 7@ 8@
            THEN
                6@ -= 7@
                6@ -= 8@ 
                008A: 30@ = 6@
                0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                WAIT 0
            ELSE
                IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d - %d ?" $NUL2 6@ 7@
                THEN
                    6@ -= 7@
                    008A: 30@ = 6@
                    0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                    WAIT 0
                ELSE  
                    IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d * %d ?" $NUL2 6@ 7@ 8@
                    THEN
                        6@ *= 7@
                        6@ *= 8@                       
                        008A: 30@ = 6@
                        0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                        WAIT 0
                    ELSE
                        IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d * %d ?" $NUL2 6@ 7@
                        THEN
                            6@ *= 7@ 
                            008A: 30@ = 6@
                            0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                            WAIT 0
                        ELSE  
                            IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d / %d / %d ?" $NUL2 6@ 7@ 8@
                            THEN
                                6@ /= 7@
                                6@ /= 8@   
                                008A: 30@ = 6@
                                0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                                WAIT 0
                            ELSE 
                                IF 0AD4: $NUL = 2@ "Use {FF0000}%canswer{00FFFF} to solve this question: {FF00CC}%d / %d ?" $NUL2 6@ 7@
                                THEN
                                    6@ /= 7@
                                    008A: 30@ = 6@
                                    0AF8: samp add_message_to_chat "Answer = %d. Press 5 to send the answer." 0xFF00FFFF 6@
                                    WAIT 0
                                END
                            END
                        END
                    END
                END
            END
        END
    END
   
    IF AND
        0AB0: key_pressed 53
        30@ <> 53
    THEN
        0AF9: samp say_msg "/answer %d" 30@
        30@ = 53
        WAIT 10
    END 
    0AC9: 2@
    0AC9: 3@
END
It's still not working. And yes 98 is correct because another message is sent after the quiz line. Here is the test server:
Code:
#include <a_samp>
#include <strlib>
#include <YSI\y_commands>

main(){}

new Answer;

CMD:answer(playerid, params[])
{
	SendClientMessage(playerid, -1, sprintf("Your answer (%i) is %s.", strval(params), strval(params) == Answer ? ("correct") : ("incorrect")));
	return 1;
}

public OnPlayerConnect(playerid)
{
	GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
	return 1;
}

public OnPlayerSpawn(playerid)
{
	SetPlayerInterior(playerid, 0);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
   	return 1;
}

SetupPlayerForClassSelection(playerid)
{
 	SetPlayerInterior(playerid,14);
	SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
	SetPlayerFacingAngle(playerid, 270.0);
	SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
	SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}

public OnPlayerRequestClass(playerid, classid)
{
	SetupPlayerForClassSelection(playerid);
	return 1;
}

public OnGameModeInit()
{
	SetTimer("SendMessage", 25000, true);

	AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);

	return 1;
}

new MessageType;
forward SendMessage(); public SendMessage()
{
	new RandomNumber = random(10);
	switch(MessageType)
	{
		case 0:
		{
			Answer = 1 * 2 * RandomNumber;
			SendClientMessageToAll(0x00FFFFFF, sprintf("Use {FF0000}/answer{00FFFF} to solve this question: {FF00CC}%d * %d * %d ?", 1, 2, RandomNumber));
		}
		default:
		{
			Answer = 2 * RandomNumber;
			SendClientMessageToAll(0x00FFFFFF, sprintf("Use {FF0000}/answer{00FFFF} to solve this question: {FF00CC}%d * %d ?", 2, RandomNumber));
		}
	}
	MessageType++;
	if(MessageType == 3) MessageType = 0;
	
	SendClientMessageToAll(0x00FFFFFF, "Now solve it bitch.");
	return 1;
}
I used your exact code and it's like nothing happens at all. The server works fine, the correct answer message works and everything so it's just the mod's problem.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
The mod should work, by adding that line in the chat manually it works 100%, i don't see why it won't work..
Send me the server IP, i'll try for myself.
 

HooThaFuck

Active member
Joined
Apr 18, 2015
Messages
51
Reaction score
0
springfield link said:
The mod should work, by adding that line in the chat manually it works 100%, i don't see why it won't work..
Send me the server IP, i'll try for myself.
*** Removed ***
 
Status
Not open for further replies.
Top