Server Help

ASSS Custom Projects - Problem with "Adding Commands" module.

gilder - Mon Sep 04, 2006 9:08 am
Post subject: Problem with "Adding Commands" module.
I started studying module writing two days ago with Dev-C++ 4.9.9.2 (Windows XP Pro).

I copied "Adding commands" code from:

http://wiki.minegoboom.com/index.php/Writing_Modules_In_C#Adding_Commands

The module doesn't say anything when i type ?getplayers, but ?help getplayers will show the help text properly. Can you help me?
Dr Brain - Mon Sep 04, 2006 9:48 am
Post subject:
You need to add either cmd_getplayers or privcmd_getplayers (or both, depending on what you're donig) to one of the files in conf/groupdef.dir/ so the zone knows who's allowed to use it.
gilder - Mon Sep 04, 2006 9:58 am
Post subject:
Thanks. Didn't read those instructions well...
gilder - Tue Sep 05, 2006 5:30 am
Post subject:
I'll post a little new question here, so i don't have to make new topic.

I was trying to warp powerball with PlaceBall function, but the ball just disappeared after a few seconds.

Code: Show/Hide

local Iballs *balls;

...

    ArenaBallData data;
   
    data.balls->state=BALL_ONMAP;
    data.balls->x=512;
    data.balls->y=512;
    data.balls->xspeed=0;
    data.balls->yspeed=0;
    data.balls->carrier=NULL;
    data.balls->freq=1;
    data.balls->time=0;
   
    balls->PlaceBall(p->arena, 1, &(data.balls));


linker also gives an error (PlaceBall line): WARNING: passing arg 3 of pointer to function from incompatible pointer type.
Dr Brain - Tue Sep 05, 2006 7:46 am
Post subject:
Sounds like you're not passing the correct struct to it. Check the PlaceBall prototype in balls.h (I'm too lazy).
gilder - Tue Sep 05, 2006 8:17 am
Post subject:
Code: Show/Hide
void (*PlaceBall)(Arena *arena, int bid, struct BallData *newpos);
   /* sets the parameters of the ball to those in the given BallData
    * struct */
   /* pyint: arena, int, balldata -> void */


I can't find anything wrong there.
i88gerbils - Tue Sep 05, 2006 10:00 am
Post subject:
Don't you have to pass the pointer directly and not the value?
gilder - Tue Sep 05, 2006 2:29 pm
Post subject:
Now the server started crashing.

After a few test times i noticed the following:

Code: Show/Hide

    ArenaBallData* data;
   
    data->balls->x=512*16;
    data->balls->y=512*16;
    data->balls->xspeed=0;
    data->balls->yspeed=0;
    data->balls->carrier=NULL;
    data->balls->freq=0;
    data->balls->time=0;
    data->balls->state=BALL_ONMAP;
   
    balls->PlaceBall(p->arena, 1, data->balls);

The ball will be warped, you can see the ball only in big radar (Alt) and server crashes after few seconds.


Code: Show/Hide

    ArenaBallData* data;
   
    data->balls->x=512*16;
    data->balls->y=512*16;
    data->balls->xspeed=0;
    data->balls->yspeed=0;
    data->balls->carrier=NULL;
    data->balls->freq=0;
    data->balls->time=0;
    data->balls->state=BALL_ONMAP;

Server crashes


Code: Show/Hide

    ArenaBallData* data;
   
    data->balls->x=512*16;
    data->balls->y=512*16;
    data->balls->xspeed=0;
    data->balls->yspeed=0;
    data->balls->carrier=NULL;
    data->balls->freq=0;
    data->balls->time=0;


nothing happends


Code: Show/Hide

    ArenaBallData* data;
   
    data->balls->x=512*16;
    data->balls->y=512*16;
    data->balls->xspeed=0;
    data->balls->yspeed=0;
    data->balls->carrier=NULL;
    data->balls->freq=0;
    data->balls->time=0;

    balls->PlaceBall(p->arena, 1, data->balls);

nothing happends


"data->balls->state=BALL_ONMAP;" seems to crash the zone.
Mine GO BOOM - Tue Sep 05, 2006 2:32 pm
Post subject:
Number one, you are overriding memory. ArenaBallData's balls is a pointer to struct Balls and not a memory space in itself. So you are clobbering data with that. Try this instead:
Code: Show/Hide
struct BallData data;

data.state=BALL_ONMAP;
data.x=512;
data.y=512;
data.xspeed=0;
data.yspeed=0;
data.carrier=NULL;
data.freq=1;
data.time=0;

balls->PlaceBall(p->arena, 1, &data);

If you really wanted to use ArenaBallData for this:
Code: Show/Hide
ArenaBallData data;

data.balls = (struct Balls*)amalloc(sizeof(struct Balls));
data.balls->state=BALL_ONMAP;
data.balls->x=512;
data.balls->y=512;
data.balls->xspeed=0;
data.balls->yspeed=0;
data.balls->carrier=NULL;
data.balls->freq=1;
data.balls->time=0;

balls->PlaceBall(p->arena, 1, data.balls);
afree(data.balls);

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group