Raised This Month: $ Target: $400
 0% 

Three Dimensional Arrays


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 08-07-2014 , 15:49   Re: Three Dimensional Arrays
Reply With Quote #1

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 #2

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 #3

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