AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] 3d dynamic array (https://forums.alliedmods.net/showthread.php?t=308614)

CrazY. 06-27-2018 11:12

[ H3LP ] 3d dynamic array
 
Hello, I'm getting some trouble with 3d arrays. This is the code I'm using:

Code:
enum _:eKnifeSounds {     SND_KNIFE_DEPLOY = 0,     SND_KNIFE_DEPLOY1,     SND_KNIFE_HIT1,     SND_KNIFE_HIT2,     SND_KNIFE_HIT3,     SND_KNIFE_HIT4,     SND_KNIFE_WALL1,     SND_KNIFE_WALL2,     SND_KNIFE_SLASH1,     SND_KNIFE_SLASH2,     SND_KNIFE_STAB, }; new const g_szKnivesSounds[][eKnifeSounds][] = {     { "boxing_deploy1", "boxing_deploy1", "boxing_hit1", "boxing_hit2", "boxing_hit3", "boxing_hit4",     "boxing_hitwall1", "boxing_hitwall1", "boxing_slash1", "boxing_slash2", "boxing_stab" } }

Output:
Code:

sound/weapons/oy1.wav
sound/weapons/.wav
sound/weapons/all1.wav
sound/weapons/h1.wav
sound/weapons/h2.wav


edon1337 06-27-2018 11:36

Re: [ H3LP ] 3d dynamic array
 
And what is the problem? This?
Code:
sound/weapons/oy1.wav sound/weapons/.wav sound/weapons/all1.wav sound/weapons/h1.wav sound/weapons/h2.wav

CrazY. 06-27-2018 11:58

Re: [ H3LP ] 3d dynamic array
 
What I expected was:

Code:

sound/weapons/boxing_deploy1
sound/weapons/boxing_deploy1
sound/weapons/boxing_hit1
sound/weapons/boxing_hit2
sound/weapons/boxing_hit3
sound/weapons/boxing_hit4
sound/weapons/boxing_hitwall1
sound/weapons/boxing_hitwall2
sound/weapons/boxing_slash1
sound/weapons/boxing_slash2
sound/weapons/boxing_stab


Bugsy 06-27-2018 12:01

Re: [ H3LP ] 3d dynamic array
 
You only need a 2d
new g_szKnivesSounds[eKnifeSounds][]

CrazY. 06-27-2018 12:08

Re: [ H3LP ] 3d dynamic array
 
I believe I need 3d. Here's how I'm using:

Code:
enum _:eKnife {     KNIFE_NAME[32],     KNIFE_SOUND, }; enum _:eKnifeSounds {     SND_KNIFE_DEPLOY = 0,     SND_KNIFE_DEPLOY1,     SND_KNIFE_HIT1,     SND_KNIFE_HIT2,     SND_KNIFE_HIT3,     SND_KNIFE_HIT4,     SND_KNIFE_WALL1,     SND_KNIFE_WALL2,     SND_KNIFE_SLASH1,     SND_KNIFE_SLASH2,     SND_KNIFE_STAB, }; // -1, emit default CS knife sounds new const g_rgKnives[][eKnife] = {     { "Default Knife", -1 },     { "Boxing Gloves", 0 // g_szKnivesSounds[0][eKnifeSounds] },     { "Example", 1 // g_szKnivesSounds[1][eKnifeSounds] } }; new const g_szKnivesSounds[][eKnifeSounds][] = {     { "boxing_deploy1", "boxing_deploy1", "boxing_hit1", "boxing_hit2", "boxing_hit3", "boxing_hit4",     "boxing_hitwall1", "boxing_hitwall1", "boxing_slash1", "boxing_slash2", "boxing_stab" },         { "example_deploy1", "example_deploy1", "example_hit1", "example_hit2", "example_hit3", "example_hit4",     "example_hitwall1", "example_hitwall1", "example_slash1", "example_slash2", "example_stab" } }

edon1337 06-27-2018 12:14

Re: [ H3LP ] 3d dynamic array
 
Show part of the code where KNIFE_SOUND is used and how you output

CrazY. 06-27-2018 12:17

Re: [ H3LP ] 3d dynamic array
 
Code:
for (new i = 0; i < sizeof g_szKnivesSounds; i++) {     for (new s = SND_KNIFE_DEPLOY; s <= SND_KNIFE_STAB; s++)     {         formatex(szSound, charsmax(szSound), "weapons/%s.wav", g_szKnivesSounds[i][s]);         server_print("g_szKnivesSounds[%d][%d] = %s", i, s, szSound);         //precache_sound(szSound);     } }

Spoiler

Ghosted 06-27-2018 12:24

Re: [ H3LP ] 3d dynamic array
 
I Think At

Code:

formatex(szSound, charsmax(szSound), "weapons/%s.wav", g_szKnivesSounds[g_rgKnives[iKnifeId][KNIFE_SOUND]][iSoundId])
This:

Code:

g_szKnivesSounds[g_rgKnives[iKnifeId][KNIFE_SOUND]][iSoundId]
Should Be:

Code:

g_szKnivesSounds[iKnifeId][iSoundId]
(If not then please paste full source code :_ )

CrazY. 06-27-2018 12:27

Re: [ H3LP ] 3d dynamic array
 
The problem is not in emit sound, the problem is in 3d array. g_rgKnives[iKnifeId][KNIFE_SOUND] is nothing more than the sound index that I set in g_rgKnives.

Ghosted 06-27-2018 12:32

Re: [ H3LP ] 3d dynamic array
 
Quote:

Originally Posted by CrazY. (Post 2599544)
The problem is not in emit sound, the problem is in 3d array. g_rgKnives[iKnifeId][KNIFE_SOUND] is nothing more than the sound index that I set in g_rgKnives.

Can you post full source code? :3


All times are GMT -4. The time now is 12:41.

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