Little Help
#1

Hello everybody today I get strange bug with my song inventory system I don`t know why..So problem is when I use song by command /usesong [SLOT] example slot 1 and there is song Hollywood Undead - Undead in Audio debug text it`s wrtted Hollywood Undead - Undead. Anyone know why here is the code:
pawn Код:
new InventoryItems[MAX_ITEMS][] = {
    {0, "Sidney Samson and Martin Garrix - Torrent", "http://k007.kiwi6.com/hotlink/s65e1e3suc/Sidney_Samson_and_Martin_Garrix_-_Torrent_mp3cut.net_.mp3"},
    {1, "Avicii - Wake Me Up", "http://k007.kiwi6.com/hotlink/nudyhhx2fv/Avicii_-_Avicii_-_Wake_Me_Up_mp3cut.net_.mp3"},
    {2, "Die Antwoord - Rich Bitch", "http://k007.kiwi6.com/hotlink/rzw3kc240h/Die_Antwoord_-_Rich_Bitch_mp3cut.net_.mp3"},
    {3, "Calvin Harris feat. Alesso and Hurts - Under Control", "http://k007.kiwi6.com/hotlink/6zctrsw8uf/Calvin_Harris_and_Alesso_-_Under_Control_ft._Hurts_mp3cut.net_1_.mp3"},
    {4, "Martin Garrix - Animals", "http://k007.kiwi6.com/hotlink/hoz1u3oca1/Martin_Garrix_-_Animals_Official_Video_mp3cut.net_1_.mp3"},
    {5, "Hollywood Undead - Undead", "http://k007.kiwi6.com/hotlink/aj6ybbw6d1/Hollywood_Undead_-_Undead_mp3cut.net_.mp3"}
};
stock OnPlayerUseItem(playerid,slot)
{
    new songstr[200];
    switch(InventoryItems[iItem[playerid][slot]][0])
    {
        case 0:
        {
            format(songstr,sizeof(songstr),"%s",InventoryItems[0][0]);
            PlayAudioStreamForPlayer(playerid, songstr);
        }
        case 1:
        {
           
        }
        case 2:
        {
           
        }
        case 3:
        {
           
        }
        case 4:
        {

        }
        case 5:
        {
            format(songstr,sizeof(songstr),"%s",InventoryItems[5][2]);
            PlayAudioStreamForPlayer(playerid, songstr);
        }
    }
    return 1;
}
Here is screen shot how it looks:
Reply
#2

pawn Код:
format(songstr,sizeof(songstr),"%s",InventoryItems[5][2]);
to

pawn Код:
format(songstr,sizeof(songstr),"%s",InventoryItems[0][1]);
Reply
#3

PHP код:
new InventoryItems[MAX_ITEMS][] = {
    {
0"Sidney Samson and Martin Garrix - Torrent""http://k007.kiwi6.com/hotlink/s65e1e3suc/Sidney_Samson_and_Martin_Garrix_-_Torrent_mp3cut.net_.mp3"},
    {
1"Avicii - Wake Me Up""http://k007.kiwi6.com/hotlink/nudyhhx2fv/Avicii_-_Avicii_-_Wake_Me_Up_mp3cut.net_.mp3"},
    {
2"Die Antwoord - Rich Bitch""http://k007.kiwi6.com/hotlink/rzw3kc240h/Die_Antwoord_-_Rich_Bitch_mp3cut.net_.mp3"},
    {
3"Calvin Harris feat. Alesso and Hurts - Under Control""http://k007.kiwi6.com/hotlink/6zctrsw8uf/Calvin_Harris_and_Alesso_-_Under_Control_ft._Hurts_mp3cut.net_1_.mp3"},
    {
4"Martin Garrix - Animals""http://k007.kiwi6.com/hotlink/hoz1u3oca1/Martin_Garrix_-_Animals_Official_Video_mp3cut.net_1_.mp3"},
    {
5"Hollywood Undead - Undead""http://k007.kiwi6.com/hotlink/aj6ybbw6d1/Hollywood_Undead_-_Undead_mp3cut.net_.mp3"}
};
stock OnPlayerUseItem(playerid,slot)
{
    new 
songstr[200];
    switch(
InventoryItems[iItem[playerid][slot]][0])
    {
        case 
0:
        {
            
format(songstr,sizeof(songstr),"%s",InventoryItems[0][0]);
            
PlayAudioStreamForPlayer(playeridsongstr);
        }
        case 
1:
        {
            
        }
        case 
2:
        {
            
        }
        case 
3:
        {
            
        }
        case 
4:
        {
        }
        case 
5:
        {
            
format(songstr,sizeof(songstr),"%s",InventoryItems[0][1]);
            
PlayAudioStreamForPlayer(playeridsongstr);
        }
    }
    return 
1;

REP IF I HELPED
Reply
#4

Quote:
Originally Posted by arlindi
Посмотреть сообщение
PHP код:
new InventoryItems[MAX_ITEMS][] = {
    {
0"Sidney Samson and Martin Garrix - Torrent""http://k007.kiwi6.com/hotlink/s65e1e3suc/Sidney_Samson_and_Martin_Garrix_-_Torrent_mp3cut.net_.mp3"},
    {
1"Avicii - Wake Me Up""http://k007.kiwi6.com/hotlink/nudyhhx2fv/Avicii_-_Avicii_-_Wake_Me_Up_mp3cut.net_.mp3"},
    {
2"Die Antwoord - Rich Bitch""http://k007.kiwi6.com/hotlink/rzw3kc240h/Die_Antwoord_-_Rich_Bitch_mp3cut.net_.mp3"},
    {
3"Calvin Harris feat. Alesso and Hurts - Under Control""http://k007.kiwi6.com/hotlink/6zctrsw8uf/Calvin_Harris_and_Alesso_-_Under_Control_ft._Hurts_mp3cut.net_1_.mp3"},
    {
4"Martin Garrix - Animals""http://k007.kiwi6.com/hotlink/hoz1u3oca1/Martin_Garrix_-_Animals_Official_Video_mp3cut.net_1_.mp3"},
    {
5"Hollywood Undead - Undead""http://k007.kiwi6.com/hotlink/aj6ybbw6d1/Hollywood_Undead_-_Undead_mp3cut.net_.mp3"}
};
stock OnPlayerUseItem(playerid,slot)
{
    new 
songstr[200];
    switch(
InventoryItems[iItem[playerid][slot]][0])
    {
        case 
0:
        {
            
format(songstr,sizeof(songstr),"%s",InventoryItems[0][0]);
            
PlayAudioStreamForPlayer(playeridsongstr);
        }
        case 
1:
        {
            
        }
        case 
2:
        {
            
        }
        case 
3:
        {
            
        }
        case 
4:
        {
        }
        case 
5:
        {
            
format(songstr,sizeof(songstr),"%s",InventoryItems[0][1]);
            
PlayAudioStreamForPlayer(playeridsongstr);
        }
    }
    return 
1;

REP IF I HELPED
Lol. You're not going to get rep for basically quoting what I just said.

Also @OP:

pawn Код:
switch(InventoryItems[iItem[playerid][slot]][0])
    {
        case 0:
        {
            format(songstr,sizeof(songstr),"%s",InventoryItems[0][0]);
            PlayAudioStreamForPlayer(playerid, songstr);
        }
Won't work, you'll have to add a positive value (not 0) for whatever row you want to call.
Reply
#5

i think it should be format(songstr,sizeof(songstr),"%s",InventoryItems[0][3]);
because link is in the 3rd parameter in the array
Reply
#6

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
i think it should be format(songstr,sizeof(songstr),"%s",InventoryItems[0][3]);
because link is in the 3rd parameter in the array
Ye I tried that too but then is lliwood Undead writted I don`t know why.. . Anyone can help me?
Reply
#7

pawn Код:
enum e_InventoryItems
{
    II_Song[53],
    II_URL[110]
};

new InventoryItems[][e_InventoryItems] = {
    {"Sidney Samson and Martin Garrix - Torrent",               "http://k007.kiwi6.com/hotlink/s65e1e3suc/Sidney_Samson_and_Martin_Garrix_-_Torrent_mp3cut.net_.mp3"},
    {"Avicii - Wake Me Up",                                     "http://k007.kiwi6.com/hotlink/nudyhhx2fv/Avicii_-_Avicii_-_Wake_Me_Up_mp3cut.net_.mp3"},
    {"Die Antwoord - Rich Bitch",                               "http://k007.kiwi6.com/hotlink/rzw3kc240h/Die_Antwoord_-_Rich_Bitch_mp3cut.net_.mp3"},
    {"Calvin Harris feat. Alesso and Hurts - Under Control",    "http://k007.kiwi6.com/hotlink/6zctrsw8uf/Calvin_Harris_and_Alesso_-_Under_Control_ft._Hurts_mp3cut.net_1_.mp3"},
    {"Martin Garrix - Animals",                                 "http://k007.kiwi6.com/hotlink/hoz1u3oca1/Martin_Garrix_-_Animals_Official_Video_mp3cut.net_1_.mp3"},
    {"Hollywood Undead - Undead",                               "http://k007.kiwi6.com/hotlink/aj6ybbw6d1/Hollywood_Undead_-_Undead_mp3cut.net_.mp3"}
};
Check the "slot" parameter from the command if it's valid and use it as index:
pawn Код:
if (0 <= slot < sizeof (InventoryItems))
{
    PlayAudioStreamForPlayer(playerid, InventoryItems[slot][II_URL]);
}
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
enum e_InventoryItems
{
    II_Song[53],
    II_URL[110]
};

new InventoryItems[][e_InventoryItems] = {
    {"Sidney Samson and Martin Garrix - Torrent",               "http://k007.kiwi6.com/hotlink/s65e1e3suc/Sidney_Samson_and_Martin_Garrix_-_Torrent_mp3cut.net_.mp3"},
    {"Avicii - Wake Me Up",                                     "http://k007.kiwi6.com/hotlink/nudyhhx2fv/Avicii_-_Avicii_-_Wake_Me_Up_mp3cut.net_.mp3"},
    {"Die Antwoord - Rich Bitch",                               "http://k007.kiwi6.com/hotlink/rzw3kc240h/Die_Antwoord_-_Rich_Bitch_mp3cut.net_.mp3"},
    {"Calvin Harris feat. Alesso and Hurts - Under Control",    "http://k007.kiwi6.com/hotlink/6zctrsw8uf/Calvin_Harris_and_Alesso_-_Under_Control_ft._Hurts_mp3cut.net_1_.mp3"},
    {"Martin Garrix - Animals",                                 "http://k007.kiwi6.com/hotlink/hoz1u3oca1/Martin_Garrix_-_Animals_Official_Video_mp3cut.net_1_.mp3"},
    {"Hollywood Undead - Undead",                               "http://k007.kiwi6.com/hotlink/aj6ybbw6d1/Hollywood_Undead_-_Undead_mp3cut.net_.mp3"}
};
Check the "slot" parameter from the command if it's valid and use it as index:
pawn Код:
if (0 <= slot < sizeof (InventoryItems))
{
    PlayAudioStreamForPlayer(playerid, InventoryItems[slot][II_URL]);
}
pawn Код:
if (0 <= slot < sizeof (InventoryItems))
I don`t understand this line. What you want to say if slot is in minus then what?
Reply
#9

Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)