Server Help

Bot Questions - Player Position Detection

tec27 - Sat Feb 01, 2003 9:25 pm
Post subject: Player Position Detection
I'm using mervbot and I was trying to figure out how to make it so that every time a there was a player in a square area on the map, it would start a timer. Any ideas on how to do it?
SOS - Sun Feb 02, 2003 4:31 am
Post subject:
EVENT_PlayerMove
Check player's position there (p->tile.x and p->tile.y)
k0zy - Sun Feb 02, 2003 4:32 am
Post subject:
a very easy way is to use the playermove event in spawn.cpp

Code: Show/Hide
case EVENT_PlayerMove:
{
Player *p = (Player*)event.p[0];

if ((p->tile.x == 512) && (p->tile.y == 512))
{
sendPublic("*timer 5");
}

}


This will start the timer when a player cosses the "center" of a map.

Damn, sos was faster... biggrin.gif

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
tec27 - Mon Feb 03, 2003 7:22 am
Post subject:
thanks, both of you, it was very helpful.
ExplodyThingy - Tue Feb 04, 2003 12:21 pm
Post subject:
Can you make it so that a player can only send a command within a block of tiles? It seems to ignore it in a rectanle, but works on a specific tile. (both are within the player level command case in commands.cpp
work:
Code: Show/Hide
if ((p->tile.x == 512) && (p->tile.y == 512))
{
    if(c->check("command")
    {
           sendPrivate(p,"command recieved");
    }
}

No work:
Code: Show/Hide
if (  ((p->tile.x >> 510) && (p->tile.y >> 510))   &&   ((p->tile.x << 514) && (p->tile.y << 514))   )
{
    if(c->check("command")
    {
           sendPrivate(p,"command recieved");
    }
}


This isnt cut-and-paste, so ignore missing ";" and such junk.
k0zy - Tue Feb 04, 2003 12:59 pm
Post subject:
Its simply "<", and not "<<"...
Try that icon_smile.gif

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
SOS - Tue Feb 04, 2003 2:22 pm
Post subject:
Haha sa_tongue.gif
Mine GO BOOM - Tue Feb 04, 2003 2:52 pm
Post subject:
This is a generic sample of code for checking if some point X, Y is inside a rectangle:

Code: Show/Hide
if (x >= X_MIN && x <= X_MAX && y >= Y_MIN && y <= Y_MAX)

ExplodyThingy - Tue Feb 04, 2003 2:58 pm
Post subject:
Yes, yes, thank you. I got myself tripped up on == and >= and somehow i carried it over to >>.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group