Raised This Month: $ Target: $400
 0% 

Three Dimensional Arrays


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ryo89589
Member
Join Date: Aug 2011
Old 08-07-2014 , 14:07   Three Dimensional Arrays
Reply With Quote #1

Some codes:
1.
PHP Code:
new SongsData[1024][9][512
2.
PHP Code:
/* Clear 'SongsData' */
SongsData "" 
3. Error 048: array dimensions do not match

How can I do? Thanks.
ryo89589 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 08-07-2014 , 14:22   Re: Three Dimensional Arrays
Reply With Quote #2

Explain better. What you trying to do.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ryo89589
Member
Join Date: Aug 2011
Old 08-07-2014 , 14:47   Re: Three Dimensional Arrays
Reply With Quote #3

Quote:
Originally Posted by ^SmileY View Post
Explain better. What you trying to do.
I want to clear "SoundsData".
For example:
PHP Code:
SoundsData[0][1][0] = "AbC"
SoundsData[3][2][0] = "cBa" 
When i cleared "SoundsData",
PHP Code:
SoundsData[0][1][0]: ""
SoundsData[3][2][0]: ""
SoundsData[0][0][0]: "" 
But it had some problem.
The problem in the first floor.
Thanks.
ryo89589 is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-07-2014 , 14:41   Re: Three Dimensional Arrays
Reply With Quote #4

Is Songsdata an array of ints, a 1024x9 array of strings (of length 512), what?
PreDominance is offline
ryo89589
Member
Join Date: Aug 2011
Old 08-07-2014 , 14:54   Re: Three Dimensional Arrays
Reply With Quote #5

Quote:
Originally Posted by PreDominance View Post
Is Songsdata an array of ints, a 1024x9 array of strings (of length 512), what?
SoundsData[sound counts][sound datas][Data]
Such as:
1.SoundsData[0][0] = "Song name"
2.SoundsData[0][1] = "Singer"
3.SoundsData[1][0] = "Song name2"
4.SoundsData[1][1] = "Singer2"
so i need many arrays.
ryo89589 is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 08-07-2014 , 14:53   Re: Three Dimensional Arrays
Reply With Quote #6

Idk
PHP Code:
    new SongsData[1024][9][512]
    for(new 
0sizeof(SongsData); x++)
    {
        for(new 
0sizeof(SongsData[]); y++)
        {
            for(new 
0sizeof(SongsData[][]); z++)
            {
                
SongsData[x][y][z] = 0
            
}
        }
    } 
__________________
Hey ^_^
NikKOo31 is offline
ryo89589
Member
Join Date: Aug 2011
Old 08-07-2014 , 14:58   Re: Three Dimensional Arrays
Reply With Quote #7

Quote:
Originally Posted by NikKOo31 View Post
Idk
PHP Code:
    new SongsData[1024][9][512]
    for(new 
0sizeof(SongsData); x++)
    {
        for(new 
0sizeof(SongsData[]); y++)
        {
            for(new 
0sizeof(SongsData[][]); z++)
            {
                
SongsData[x][y][z] = 0
            
}
        }
    } 
Thanks! Have other simple ways to do that?
if no, doesn't matter.
ryo89589 is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 08-07-2014 , 15:49   Re: Three Dimensional Arrays
Reply With Quote #8

Quote:
Originally Posted by ryo89589 View Post
Thanks! Have other simple ways to do that?
if no, doesn't matter.
PHP Code:
    new SongsData[1024][9][512]
    for(new 
0sizeof(SongsData); x++)
    {
        for(new 
0sizeof(SongsData[]); y++)
        {
            
SongsData[x][y][0] = '^0'
        
}
    } 
Or with enum
PHP Code:
enum Data
{
    
Name[32],
    
Singer[32]
}
#define MAXSONGS    32
new SongData[MAXSONGS][Data]


stock load_song(positiontitle[], author[])
{
    
copy(SongData[position][Name], charsmax(SongData[position][Name]), title)
    
copy(SongData[position][Singer], charsmax(SongData[position][Singer]), author)
}

stock delete_song(position)
{
    
SongData[position][Name][0] = '^0'
    
SongData[position][Singer][0] = '^0'
}

stock clear_songdata()
{
    for(new 
0MAXSONGSi++)
    {
        
SongData[i][Name][0] = '^0'
        
SongData[i][Singer][0] = '^0'
    
}

__________________
Hey ^_^

Last edited by NikKOo31; 08-07-2014 at 15:49.
NikKOo31 is offline
ryo89589
Member
Join Date: Aug 2011
Old 08-08-2014 , 00:36   Re: Three Dimensional Arrays
Reply With Quote #9

Quote:
Originally Posted by NikKOo31 View Post
PHP Code:
    new SongsData[1024][9][512]
    for(new 
0sizeof(SongsData); x++)
    {
        for(new 
0sizeof(SongsData[]); y++)
        {
            
SongsData[x][y][0] = '^0'
        
}
    } 
Or with enum
PHP Code:
enum Data
{
    
Name[32],
    
Singer[32]
}
#define MAXSONGS    32
new SongData[MAXSONGS][Data]


stock load_song(positiontitle[], author[])
{
    
copy(SongData[position][Name], charsmax(SongData[position][Name]), title)
    
copy(SongData[position][Singer], charsmax(SongData[position][Singer]), author)
}

stock delete_song(position)
{
    
SongData[position][Name][0] = '^0'
    
SongData[position][Singer][0] = '^0'
}

stock clear_songdata()
{
    for(new 
0MAXSONGSi++)
    {
        
SongData[i][Name][0] = '^0'
        
SongData[i][Singer][0] = '^0'
    
}

Thank you.
Code:
PHP Code:
enum Data
{
    
iName[64], 
    
iSinger[64], 
    
iURL[512], 
    
iSuggestGroup[64], 
    
iClientName[64], 
    
iClientAuthId[32], 
    
iClientIp[32], 
    
iDate[32], 
    
iState[2]
}
#define MAXSONGS    1024
new SongData[MAXSONGS][Data
PHP Code:
Read_ConfigFile()
{
    new 
iFile fopen(songs_file"rt")
    if(!
iFile) return
    
LoadedSongs 0
    
    
for(new 0MAXSONGSi++)
    {
        
SongData[i][iName][0] = '^0'
        
SongData[i][iSinger][0] = '^0'
        
SongData[i][iURL][0] = '^0'
        
SongData[i][iSuggestGroup][0] = '^0'
        
SongData[i][iClientName][0] = '^0'
        
SongData[i][iClientAuthId][0] = '^0'
        
SongData[i][iClientIp][0] = '^0'
        
SongData[i][iDate][0] = '^0'
        
SongData[i][iState][0] = '^0'
    
}
    
    new 
szText[1024]
    while(!
feof(iFile))
    {
        
fgets(iFileszTextcharsmax(szText))
        
trim(szText)
        
        if(!
szText[0] || szText[0] == '#' || szText[0] == ';' || (szText[0] == '/' && szText[1] == '/'))
            continue
        
        
parse(szText/* Line 95 */
            
SongData[LoadedSongs][iName], charsmax(SongData[LoadedSongs][iName]), 
            
SongData[LoadedSongs][iSinger], charsmax(SongData[LoadedSongs][iSinger]), 
            
SongData[LoadedSongs][iURL], charsmax(SongData[LoadedSongs][iURL]), 
            
SongData[LoadedSongs][iSuggestGroup], charsmax(SongData[LoadedSongs][iSuggestGroup]), 
            
SongData[LoadedSongs][iClientName], charsmax(SongData[LoadedSongs][iClientName]), 
            
SongData[LoadedSongs][iClientAuthId], charsmax(SongData[LoadedSongs][iClientAuthId]), 
            
SongData[LoadedSongs][iClientIp], charsmax(SongData[LoadedSongs][iClientIp]), 
            
SongData[LoadedSongs][iDate], charsmax(SongData[LoadedSongs][iDate]), 
            
SongData[LoadedSongs][iState], charsmax(SongData[LoadedSongs][iState]))
        
        
LoadedSongs ++
    }
    
fclose(iFile)

Error:
Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// hlmp_song_recommendation_system.sma
// ..\hlmp_song_recommendation_system.sma(95 -- 96) : error 001: expected token: "]", but found "-identifier-"
// ..\hlmp_song_recommendation_system.sma(96) : warning 217: loose indentation
// ..\hlmp_song_recommendation_system.sma(96) : error 029: invalid expression, assumed zero
// ..\hlmp_song_recommendation_system.sma(96) : error 029: invalid expression, assumed zero
// ..\hlmp_song_recommendation_system.sma(96) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
// Could not locate output file compiled\hlmp_song_recommendation_system.amx (compile failed).
//
// Compilation Time: 0.47 sec
// ----------------------------------------

Press enter to exit ...
But I can not understand the error in code, please help me check.
Thank you.

Last edited by ryo89589; 08-08-2014 at 00:37.
ryo89589 is offline
ryo89589
Member
Join Date: Aug 2011
Old 08-08-2014 , 07:52   Re: Three Dimensional Arrays
Reply With Quote #10

Quote:
Originally Posted by ryo89589 View Post
Thank you.
Code:
PHP Code:
enum Data
{
    
iName[64], 
    
iSinger[64], 
    
iURL[512], 
    
iSuggestGroup[64], 
    
iClientName[64], 
    
iClientAuthId[32], 
    
iClientIp[32], 
    
iDate[32], 
    
iState[2]
}
#define MAXSONGS    1024
new SongData[MAXSONGS][Data
PHP Code:
Read_ConfigFile()
{
    new 
iFile fopen(songs_file"rt")
    if(!
iFile) return
    
LoadedSongs 0
    
    
for(new 0MAXSONGSi++)
    {
        
SongData[i][iName][0] = '^0'
        
SongData[i][iSinger][0] = '^0'
        
SongData[i][iURL][0] = '^0'
        
SongData[i][iSuggestGroup][0] = '^0'
        
SongData[i][iClientName][0] = '^0'
        
SongData[i][iClientAuthId][0] = '^0'
        
SongData[i][iClientIp][0] = '^0'
        
SongData[i][iDate][0] = '^0'
        
SongData[i][iState][0] = '^0'
    
}
    
    new 
szText[1024]
    while(!
feof(iFile))
    {
        
fgets(iFileszTextcharsmax(szText))
        
trim(szText)
        
        if(!
szText[0] || szText[0] == '#' || szText[0] == ';' || (szText[0] == '/' && szText[1] == '/'))
            continue
        
        
parse(szText/* Line 95 */
            
SongData[LoadedSongs][iName], charsmax(SongData[LoadedSongs][iName]), 
            
SongData[LoadedSongs][iSinger], charsmax(SongData[LoadedSongs][iSinger]), 
            
SongData[LoadedSongs][iURL], charsmax(SongData[LoadedSongs][iURL]), 
            
SongData[LoadedSongs][iSuggestGroup], charsmax(SongData[LoadedSongs][iSuggestGroup]), 
            
SongData[LoadedSongs][iClientName], charsmax(SongData[LoadedSongs][iClientName]), 
            
SongData[LoadedSongs][iClientAuthId], charsmax(SongData[LoadedSongs][iClientAuthId]), 
            
SongData[LoadedSongs][iClientIp], charsmax(SongData[LoadedSongs][iClientIp]), 
            
SongData[LoadedSongs][iDate], charsmax(SongData[LoadedSongs][iDate]), 
            
SongData[LoadedSongs][iState], charsmax(SongData[LoadedSongs][iState]))
        
        
LoadedSongs ++
    }
    
fclose(iFile)

Error:
Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// hlmp_song_recommendation_system.sma
// ..\hlmp_song_recommendation_system.sma(95 -- 96) : error 001: expected token: "]", but found "-identifier-"
// ..\hlmp_song_recommendation_system.sma(96) : warning 217: loose indentation
// ..\hlmp_song_recommendation_system.sma(96) : error 029: invalid expression, assumed zero
// ..\hlmp_song_recommendation_system.sma(96) : error 029: invalid expression, assumed zero
// ..\hlmp_song_recommendation_system.sma(96) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
// Could not locate output file compiled\hlmp_song_recommendation_system.amx (compile failed).
//
// Compilation Time: 0.47 sec
// ----------------------------------------

Press enter to exit ...
But I can not understand the error in code, please help me check.
Thank you.
Have anyone help me?
ryo89589 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:11.


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