CLEO Help shorten commands cleo

CLEO related
Status
Not open for further replies.

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
This should create an audio stream to %s, where %s is a URL to the song, but instead %s == (null) and it then unregisters the command.

Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
0B34: samp register_client_command "play1" to_label @Label163 
30@ = 0 

:Label23
wait 0 
if 
  30@ == 1 
else_jump @Label23 
   SAMP.IsCommandTyped(0@)
if 
0AD4: $PLAYER_CHAR = scan_string 0@ format "%s" 1@v  
else_jump @Label23 
jump @Label96 

:Label96
wait 30@  
say "/radio %s" 1@v 
jump @Label241 

:Label163
30@ = 1 
SAMP.CmdRet
jump @Label23  

:Label241
31@ = 0 
30@ = 0 
SAMP.CmdRet
jump @Label23

Any idea where I'm going wrong?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
maybe using global variable $Player_char at 0AD4 causes problems, or "say" opcode does not allow string formatting, you could try it like this

Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
0B34: samp register_client_command "play1" to_label @command
30@ = 0 

:Label
wait 0 
if 
 30@ == 1 
else_jump @Label
30@ = 0
SAMP.IsCommandTyped(0@)
  
    if
    0AD4: 31@ = scan_string 0@ format "%s" 1@v  
    then
    0AD3: 6@v = format "/radio %s" 1@v
    say 6@v 
    end 
jump @Label  

:command
30@ = 1 
SAMP.CmdRet
btw this code is a bit like Fred Flinstone's car, you can drive it but you have to run anyway. And that's what this code does. It sends a /radio command with a parameter but you have to type /play1 with the same parameter anyway.
Idk exactly what's the idea behind it but if it aims at automatically typing the url or name of the radio station then you could do something like this:
Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
0B34: samp register_client_command "play" to_label @command
30@ = 0 

:Label
wait 0 
if 
 30@ == 1 
else_jump @Label
30@ = 0
SAMP.IsCommandTyped(0@)
  
    if
    0AD4: 31@ = scan_string 0@ format "%d" 29@  
    then
        if 29@ == 1
        then  
        say "/radio Los Santos"            
        end
        
        if 29@ == 2
        then
        say "/radio Lady Gaga"
        end
        
        if 29@ == 3
        then
        say "/radio yourmusic.com/titanicthemesong"
        end           
    end 
jump @Label  

:command
30@ = 1 
SAMP.CmdRet
this way all you would type is /play 1 and it would automatically send /radio Los Santos command
 

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
monday said:
maybe using global variable $Player_char at 0AD4 causes problems, or "say" opcode does not allow string formatting, you could try it like this

Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
0B34: samp register_client_command "play1" to_label @command
30@ = 0 

:Label
wait 0 
if 
 30@ == 1 
else_jump @Label
30@ = 0
SAMP.IsCommandTyped(0@)
  
    if
    0AD4: 31@ = scan_string 0@ format "%s" 1@v  
    then
    0AD3: 6@v = format "/radio %s" 1@v
    say 6@v 
    end 
jump @Label  

:command
30@ = 1 
SAMP.CmdRet
btw this code is a bit like Fred Flinstone's car, you can drive it but you have to run anyway. And that's what this code does. It sends a /radio command with a parameter but you have to type /play1 with the same parameter anyway.
Idk exactly what's the idea behind it but if it aims at automatically typing the url or name of the radio station then you could do something like this:
Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
0B34: samp register_client_command "play" to_label @command
30@ = 0 

:Label
wait 0 
if 
 30@ == 1 
else_jump @Label
30@ = 0
SAMP.IsCommandTyped(0@)
  
    if
    0AD4: 31@ = scan_string 0@ format "%d" 29@  
    then
        if 29@ == 1
        then  
        say "/radio Los Santos"            
        end
        
        if 29@ == 2
        then
        say "/radio Lady Gaga"
        end
        
        if 29@ == 3
        then
        say "/radio yourmusic.com/titanicthemesong"
        end           
    end 
jump @Label  

:command
30@ = 1 
SAMP.CmdRet
this way all you would type is /play 1 and it would automatically send /radio Los Santos command

I'm trying to accomplish this:

Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
0B34: samp register_client_command "play" to_label @command
30@ = 0 

:Label
wait 0 
if 
30@ == 1 
else_jump @Label
30@ = 0
SAMP.IsCommandTyped(0@)
 
   if
   0AD4: 31@ = scan_string 0@ format "%s" 29@  
   then
       say "/radio 6t.pe/?%s"
       printf "%s" 500           
   end 
jump @Label  

:command
30@ = 1 
SAMP.CmdRet

Where %s is a YouTube link, 6t.pe/? will convert the song and stream it, so I'd only need to type something like:
/play https://www.youtube.com/watch?v=U32pZRsr1UQ

Then it will convert and stream. Any idea how this could be done or is it not possible in cleo?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
oh sorry I thought it was the feature on the server you play. Here's a snippet posted by spiceman on blast.hk:
Code:
0AC8: 0@ = allocate_memory_size SizeUri
0AD3: 0@ = format "someUri"
// exp: 0AD3: 0@ = format "http:%c%cmysite.com%ctrack-1.mp3" 0x2F 0x2F 0x2F
0AB1: @PlayAudioStream 1 uri 0@
wait 50
0AB1: @StopAudioStream 0

Code:
:PlayAudioStream
// 0AB1: @PlayAudioStream 1 uri 1@
0C17: 1@ = strlen 0@
 
2@ = RakNet.NewBitStream()
RakNet.Write(2@, 1@, BS_TYPE_BYTE, 0x01) // Длина строки
RakNet.Write(2@, 0@, BS_TYPE_ARRAY, 1@) // URI записи
for 1@ = 0 to 0xE
    RakNet.Write(2@, 0x00, BS_TYPE_BYTE, 0x01)
end
RakNet.Write(2@, 0x48, BS_TYPE_BYTE, 0x1)
RakNet.Write(2@, 0x42, BS_TYPE_BYTE, 0x1)
RakNet.Write(2@, 0x00, BS_TYPE_BYTE, 0x1)
0BF6: raknet emul_rpc_receive 0x29 bit_stream 2@
RakNet.DeleteBitStream(2@)
0AB2: ret 0
 
:StopAudioStream
0@ = RakNet.NewBitStream()
0BF6: raknet emul_rpc_receive 0x2A bit_stream 0@
RakNet.DeleteBitStream(0@)
0AB2: ret 0
 

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
monday said:
oh sorry I thought it was the feature on the server you play. Here's a snippet posted by spiceman on blast.hk:
Code:
0AC8: 0@ = allocate_memory_size SizeUri
0AD3: 0@ = format "someUri"
// exp: 0AD3: 0@ = format "http:%c%cmysite.com%ctrack-1.mp3" 0x2F 0x2F 0x2F
0AB1: @PlayAudioStream 1 uri 0@
wait 50
0AB1: @StopAudioStream 0

Code:
:PlayAudioStream
// 0AB1: @PlayAudioStream 1 uri 1@
0C17: 1@ = strlen 0@
 
2@ = RakNet.NewBitStream()
RakNet.Write(2@, 1@, BS_TYPE_BYTE, 0x01) // Длина строки
RakNet.Write(2@, 0@, BS_TYPE_ARRAY, 1@) // URI записи
for 1@ = 0 to 0xE
    RakNet.Write(2@, 0x00, BS_TYPE_BYTE, 0x01)
end
RakNet.Write(2@, 0x48, BS_TYPE_BYTE, 0x1)
RakNet.Write(2@, 0x42, BS_TYPE_BYTE, 0x1)
RakNet.Write(2@, 0x00, BS_TYPE_BYTE, 0x1)
0BF6: raknet emul_rpc_receive 0x29 bit_stream 2@
RakNet.DeleteBitStream(2@)
0AB2: ret 0
 
:StopAudioStream
0@ = RakNet.NewBitStream()
0BF6: raknet emul_rpc_receive 0x2A bit_stream 0@
RakNet.DeleteBitStream(0@)
0AB2: ret 0

The audio stream is processed by the server I play, just not the converting.

For example, I can type /radio https://6t.pe/?https://www.youtube.com/watch?v=4WH0bFYg3Wo and it will be streamed. I just wanted to shorten that to something like /play https://www.youtube.com/watch?v=4WH0bFYg3Wo by copying the YouTube link and using "say" to type the full command. Is that possible? I can't seem to get %s to store links.
 
Status
Not open for further replies.
Top