AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ArrayGetString (https://forums.alliedmods.net/showthread.php?t=317392)

Fuck For Fun 07-10-2019 15:57

ArrayGetString
 
PHP Code:

L 07/10/2019 03:05:27Invalid index 919119408 (count0)
L 07/10/2019 03:05:27: [AMXXDisplaying debug trace (plugin "jailbreak_lastrequest.amxx")
L 07/10/2019 03:05:27: [AMXXRun time error 10native error (native "ArrayGetString")
L 07/10/2019 03:05:27: [AMXX]    [0jailbreak_lastrequest.sma::StopLR (line 3682)
L 07/10/2019 03:05:27: [AMXX]    [1jailbreak_lastrequest.sma::TaskStopLR (line 3671

Code:

public TaskStopLR(Data[])
{
        StopLR(Data[0]);
}

StopLR(pWinner = 0)
{
        if (g_iLRRunning)
        {
                if (pWinner != 0)
                {
                        new iLen, szSound[64], iMinPlayers;

                        ArrayGetString(g_arrayWinSounds, random(ArraySize(g_arrayWinSounds)), szSound, charsmax(szSound)); // here

                        iMinPlayers = get_pcvar_num(jb_keys_min_players);
                        iLen = strlen(szSound);

                        if (szSound[iLen - 3] == 'm' && szSound[iLen - 2] == 'p' && szSound[iLen - 1] == '3')
                                client_cmd(0, "mp3 play ^"sound/%s^"", szSound);
                        else
                                client_cmd(0, "spk ^"%s^"", szSound);

                        if (GetPlayersNum("ch") >= iMinPlayers)
                        {
                                switch(random_num(1, 10))
                                {
                                        case 1:
                                        {
                                                g_iKeys[pWinner] += 1;
                                                jb_client_print(pWinner, "Congrulations! You won^4 1 Key^1 and stayed with^3 %i Key(s)^1.", g_iKeys[pWinner]);
                                        }
                                        default:
                                        {
                                                jb_client_print(pWinner, "Sorry, you didn't win any Key. Good luck next time!");
                                        }
                                }
                        }
                        else
                        {
                                jb_client_print(pWinner, "^4*%d players^1 must be online to get^3 key^1.", iMinPlayers);
                        }
                }


EFFx 07-10-2019 16:48

Re: ArrayGetString
 
Try replacing with random_num(0, ArraySize(g_arrayWinSounds) - 1), also, make sure that the array has size.

Natsheh 07-10-2019 17:03

Re: ArrayGetString
 
The dynamic array is empty.....

Check if it has a size bigger than 0.

Fuck For Fun 07-11-2019 03:05

Re: ArrayGetString
 
Quote:

Originally Posted by EFFx (Post 2658680)
Try replacing with random_num(0, ArraySize(g_arrayWinSounds) - 1), also, make sure that the array has size.

Quote:

Originally Posted by Natsheh (Post 2658683)
The dynamic array is empty.....

Check if it has a size bigger than 0.

that the array of sound, And maybe the problem is that I'm using a low SIZE
Code:

PrecacheSoundArray(Array:arrayHandle)
{
        if (arrayHandle == Invalid_Array)
                return;

        new i, iSoundCount, szSound[16];

        iSoundCount = ArraySize(arrayHandle);

        for (i = 0; i < iSoundCount; i++)
        {
                ArrayGetString(arrayHandle, i, szSound, charsmax(szSound));
                precache_sound(szSound);
        }
}



All times are GMT -4. The time now is 17:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.