Automatic Gate Helping to begin
#1

Good night all and thanks for see but i know the ppl is going to say search have a lot of automatic gates here BUT im needing one special automatic gate bcs im searching but is for a automatic gate to ONE TEAM or GANG not for player but yes for a Team i have one automatic gates but i think dont work with Team only one player so if you can help me THANKS ALOT if you cant ok

thanks all but im really needing it IM CRAZY WITH THAT
Reply
#2

How do you define as being in a team?
Reply
#3

Perhaps you could try using this?

http://forum.sa-mp.com/index.php?top...2882#msg662882
Reply
#4

w8 i have to test
Reply
#5

#include <a_samp>

#define MAX_GATES 1 // Number of your gates.

#define COLOR_RED 0xDF1010AA
#define COLOR_GRAY 0xAFAFAFAA

enum gInfo
{
TeamId,

ObjectId,
Opened,

Float: CloseX,
Float: CloseY,
Float: CloseZ,

Float: OpenX,
Float: OpenY,
Float: OpenZ,

Float: CloseRotX,
Float: CloseRotY,
Float: CloseRotZ,

Float: OpenRotX,
Float: OpenRotY,
Float: OpenRotZ,

GateTimer,
ParentId
};

new Gate[MAX_GATES][gInfo];
new gates;

forward OpenCloseGates(playerid);
forward ToggleGate(gateID);
forward MoveChild(GateId);
forward GetChildId(GateId);
forward IsAllowedToUseGate(playerid, gateID);
forward GetClosestGate(playerid, &Float: distance);
forward RotateObject(Object, Float:maxX, Float:maxY, Float:maxZ, SuundX, SuundY, SuundZ);

forward CreateGate(modelid, Float: closeX, Float: closeY, Float: closeZ, Float: closeRotX, Float: closeRotY, Float: closeRotZ, Float: openX, Float: openY, Float: openZ, Float: openRotX, Float: openRotY, Float: openRotZ, Parent);

Floatistance(Float1,Float:y1,Float:z1,Float2 ,Float:y2,Float:z2)
{
new Float:temp=floatsqroot((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2) + (z1-z2) * (z1-z2));
if(temp < 0) temp=temp*(-1);
return temp;
}

public OnFilterScriptInit()
{
print("CreateGate FS by Jyrno42 Loaded");

/* SAMPLE */
new gate = CreateGate(980, 2087.664306, 2314.904541, 12.000000, 0.0, 0.0, 325.00, 2087.664306,2314.904541,0.000000, 0.0, 0.0, 0.0, -1);
Gate[gate][TeamId] = 10;

// Lets create a gate for team 1 with no parent gate.
// Note: This gate is a rotating gate for the parkinglot of LSPD.

return 1;
}
public OnFilterScriptExit()
{
print("CreateGate FS UnLoaded");
}

public OpenCloseGates(playerid)
{
new Float: dist;
new gateID = GetClosestGate(playerid, dist);

if(dist < 10.0)
{
if(IsAllowedToUseGate(playerid, gateID))
{
ToggleGate(gateID);

return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You dont have a remote to open this gate!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAY, "Youre not close to any gates!");
return 1;
}
}

public GetClosestGate(playerid, &Float: distance)
{
new Float: pX, Float: pY, Float: pZ;

GetPlayerPos(playerid, pX, pY, pZ);

distance = 999999.9;
new Float: dist2;

new ret;

for(new i; i < MAX_GATES; i++)
{

dist2 = Distance(pX, pY, pZ, Gate[i][CloseX], Gate[i][CloseY], Gate[i][CloseZ]);

if(dist2 < distance && Gate[i][ParentId] == -1)
{
distance = dist2;
ret = i;
}
}

return ret;
}

public CreateGate(modelid, Float: closeX, Float: closeY, Float: closeZ, Float: closeRotX, Float: closeRotY, Float: closeRotZ, Float: openX, Float: openY, Float: openZ, Float: openRotX, Float: openRotY, Float: openRotZ, Parent)
{
if(gates >= MAX_GATES)
{
print("CreateGate Error: Number of gates exeeds MAX_GATES.");
return 0;
}

Gate[gates][ObjectId] = CreateObject(modelid, closeX, closeY, closeZ, closeRotX, closeRotY, closeRotZ);

Gate[gates][CloseX] = closeX;
Gate[gates][CloseY] = closeY;
Gate[gates][CloseZ] = closeZ;

Gate[gates][OpenX] = openX;
Gate[gates][OpenY] = openY;
Gate[gates][OpenZ] = openZ;

Gate[gates][CloseRotX] = closeRotX;
Gate[gates][CloseRotY] = closeRotY;
Gate[gates][CloseRotZ] = closeRotZ;

Gate[gates][OpenRotX] = openRotX;
Gate[gates][OpenRotY] = openRotY;
Gate[gates][OpenRotZ] = openRotZ;

gates++;
return gates-1;
}

public RotateObject(Object, Float:maxX, Float:maxY, Float:maxZ, SuundX, SuundY, SuundZ)// 0++, 1--
{
new Float:rotx, Float:roty, Float:rotz;
new Float: addX = 1.0, Float:addY = 1.0, Float: addZ = 1.0;

new fullX, fullY, fullZ;

GetObjectRot(Object, rotx, roty, rotz);

if(SuundX == 0)
{
if(rotx >= maxX)
{
addX = 0;
fullX = 1;
}
}
else
{
if(rotx <= maxX)
{
addX = 0;
fullX = 1;
}
}

if(SuundY == 0)
{
if(roty >= maxY)
{
addY= 0;
fullY = 1;
}
}
else
{
if(roty <= maxY)
{
addY= 0;
fullY = 1;
}
}

if(SuundZ == 0)
{
if(rotz >= maxZ)
{
addZ = 0;
fullZ = 1;
}
}
else
{
if(rotz >= maxZ)
{
addZ = 0;
fullZ = 1;
}
}

if(SuundX == 0) rotx += addX;
else rotx -= addX;

if(SuundY == 0) roty += addY;
else roty -= addY;

if(SuundZ == 0) rotz += addZ;
else rotz -= addZ;

SetObjectRot(Object, rotx, roty, rotz);

if(!fullX || !fullY || !fullZ)
{
SetTimerEx("RotateObject", 75, 0, "ifffiii", Object, maxX, maxY, maxZ, SuundX, SuundY, SuundZ);
}

return 1;
}

public ToggleGate(gateID)
{
if(Gate[gateID][Opened])
{
MoveObject(Gate[gateID][ObjectId], Gate[gateID][CloseX], Gate[gateID][CloseY], Gate[gateID][CloseZ], 4.0);

new SuundX, SuundY, SuundZ;

if(Gate[gateID][CloseRotX] < Gate[gateID][OpenRotX])
{
SuundX = 1;
}

if(Gate[gateID][CloseRotY] < Gate[gateID][OpenRotY])
{
SuundY = 1;
}

if(Gate[gateID][CloseRotZ] < Gate[gateID][OpenRotZ])
{
SuundZ = 1;
}

RotateObject(Gate[gateID][ObjectId], Gate[gateID][CloseRotX], Gate[gateID][CloseRotY], Gate[gateID][CloseRotZ], SuundX, SuundY, SuundZ);

Gate[gateID][Opened] = 0;

MoveChild(gateID);

return 1;
}
else
{
MoveObject(Gate[gateID][ObjectId], Gate[gateID][OpenX], Gate[gateID][OpenY],Gate[gateID][OpenZ], 4.0);

new SuundX, SuundY, SuundZ;

if(Gate[gateID][CloseRotX] > Gate[gateID][OpenRotX])
{
SuundX = 1;
}

if(Gate[gateID][CloseRotY] > Gate[gateID][OpenRotY])
{
SuundY = 1;
}

if(Gate[gateID][CloseRotZ] > Gate[gateID][OpenRotZ])
{
SuundZ = 1;
}

RotateObject(Gate[gateID][ObjectId], Gate[gateID][OpenRotX], Gate[gateID][OpenRotY], Gate[gateID][OpenRotZ], SuundX, SuundY, SuundZ);

Gate[gateID][Opened] = 1;

MoveChild(gateID);

return 1;
}
}

public IsAllowedToUseGate(playerid, gateID)
{
new ret;

if(Gate[gateID][TeamId] > 0)
{
if(GetPlayerTeam(playerid) == Gate[gateID][TeamId])
{
return 1;
}
ret = 0;
}

return ret;
}

public MoveChild(GateId)
{
new childId = GetChildId(GateId);

if(childId == -1)// No children
{
return 0;
}

ToggleGate(childId);

return 1;
}

public GetChildId(GateId)
{
for(new i; i < MAX_GATES; i++)
{
if(Gate[i][ParentId] == GateId)
{
return i;
}
}
return -1;
}

its here but now what i should put to put me in the team and i can opne the gate?

sorry but im only on ebeginner
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)