18.07.2013, 20:57
i want to make a /enter at ammunation and cluckin bell
how?
how?
i want like public OnPlayerCommandText(playerid, cmdtext[])
{ if(!strcmp("/enter", cmdtext)) { SetPlayerInterior(playerid, 5); SetPlayerPos(playerid, 372.5565, -131.3607, 1001.4922); SetPlayerShopName(playerid,"FDPIZA"); SendClientMessage(playerid,0xFFFFFFFF,"Welcome to Pizza Stack!"); return 1; } return 0; } |
if(strcmp("/enter", cmdtext, true, 10) == 0)
{
if(PlayerToPoint(15.0, playerid, 0.0, 0.0, 0.0 )) // Paste the shop's coordinates to 0.0's.
{
SetPlayerInterior(playerid, 5);
SetPlayerPos(playerid, 372.5565, -131.3607, 1001.4922);
SetPlayerShopName(playerid,"FDPIZA");
SendClientMessage(playerid,0xFFFFFFFF,"Welcome to Pizza Stack!");
}
return 1;
}
PlayerToPoint is slow. Use IsPlayerInRangeOfPoint instead of PlayerToPoint.
|
#include <a_samp>
#include <streamer>
#include <zcmd>
// Define invalid dynamic areas
#define INVALID_DYNAMIC_AREA -1
// Maximum number of enterable points
#define MAX_ENTER_POINTS 10
// Enter/exit point types
#define ENTER_POINT_ENTER 0
#define ENTER_POINT_EXIT 1
// Current area player is in
new CurrDynamicArea[MAX_PLAYERS] = { -1, ... };
// Enter point enum
enum EPOINTDATA
{
AreaID,
EType,
Float:DestX,
Float:DestY,
Float:DestZ,
Float:DestFA,
VWorld,
Interior,
}
// Enter point variable
new EnterPoint[MAX_ENTER_POINTS][EPOINTDATA];
public OnFilterScriptInit()
{
for(new i = 0; i < MAX_ENTER_POINTS; i++) { EnterPoint[i][AreaID] = -1; }
// This is not a real point only used for testing delete
AddEnterPoint(100.0, 100.0, 100.0, 200.0, 200.0, 200.0, 0.0, 2.0, ENTER_POINT_ENTER, 1, 1);
AddEnterPoint(200.0, 200.0, 200.0, 100.0, 100.0, 100.0, 0.0, 2.0, ENTER_POINT_EXIT, 0, 0);
return 1;
}
// Player entered a dynamic area record the areaid
public OnPlayerEnterDynamicArea(playerid, areaid)
{
CurrDynamicArea[playerid] = areaid;
return 1;
}
// Player left a dynamic area set to INVALID_DYNAMIC_AREA
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
CurrDynamicArea[playerid] = INVALID_DYNAMIC_AREA;
return 1;
}
// Player disconencted set to INVALID_DYNAMIC_AREA for that player
public OnPlayerDisconnect(playerid, reason)
{
CurrDynamicArea[playerid] = INVALID_DYNAMIC_AREA;
return 1;
}
// Add a new point
stock AddEnterPoint(Float:EX, Float:EY, Float:EZ, Float:DX, Float:DY, Float:DZ, Float:DFA, Float:size, Type, VW, INTER)
{
// Find an empty array slot
for(new i = 0; i < MAX_ENTER_POINTS; i++)
{
if(EnterPoint[i][AreaID] != INVALID_DYNAMIC_AREA)
{
// Create dynamic area for point
EnterPoint[i][AreaID] = CreateDynamicSphere(EX, EY, EZ, size);
// Record destination data
EnterPoint[i][DestX] = DX;
EnterPoint[i][DestX] = DY;
EnterPoint[i][DestX] = DZ;
EnterPoint[i][DestX] = DFA;
EnterPoint[i][EType] = Type;
EnterPoint[i][VWorld] = VW;
EnterPoint[i][Interior] = INTER;
return i;
}
}
// Too many points increate the array size
print("Error: Tried too add too many enter/exit points");
return INVALID_DYNAMIC_AREA;
}
// Delete a enter point
stock DeleteEnterPoint(index)
{
// Is there actually an area?
if(EnterPoint[index][AreaID] != INVALID_DYNAMIC_AREA)
{
// Destroy and reset ENUM (No need to set actual enum data)
DestroyDynamicArea(EnterPoint[index][AreaID]);
EnterPoint[index][AreaID] = INVALID_DYNAMIC_AREA;
return 1;
}
print("Error: Tried to remove an invalid enter/exit point");
return INVALID_DYNAMIC_AREA;
}
// Get the enter point array ID of the player
stock GetEnterPointID(playerid, Type)
{
for(new i = 0; i < MAX_ENTER_POINTS; i++)
{
// Wrong type of enter/exit point
if(EnterPoint[i][EType] != Type) continue;
// Player found the area array reference
if(EnterPoint[i][AreaID] == CurrDynamicArea[playerid]) return i;
}
// Player is not in different enter point
return INVALID_DYNAMIC_AREA;
}
// Enter command
CMD:enter(playerid, arg[])
{
PlayerEnterPoint(playerid, ENTER_POINT_ENTER);
return 1;
}
// Exit command
CMD:exit(playerid, arg[])
{
PlayerEnterPoint(playerid, ENTER_POINT_EXIT);
return 1;
}
// Player typed enter
stock PlayerEnterPoint(playerid, Type)
{
// Only check if they are at an enter point if they are in an actual area
if(CurrDynamicArea[playerid] != INVALID_DYNAMIC_AREA)
{
// Get the array reference for the players current area
new eref = GetEnterPointID(playerid, Type);
// Found a match set the players position etc
if(eref != INVALID_DYNAMIC_AREA)
{
SetPlayerPos(playerid, EnterPoint[eref][DestX], EnterPoint[eref][DestY], EnterPoint[eref][DestZ]);
SetPlayerFacingAngle(playerid, EnterPoint[eref][DestFA]);
SetPlayerVirtualWorld(playerid, EnterPoint[eref][VWorld]);
SetPlayerInterior(playerid, EnterPoint[eref][Interior]);
SetCameraBehindPlayer(playerid);
}
}
return 1;
}