08.01.2011, 16:42
Quote:
I understand now how that would work, but i don't know whats wrong. I set that up and i still don't receive any message when a enter that area.
|
pawn Код:
#undef MAX_PLAYERS
#define MAX_SLOTS 500 //Max players of your server
#define MAX_PLAYERS MAX_SLOTS //If you wanna use MAX_PLAYERS instead of MAX_SLOTS...
#define CB:%0(%1) forward %0(%1); public %0(%1) //Now you don't need to forward for every custom callback. Juse use CB:Callbackname(params)
new bool:IsPInBankArea[MAX_PLAYERS] = false;
public OnFilterScriptInit() //Use OnGameModeInit if it's an gamemode
{
SetTimer("CheckPlayerArea", 1000, true);
return 1;
}
public OnPlayerConnect(playerid)
{
IsPInBankArea[playerid] = false;
return 1;
}
CB:CheckPlayerArea()
{
for(new i = 0; i < MAX_SLOTS; i++){
if(IsPlayerInArea(i, 1717.8574, 1725.7787, -1650.3363, -1659.9257)){
if(!IsPInBankArea[i]){
IsPInBankArea[i] = true;
SendClientMessage(i, COLOR_GREEN, "Welcome to the bank!");
}
}
if(!IsPlayerInArea(i, 1717.8574, 1725.7787, -1650.3363, -1659.9257)){
if(IsPInBankArea[i]){
IsPInBankArea[i] = false;
SendClientMessage(i, COLOR_GREEN, "You left the bank");
}
}
}
return 1;
}
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
return 0;
}
Because it can also be MinX,MinY,MaxX,MaxY instead of MinX,MaxX,MinY,MaxY
- Kevin