Raised This Month: $ Target: $400
 0% 

enum problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AoD90
Senior Member
Join Date: Jul 2008
Location: Ugljevik/RS/BIH
Old 04-27-2011 , 15:23   enum problem
Reply With Quote #1

I have new problem...

PHP Code:
enum _:PlayerData
{
    
Ime[35],
    
AuthID[35],
    
UserID,
    
Skill
}

enum _:SubData
{
    
sUser[35],
    
sAuthID[35],
    
sSkill,
    
uAuthID[35]
}

new 
g_ePlayerData[35][PlayerData]
new 
g_eSubData[35][SubData
Now, if I have this
g_ePlayerData[i][Ime] = "smt"
g_eSubData[j][sUser] = "another"

and if I do
g_ePlayerData[i][Ime] = g_eSubData[j][sUser]

than my g_ePlayerData[i][Ime] is "amt".

How can I fix this...
AoD90 is offline
Send a message via MSN to AoD90
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-27-2011 , 15:28   Re: enum problem
Reply With Quote #2

What do you think code
PHP Code:
enum _:PlayerData
{
    
Ime[35],
    
AuthID[35],
    
UserID,
    
Skill
}

enum _:SubData
{
    
sUser[35],
    
sAuthID[35],
    
sSkill,
    
uAuthID[35]

does?
__________________


Last edited by SonicSonedit; 04-27-2011 at 15:33.
SonicSonedit is offline
AoD90
Senior Member
Join Date: Jul 2008
Location: Ugljevik/RS/BIH
Old 04-27-2011 , 15:40   Re: enum problem
Reply With Quote #3

Have no clue
AoD90 is offline
Send a message via MSN to AoD90
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-27-2011 , 15:43   Re: enum problem
Reply With Quote #4

I thought so
Please read this http://wiki.amxmodx.org/index.php/Pawn_Tutorial#Arrays the section about arrays (link) and strings (right after arrays)
And about enum - it declares and auto-calculates variables.

PHP Code:
enum
{
    
MYVAR1,
    
MYVAR2,
    
MYVAR99,
    
MYVAR7,
    
ILOVEHOTDOGS,
    
HAHA

will create new variables and set their values: MYVAR1=0, MYVAR2=1, MYVAR99=2, MYVAR7=3, ILOVEHOTDOGS=4, HAHA=5

And what you did will s͖̦͔͎̎ú̼͎͍m̗̥͚̯̼̜͂̃̾̌̔m̦̱̳͉̯͔ͮ͌̌ͭͤo̳̯̝͔͚̤̎̐͢ ͔n ̹̗̺̙̋ͦ͌c̶ͩ̿t̚҉͙̱̪̗̦ḧ̥̟̯͇̳̦́ͅụ̰̹̤̝̞̣̂ͥ̓̌̌̆l̓͡ ̟̺̘̩̠͍̩ḩ͎͉̤̯̬̙ͨ͂̍͊ͣͥ̀u̎ͮ.
__________________


Last edited by SonicSonedit; 04-27-2011 at 15:49.
SonicSonedit is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2011 , 15:51   Re: enum problem
Reply With Quote #5

His enum is about data structures, not contants.
__________________
Arkshine is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-27-2011 , 15:56   Re: enum problem
Reply With Quote #6

Arkshine
So, pawn does have a structures? Because when i read wiki, it said pawn is based on small doesn't have structures or classes.
__________________

SonicSonedit is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2011 , 15:59   Re: enum problem
Reply With Quote #7

Pseudo-structure, ugly hack but working. It's limited but you can do like he does. There is a tutorial and few posts about the use of data structures, you may search.
__________________
Arkshine is offline
AoD90
Senior Member
Join Date: Jul 2008
Location: Ugljevik/RS/BIH
Old 04-27-2011 , 16:01   Re: enum problem
Reply With Quote #8

It works well with eg. AuthID but with g_ePlayerData[i][Ime] = g_eSubData[j][sUser] just replaces first letter of g_ePlayerData[i][Ime] with first letter of g_eSubData[j][sUser].

Btw I was looking at http://forums.alliedmods.net/showthread.php?t=140103

Last edited by AoD90; 04-27-2011 at 16:03.
AoD90 is offline
Send a message via MSN to AoD90
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-27-2011 , 16:04   Re: enum problem
Reply With Quote #9

Arkshine
Thank you. I surely will. AoD90's error is caused by some incorrect memory access, then. Is it because he incorrect string length, invalid assignment or just because its an ugly hack?
__________________

SonicSonedit is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-27-2011 , 16:09   Re: enum problem
Reply With Quote #10

Try to use copy() native.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 04:25.


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