AlliedModders

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

AoD90 04-27-2011 15:23

enum problem
 
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...

SonicSonedit 04-27-2011 15:28

Re: enum problem
 
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?

AoD90 04-27-2011 15:40

Re: enum problem
 
Have no clue :)

SonicSonedit 04-27-2011 15:43

Re: enum problem
 
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̎ͮ.

Arkshine 04-27-2011 15:51

Re: enum problem
 
His enum is about data structures, not contants.

SonicSonedit 04-27-2011 15:56

Re: enum problem
 
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.

Arkshine 04-27-2011 15:59

Re: enum problem
 
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.

AoD90 04-27-2011 16:01

Re: enum problem
 
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

SonicSonedit 04-27-2011 16:04

Re: enum problem
 
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?

ConnorMcLeod 04-27-2011 16:09

Re: enum problem
 
Try to use copy() native.


All times are GMT -4. The time now is 04:25.

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