How to create "Press F to enter the building"
#4

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.

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);
}
That is far better than checking point ranges every time even if the player is not even near a point.
Reply


Messages In This Thread
How to create "Press F to enter the building" - by Nostrum - 01.05.2013, 18:19
Re: How to create "Press F to enter the building" - by RandomDude - 01.05.2013, 18:24
Re: How to create "Press F to enter the building" - by Emmet_ - 01.05.2013, 18:27
Re: How to create "Press F to enter the building" - by Pottus - 01.05.2013, 18:42
Re: How to create "Press F to enter the building" - by Scenario - 01.05.2013, 18:44
Re: How to create "Press F to enter the building" - by Pottus - 01.05.2013, 19:13
Re: How to create "Press F to enter the building" - by Scenario - 01.05.2013, 19:41

Forum Jump:


Users browsing this thread: 1 Guest(s)