Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Awa-Gates by {Awaran};
- *
- * @author: {Awaran};
- * @version: 0.2
- * @date: 13 Jan. 2010 (first release)
- * @update: 15 April. 2010 (update of v0.2)
- *
- * (c) Awaran - 2010 - 2011
- *
- * FILE RELEASED 'AS IS' (NO WARRANTIES)
- *
- * This file is intended for use on SA:MP 0.3a server versions.
- *
- */
- #define GATE_LIMIT 480
- new gatetmp;
- new GateOb[GATE_LIMIT];
- #define GATE_STATUS_CLOSED 0
- #define GATE_STATUS_OPEN 1
- #define IS_NEAR_RANGE 9.00
- forward OnPlayerRequestGateOperation(playerid, gateid);
- enum GateConfig
- {
- Valid,
- Float:close_X,
- Float:close_Y,
- Float:close_Z,
- Float:open_X,
- Float:open_Y,
- Float:open_Z,
- Status,
- }
- new Gate[GATE_LIMIT][GateConfig];
- stock CreateGate(modelid, Float:close_x, Float:close_y, Float:close_z, Float:open_x, Float:open_y, Float:open_z, Float:rX, Float:rY, Float:rZ)
- {
- new gg = gatetmp;
- gatetmp++;
- GateOb[gg] = CreateObject(modelid, close_x, close_y, close_z, rX, rY, rZ);
- Gate[gg][Valid] = 1;
- Gate[gg][close_X] = close_x;
- Gate[gg][close_Y] = close_y;
- Gate[gg][close_Z] = close_z;
- Gate[gg][open_X] = open_x;
- Gate[gg][open_Y] = open_y;
- Gate[gg][open_Z] = open_z;
- Gate[gg][Status] = GATE_STATUS_CLOSED;
- return gg;
- }
- stock FunctionGate(playerid, gateid, Float:speed)
- {
- if (OnPlayerRequestGateOperation(playerid, gateid))
- {
- if(Gate[gateid][Status] == GATE_STATUS_CLOSED)
- {
- OpenGate(GateOb[gateid], speed);
- Gate[gateid][Status] = GATE_STATUS_OPEN;
- }
- else if(Gate[gateid][Status] == GATE_STATUS_OPEN)
- {
- CloseGate(GateOb[gateid], speed);
- Gate[gateid][Status] = GATE_STATUS_CLOSED;
- }
- }
- }
- stock OpenGate(gateid, Float:speed)
- {
- MoveObject(GateOb[gateid], Gate[gateid][open_X], Gate[gateid][open_Y], Gate[gateid][open_Z], speed);
- }
- stock CloseGate(gateid, Float:speed)
- {
- MoveObject(GateOb[gateid],Gate[gateid][close_X], Gate[gateid][close_Y], Gate[gateid][close_Z], speed);
- }
- stock IsNearGate(playerid) // returns -1 if no gate is near || returns the id of the gate the player is closest to
- {
- for(new gateid = 0; gateid < GetMaxGates(); gateid++)
- {
- if(IsPlayerInRangeOfPoint(playerid, IS_NEAR_RANGE, Gate[gateid][close_X], Gate[gateid][close_Y], Gate[gateid][close_Z]))
- {
- return gateid;
- }
- }
- return -1;
- }
- stock GetMaxGates()
- {
- return gatetmp;
- }
- /*
- native CreateGate(modelid, Float:close_x, Float:close_y, Float:close_z, Float:open_x, Float:open_y, Float:open_z, Float:rX, Float:rY, Float:rZ);
- native FunctionGate(gateid, Float:speed);
- native OpenGate(gateid, Float:speed); // not recommended for use
- native CloseGate(gateid, Float:speed);// not recommended for use
- native IsNearGate(playerid);
- native GetMaxGates();
- */
Advertisement
Add Comment
Please, Sign In to add comment