SA-MP Forums Archive
MP3 Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MP3 Help (/showthread.php?tid=420284)



MP3 Help - YahyaBR - 04.03.2013

Hello, i wanna make a mp3 menu on my server
but it doesn't work, it doesn't show any menu ingame
no error message, idk what's the problem
here is the code
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>


public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" MP3 Player By [BR]Yahya");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mp3", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "MP3", "nRevenge - A Minecraft Parody of Usher's DJ got us fallin' love\nOppa Gangnam Style - PSY\nMine - Minecraft Parody of Fly (Nicki Minaj)\nWelcome to the jungle - GunN'Roses\nDiamond - Rihanna\nET - Katy Perry\nLeave out all the rest - Linkin Park\nIn The End - Linkin Park\nTNT - A Minecraft Parody of Cruz's Dynamite ", "Play", "Cancel");
        return 1;
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1 && response == 1)
    {
        if(response)
        {

            if(listitem == 0)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/7w7a3fidp9/index_php_mp3_Revenge_A_Minecraft_Parody_of_Usher39s_DJ_Got_Us_Fallin39_in_Love_Crafted_Using_Noteblocks_uuid_5134801c706f0.mp3");
            }
            if(listitem == 1)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/773tu1e8l0/index_php_mp3_PSY_GANGNAM_STYLE_MV_uuid_51348296226c0.mp3");
            }
            if(listitem == 2)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/x3r01d6p8c/index_php_mp3_Mine_A_Minecraft_Parody_of_Nicki_Minaj_ft_Rihanna_Fly_uuid_513484d6adef9.mp3");
            }
            if(listitem == 3)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/q8094d58co/index_php_mp3_Guns_N39_Roses_Welcome_To_The_Jungle_uuid_5134871586759.mp3");
            }
            if(listitem == 4)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/voumwb62zr/index_php_mp3_Rihanna_Diamonds_uuid_5134879e6cc20.mp3");
            }
            if(listitem == 5)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/zdlzk0i0j1/index_php_mp3_Katy_Perry_ET_ft_Kanye_West_uuid_51348850c3c94.mp3");
            }
            if(listitem == 6)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/0sjb0e69m9/index_php_mp3_Linkin_Park_Leave_Out_All_The_Rest_HQ_uuid_51348a2ca3392.mp3");
            }
            if(listitem == 7)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/17fal7h7lv/index_php_mp3_Linkin_Park_In_The_End_uuid_51348b31072da.mp3");
            }
            if(listitem == 8)
            {
                 PlayAudioStreamForPlayer(playerid,"http://k007.kiwi6.com/hotlink/18efm789q0/tnt_-_a_minecraft_parody_of_taio_cruz_s_dynamite_-_crafted_using_note_blocks_-_*******_1.mp3");
            }
        }
        return 1;
    }
    return 0;
}
and if you do like to help me, can you explain what does 1 or 0 mean on "return 1;"?
thanks


Re: MP3 Help - YahyaBR - 04.03.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
Use "y_commands" for commands (or one of several other command processors), not "strcmp".
i got this error
Код:
D:\Bart\Samp Server\filterscripts\MP3.pwn(18) : error 017: undefined symbol "y_commands"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: MP3 Help - Threshold - 04.03.2013

First of all...
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mp3", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "MP3", "nRevenge - A Minecraft Parody of Usher's DJ got us fallin' love\nOppa Gangnam Style - PSY\nMine - Minecraft Parody of Fly (Nicki Minaj)\nWelcome to the jungle - GunN'Roses\nDiamond - Rihanna\nET - Katy Perry\nLeave out all the rest - Linkin Park\nIn The End - Linkin Park\nTNT - A Minecraft Parody of Cruz's Dynamite ", "Play", "Cancel");
        return 1;
    }
    return 1;
}
Basically, the '10' you've inserted into this line, means the LENGTH OF THE STRING, in this case /mp3 is not 10 cells long, it's 4... so really, you can just remove this, leaving you with:
pawn Код:
if(strcmp(cmdtext, "/mp3", true) == 0)
Secondly, your OnPlayerCommandText should return 0, not 1. If it returns 0, and the command does not exist, it will show this to the player: "SERVER: Unknown Command". However, if you return 1, it means the command exists.

So your finished code will be:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mp3", cmdtext, true) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "MP3", "nRevenge - A Minecraft Parody of Usher's DJ got us fallin' love\nOppa Gangnam Style - PSY\nMine - Minecraft Parody of Fly (Nicki Minaj)\nWelcome to the jungle - GunN'Roses\nDiamond - Rihanna\nET - Katy Perry\nLeave out all the rest - Linkin Park\nIn The End - Linkin Park\nTNT - A Minecraft Parody of Cruz's Dynamite ", "Play", "Cancel");
        return 1;
    }
    return 0;
}
However, I would also take ******' recommendation into account, as there are much more efficient command processors, like y_commands for example...


Re: MP3 Help - YahyaBR - 04.03.2013

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
First of all...
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mp3", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "MP3", "nRevenge - A Minecraft Parody of Usher's DJ got us fallin' love\nOppa Gangnam Style - PSY\nMine - Minecraft Parody of Fly (Nicki Minaj)\nWelcome to the jungle - GunN'Roses\nDiamond - Rihanna\nET - Katy Perry\nLeave out all the rest - Linkin Park\nIn The End - Linkin Park\nTNT - A Minecraft Parody of Cruz's Dynamite ", "Play", "Cancel");
        return 1;
    }
    return 1;
}
Basically, the '10' you've inserted into this line, means the LENGTH OF THE STRING, in this case /mp3 is not 10 cells long, it's 4... so really, you can just remove this, leaving you with:
pawn Код:
if(strcmp(cmdtext, "/mp3", true) == 0)
Secondly, your OnPlayerCommandText should return 0, not 1. If it returns 0, and the command does not exist, it will show this to the player: "SERVER: Unknown Command". However, if you return 1, it means the command exists.

So your finished code will be:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mp3", cmdtext, true) == 0)
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "MP3", "nRevenge - A Minecraft Parody of Usher's DJ got us fallin' love\nOppa Gangnam Style - PSY\nMine - Minecraft Parody of Fly (Nicki Minaj)\nWelcome to the jungle - GunN'Roses\nDiamond - Rihanna\nET - Katy Perry\nLeave out all the rest - Linkin Park\nIn The End - Linkin Park\nTNT - A Minecraft Parody of Cruz's Dynamite ", "Play", "Cancel");
        return 1;
    }
    return 0;
}
However, I would also take ******' recommendation into account, as there are much more efficient command processors, like y_commands for example...
Thank you very much, it works
Quote:

LENGTH OF THE STRING

btw, what is string, and how to know the lenght

Quote:

/mp3 is not 10 cells long, it's 4

and how to know how long is the cell? thanks before


Re: MP3 Help - YahyaBR - 04.03.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
This is pretty much exactly why I told you to use a different command processor - so you don't need to worry about string lengths etc.
hmm, im still noob in scripting, what command processor you mean?
how to change the command processor?

sorry for asking too much question