01.05.2013, 18:42
This way will work but is not very efficient if you have a lot of areas your better off using using the streamer plugin and adding areas in there then doing this.
That is far better than checking point ranges every time even if the player is not even near a point.
pawn Код:
#define INVALID_AREA_ID (0xFFFF)
new CurrArea[MAX_PLAYERS] = { INVALID_AREA_ID, ... };
new myarea1, myarea2, myarea3;
public OnGameModeInit()
{
myarea1 = CreateDynamicSphere(1.0, 1.0, 1.0, 2.0);
myarea2 = CreateDynamicSphere(1.0, 1.0, 1.0, 2.0);
myarea3 = CreateDynamicSphere(1.0, 1.0, 1.0, 2.0);
}
public OnPlayerEnterDynamicArea(playerid, areaid) { CurrArea[playerid] = areaid; }
public OnPlayerLeaveDynamicArea(playerid, areaid) { CurrArea[playerid] = INVALID_AREA_ID ; }
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_SECONDARY_ATTACK)
{
if(CurrArea[playerid] != INVALID_AREA_ID)
{
switch(CurrArea[playerid])
{
case myarea1: { SetPlayerPosEx(playerid, 0.0, 0.0, 0.0, 0.0, 0, 0); }
case myarea2: { SetPlayerPosEx(playerid, 0.0, 0.0, 0.0, 0.0, 0, 0); }
case myarea3: { SetPlayerPosEx(playerid, 0.0, 0.0, 0.0, 0.0, 0, 0); }
}
}
}
return 1;
}
stock SetPlayerPosEx(playerid, Float:x, Float:y, Float:z, Float:fa, vw, int)
{
SetPlayerPos(playerid, x, y, z);
SetPlayerFacingAngle(playerid, fa);
SetPlayerVirtualWorld(playerid, vw);
SetPlayerInterior(playerid, int);
SetCameraBehindPlayer(playerid);
}