Creating gates doors in samp
105 ready-made objects for movement
Include in your code and begin using the library:
#include <easy-barrier>
new barrierid = BarrierCreate("Police_Department", 3.0, 0.5, 0,
19302,
24.637180, -8.755125, 3.397187, 0.000000, 0.000000, 86.175994, 0, 0);
SetBarrierTypeOpening(barrierid, BARRIER_MOVEMENT_TYPE_RIGHT);
// plus attach
new barrierid2 = BarrierCreate("Police_Department", 3.0, 0.5, 0,
19302,
24.637180, -6.755125, 3.397187, 0.000000, 0.000000, 86.175994, 0, 0);
SetBarrierTypeOpening(barrierid2, BARRIER_MOVEMENT_TYPE_LEFT);
AttachBarrierToBarrier(barrierid, barrierid2);
BarrierResponse:Police_Department(playerid, barrierid)
{
if(GetPlayerSkin(playerid) != 283)
{
SendClientMessage(playerid, 0xFF0000AA, "Only for cops");
return 1;
}
SendClientMessage(playerid, -1, "barrier for police open");
return 0;
}
//optional
forward OnBarrierObjectCreated(barrierid, objectid, modelid);
public OnBarrierObjectCreated(barrierid, objectid, modelid)
{
switch(modelid)
{
case 968:
{
SetDynamicObjectMaterial(objectid, 1, 3306, "cunte_house1", "sw_patiodoors", 0);
}
}
return 1;
}
forward OnBarrierEnter(playerid, barrierid, keys);
public OnBarrierEnter(playerid, barrierid, keys)
{
new string[27+32+10],
function[32];
GetBarrierFunctionName(barrierid, function);
format(string, sizeof(string), "Barrier Enter: %d | %d | %s", barrierid, keys, function);
SendClientMessage(playerid, -1, string);
return 1;
}
forward OnBarrierLeave(playerid, barrierid);
public OnBarrierLeave(playerid, barrierid)
{
new string[22+32+10],
function[32];
GetBarrierFunctionName(barrierid, function);
format(string, sizeof(string), "Barrier Leave: %d | %s", barrierid, function);
SendClientMessage(playerid, -1, string);
return 1;
}
BarrierCreate(const function[], Float:radius, Float:move_speed, closing_seconds, modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, barrier_state = BARRIER_STATE_PLAYER_AND_DRIVER, const text3d[] = "", color = -1, Float:text3d_distance = 3.0, Float:trigger_x = 0.0, Float:trigger_y = 0.0, Float:trigger_z = 0.0, key = 0)
Create a barrier
function[]
- Function nameFloat:radius
- Trigger distanceFloat:move_speed
- The speed at which to move the object (units per second)closing_seconds
- Closing time (use the value 0, for manual opening/closing)modelid
- The modelFloat:x
- The x coordinate to create the objectFloat:y
- The y coordinate to create the objectFloat:z
- The z coordinate to create the objectFloat:rx
- The x rotation of the objectFloat:ry
- The y rotation of the objectFloat:rz
- The z rotation of the objectworldid
- The virtual world IDinteriorid
- The interior IDbarrier_state
- Barrier statustext3d[]
- 3DTextcolor
- 3DText colorFloat:text3d_distance
- 3DText draw distanceFloat:trigger_x
- The x coordinate to trigger zoneFloat:trigger_y
- The y coordinate to trigger zoneFloat:trigger_z
- The z coordinate to trigger zonekey
- Interaction button- Returns (-1) on failure or (barrier id)
Remove the barrier
barrierid
- The ID of the barrier- Returns (-1) on failure or barrier id
Open the barrier
barrierid
- The ID of the barrier- Returns (-1) on failure or (1) on success
Close the barrier
barrierid
- The ID of the barrier- Returns (-1) on failure or (1) on success
Get the barrier status
barrierid
- The ID of the barrier- Returns (0) if closed, (1) if open, (-1) if failed
Set the type of movement
barrierid
- The ID of the barriertype
- Type of movementpercent
- Prcentage of movement- Returns (-1) on failure or (1) on success
Set the movement by the x coordinate
barrierid
- The ID of the barrierFloat:x
- The x coordinate- Returns (-1) on failure or (1) on success
Set the movement by the y coordinate
barrierid
- The ID of the barrierFloat:y
- The y coordinate- Returns (-1) on failure or (1) on success
Set the movement by the z coordinate
barrierid
- The ID of the barrierFloat:z
- The z coordinate- Returns (-1) on failure or (1) on success
Set the movement by the rx coordinate
barrierid
- The ID of the barrierFloat:rx
- The rx coordinate- Returns (-1) on failure or (1) on success
Set the movement by the ry coordinate
barrierid
- The ID of the barrierFloat:ry
- The ry coordinate- Returns (-1) on failure or (1) on success
Set the movement by the rz coordinate
barrierid
- The ID of the barrierFloat:rz
- The x coordinate- Returns (-1) on failure or (1) on success
Set the positions of the moving object
barrierid
- The ID of the barrierFloat:x
- The x coordinateFloat:y
- The y coordinateFloat:z
- The z coordinateFloat:rx
- The x rotation of the objectFloat:ry
- The y rotation of the objectFloat:rz
- The z rotation of the object- Returns (-1) on failure or (1) on success
Attach barrier to barrier
barrierid
- The ID of the barrierattachid
- The ID of the barrier to attach- Returns (-1) on failure or (1) on success
UnAttach the barrier from the barrier
barrierid
- The ID of the barrierattachid
- The ID of the barrier to attach- Returns (-1) on failure or (1) on success
Set barrier closing time
barrierid
- The ID of the barrierseconds[]
- Closing time (use the value 0, for manual opening/closing)- Returns (-1) on failure or (1) on success
Get barrier closing time
barrierid
- The ID of the barrier- Returns (-1) on failure or (second)
Set the speed of a moving object
barrierid
- The ID of the barrierFloat:speed
- The speed at which to move the object (units per second)- Returns (-1) on failure or (1) on success
Get the speed of a moving object
barrierid
- The ID of the barrier- Returns (-1) on failure or (speed)
Set trigger zone
barrierid
- The ID of the barrierFloat:x
- The x coordinate to trigger zoneFloat:y
- The y coordinate to trigger zoneFloat:z
- The z coordinate to trigger zone- Returns (-1) on failure or (1) on success
Get trigger zone
barrierid
- The ID of the barrier&Float:x
- The x coordinate to trigger zone&Float:y
- The y coordinate to trigger zone&Float:z
- The z coordinate to trigger zone- Returns (-1) on failure or (1) on success
SetBarrierTriggerExtra(barrierid, Float:x, Float:y, Float:z, Float:radius, barrier_state = BARRIER_STATE_PLAYER_ONLY, key = BARRIER_KEY_STATE_ONFOOT)
Set trigger extra
barrierid
- The ID of the barrierFloat:x
- The x coordinate to trigger zoneFloat:y
- The y coordinate to trigger zoneFloat:z
- The z coordinate to trigger zoneFloat:radius
- Trigger distancebarrier_state
- Barrier statuskey
- Interaction button- Returns (-1) on failure or (1) on success
GetBarrierTriggerExtra(barrierid, &Float:x, &Float:y, &Float:z, &Float:radius = 0.0, &barrier_state = 0, &key = 0)
Get trigger extra
barrierid
- The ID of the barrierFloat:x
- The x coordinate to trigger zoneFloat:y
- The y coordinate to trigger zoneFloat:z
- The z coordinate to trigger zoneFloat:radius
- Trigger distancebarrier_state
- Barrier statuskey
- Interaction button- Returns (-1) on failure or (1) on success
Get barrier ID
function[]
- Function name- Returns (-1) on failure or barrier id
- NOTE: При использовании одинаковых названий 'function[]' вернет ближайший ID барьера!
Set the barrier status
barrierid
- The ID of the barrierbarrier_state
- Barrier status- Returns (-1) on failure or (1) on success
Get Barrier status
barrierid
- The ID of the barrier- Returns (-1) on failure or (status)
Set barrier key
barrierid
- The ID of the barrierkey
- Interaction button- Returns (-1) on failure or (1) on success
Get barrier key
barrierid
- The ID of the barrier- Returns (-1) on failure or (key)
Get the barrier object ID
barrierid
- The ID of the barrier&moveid
- moving object id&extraid
- additional object id- Returns (-1) on failure or (1) on success
BarrierCreateExtraObject(barrierid, object_model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1)
Create a second extra object
barrierid
- The ID of the barrierobject_model
- The modelFloat:x
- The x coordinate to create the objectFloat:y
- The y coordinate to create the objectFloat:z
- The z coordinate to create the objectFloat:rx
- The x rotation of the objectFloat:ry
- The y rotation of the objectFloat:rz
- The z rotation of the objectworldid
- The virtual world IDinteriorid
- The interior ID- Returns (-1) on failure or (1) on success
Delete an extra barrier object
barrierid
- The ID of the barrier- Returns (-1) on failure or (1) on success
Set 3D Text
barrierid
- The ID of the barriertext[]
- textcolor
- Color- Returns (-1) on failure or (1) on success
Get Text 3D text
barrierid
- The ID of the barrier&text
- textsize = sizeof(text)
- sizeof- Returns (-1) on failure or (1) on success
Set 3D text color
barrierid
- The ID of the barriercolor
- Color- Returns (-1) on failure or (1) on success
Get 3D text color
barrierid
- The ID of the barrier- Returns (-1) on failure or (color) on success
Set position of 3D text
barrierid
- The ID of the barrierFloat:x
- The x coordinateFloat:y
- The y coordinateFloat:z
- The z coordinate- Returns (-1) on failure or (1) on success
Compare the function ( function analogue strcmp )
barrierid
- The ID of the barrierfunction[]
- Function name
Get barrier function name
barrierid
- The ID of the barrierfunction[]
- Function name- Returns (-1) on failure or (function)
Called when interacting with a barrier
const function[]
- Function nameplayerid
- The ID of the playerbarrierid
- The ID of the barrier- NOTE: Always use 'return 0;' if you need to activate the barrier
Called when creating a barrier
barrierid
- The ID of the barrierobjectid
- Object IDmodelid
- Object model
Called when a trigger zone is entered
playerid
- The ID of the playerbarrierid
- The ID of the barrierkeys
- Interaction button
Called when the trigger zone is entered
playerid
- The ID of the playerbarrierid
- The ID of the barrier
BARRIER_STATE_PLAYER_AND_DRIVER = -1
BARRIER_STATE_DRIVER_ONLY = 2
BARRIER_STATE_PLAYER_ONLY = 1
BARRIER_MOVEMENT_TYPE_OUTSIDE = 0
BARRIER_MOVEMENT_TYPE_INSIDE = 1
BARRIER_MOVEMENT_TYPE_RIGHT = 2
BARRIER_MOVEMENT_TYPE_LEFT = 3
BARRIER_MOVEMENT_TYPE_UP = 4
BARRIER_MOVEMENT_TYPE_DOWN = 5
#define MAX_BARRIERS 200
#define BARRIER_MAX_ATTACH 10
#define BARRIER_MAX_FUNCTION_NAME 32
#define BARRIER_KEY_STATE_ONFOOT KEY_WALK
#define BARRIER_KEY_STATE_DRIVER KEY_CROUCH
#define BARRIER_3DTEXT_LENGTH 144
#define BARRIER_OBJECT_DISTANCE 150.0
#define BARRIER_NOT_CREATE_EXTRA_OBJECT // only for the object model 968