|
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
the_snake Guest
Offline
|
Posted: Wed Feb 16, 2011 6:39 am Post subject: Random values from PDATA |
|
|
|
|
Hey,
I have this weird problem:
I load data onto a pdata struct
after it loads the output is this, which is correct:
Warbird: Level - 1, EXP - 200
Javelin: Level - 0, EXP - 0
Spider: Level - 0, EXP - 0
Leviathan: Level - 0, EXP - 0
Terrier: Level - 0, EXP - 0
Weasel: Level - 0, EXP - 0
Lancaster: Level - 0, EXP - 0
Shark: Level - 0, EXP - 0
Then I want to confirm the output by displaying it once more using a command ?mystats:
snake> ?mystats
Level - 1
Level - 0
Level - 15
Level - 1
Level - 0
Level - 0
Level - 0
Level - 0
then i wait a while(10 secs), doing nothing in the zone:
snake> ?mystats
Level - 1
Level - 0
Level - 77
Level - 97
Level - 11
Level - 1
Level - 0
Level - 0
and once more:
snake> ?mystats
Level - 1
Level - 0
Level - 77
Level - 164
Level - 36
Level - 1
Level - 0
Level - 0
the values seem to increase for some reason....
any idea why?
the struct is typedef struct MyPlayerData
{
int level[8];
int exp[8];
int oldship;
} MyPlayerData;
and i access it with:
local void ShowStats(const char *command, const char *params, Player *p, const Target *target)
{
MyPlayerData* pdata = PPDATA(p, playerKey);
if (pdata)
{
int i;
for (i=0;i<8;i++)
{
//if (pdata->level[i] > (start_level[i]))
chat->SendArenaMessage(p->arena,"Level - %i", pdata->level[i]);
}
}
}
|
thanks |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed Feb 16, 2011 7:07 am Post subject: |
|
|
|
|
Do you allocate the memory with amalloc? Make sure you use the size of the struct and not the size of a pointer to the struct.
Your access code looks fine to me, so lets see the init code. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
the_snake Guest
Offline
|
Posted: Wed Feb 16, 2011 7:34 am Post subject: |
|
|
|
|
this is embarrassing, but apparently while i was cleaning up my code, i had accidently deleted
playerKey = pd->AllocatePlayerData(sizeof(MyPlayerData));
thanks anyhow lol |
|
Back to top |
|
|
Arnk Kilo Dylie Seasoned Helper
Age:36 Gender: Joined: Jul 14 2006 Posts: 108 Offline
|
Posted: Wed Feb 16, 2011 4:41 pm Post subject: |
|
|
|
|
If you learn ACE, you can save yourself worrying about a lot of the init/deinit details like that. </shamelessplug> |
|
Back to top |
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 655 page(s) served in previous 5 minutes.
|