Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * ULTIMATE GATE INCLUDE 0.1
- * (c) Copyright 2010-2011 by FoxHound
- *
- * @author : FoxHound aka PSPgamer_10
- * @date : 11 September 2010
- *
- * This file is provided as is (no warranties).
- *
- */
- /*********** MAX. GATES ***********/
- #define MAX_GATES 50 // The MAX Amount of Gates
- // Max. : N/A
- // Recommended : 50
- /********** DRAWDISTANCE **********/
- #define GATE_DRAWDISTANCE 100.0 // Drawdistance of the Gate-Objects
- // Max. : 300.0
- // Recommended : 100.0
- /********* GATE ACTIVATION *********/
- #define GATE_ACTIVATE_RANGE 5.0 // If the Player is nearer than X meters, the Gate will open and "OnGateOpen" Callback will be called
- // Max. : N/A
- // Recommended : 5.0
- /*********** CHECK-TIME ***********/
- #define GATES_CHECKTIME 1000 // All x MiLiSECONDS, ALL avaible Gates will be checked.
- // +> IMPORTANT:
- // Use this Carefully, 'cause this Number could make your Server Lagg.
- // The best way to escape the laggs is to hold the Number ON/OVER 1000 MS.
- #define ToggleGateLockForPlayer(%0,%1,%2); new _UGI_togNumb=%2;if(_UGI_togNumb<=0){UGI_gateLockedStatus[%0][%1]=0;}else{UGI_gateLockedStatus[%0][%1]=1;}
- #define ToggleGateLockForAll(%0,%1); for(new p=0;p<MAX_PLAYERS;p++){new UGI_togNumb=%1;if(UGI_togNumb<=0){UGI_gateLockedStatus[p][%0]=0;}else{UGI_gateLockedStatus[p][%0]=1;}}
- new UGI_delGateIdCount=0,UGI_delGateCreate[MAX_GATES]=0;
- new UGI_gateTimerStatus=0;
- new UGI_gateIdCount=0, UGI_gateObj[MAX_GATES]=0;
- new Float:UGI_gatePos[MAX_GATES][6], UGI_gateStatus[MAX_GATES];
- new UGI_gateLockedStatus[MAX_PLAYERS][MAX_GATES];
- forward OnGateOpen(gateid, byplayerid);
- forward OnGateClose(gateid);
- forward CreateGate(modelid, Float:closedX, Float:closedY, Float:closedZ, Float:openX, Float:openY, Float:openZ, Float:rX, Float:rY, Float:rZ);
- public CreateGate(modelid, Float:closedX, Float:closedY, Float:closedZ, Float:openX, Float:openY, Float:openZ, Float:rX, Float:rY, Float:rZ)
- {
- new UGI_creatingGateId,UGI_gateCreatedFromDeletedId=0;
- if(!UGI_delGateIdCount) { UGI_creatingGateId=UGI_gateIdCount; UGI_gateCreatedFromDeletedId=0; }
- else { for(new i=MAX_GATES;i>UGI_delGateIdCount;i++) { if(UGI_delGateCreate[i]==1) { UGI_creatingGateId = i; UGI_delGateIdCount-=1; UGI_delGateCreate[i]=0; UGI_gateCreatedFromDeletedId=1; break; } } }
- if(UGI_creatingGateId==MAX_GATES) { printf("[UGI] Couldn't create Gate ID '%d': Set the MAX_GATES definition to a higher Value (Current value: %d)",UGI_creatingGateId,MAX_GATES); return 0; }
- UGI_gateObj[UGI_creatingGateId] = CreateObject(modelid, closedX, closedY, closedZ, rX, rY, rZ, GATE_DRAWDISTANCE);
- if(UGI_gateTimerStatus == 0) {
- SetTimer("UGI_gateUpdate",GATES_CHECKTIME,true);
- UGI_gateTimerStatus = 1; }
- UGI_gatePos[UGI_creatingGateId][0] = closedX; UGI_gatePos[UGI_creatingGateId][1] = closedY; UGI_gatePos[UGI_creatingGateId][2] = closedZ;
- UGI_gatePos[UGI_creatingGateId][3] = openX; UGI_gatePos[UGI_creatingGateId][4] = openY; UGI_gatePos[UGI_creatingGateId][5] = openZ;
- UGI_gateStatus[UGI_creatingGateId]=0; UGI_creatingGateId += 1;
- for(new p=0;p<MAX_PLAYERS;p++) { UGI_gateLockedStatus[p][UGI_creatingGateId-1] = 0; }
- if(!UGI_gateCreatedFromDeletedId) { UGI_gateIdCount=UGI_creatingGateId; return UGI_creatingGateId-1; }
- else { return UGI_creatingGateId; }
- }
- forward IsGateLockedForPlayer(forplayerid, gateid);
- public IsGateLockedForPlayer(forplayerid, gateid)
- {
- if(UGI_gateLockedStatus[forplayerid][gateid]==1) { return 1; }
- return 0;
- }
- forward DestroyGate(gateid);
- public DestroyGate(gateid)
- {
- UGI_delGateCreate[UGI_delGateIdCount]=1;
- UGI_delGateIdCount+=1;
- DestroyObject(UGI_gateObj[gateid]);
- UGI_gateIdCount-=1;
- return 1;
- }
- forward UGI_gateUpdate();
- public UGI_gateUpdate()
- {
- new UGI_isAnyoneOnline=0;
- for(new p=0;p<MAX_PLAYERS;p++) { if(IsPlayerConnected(p)) { UGI_isAnyoneOnline=1; p=(MAX_PLAYERS-1); break; } }
- if(UGI_isAnyoneOnline)
- {
- new UGI_noPersonFound=(MAX_GATES+1);
- for(new g=0;g<UGI_gateIdCount;g++)
- {
- for(new p=0;p<MAX_PLAYERS;p++)
- {
- if(IsPlayerConnected(p))
- {
- new Float:objX, Float:objY, Float:objZ;
- new Float:gateActivateRange = GATE_ACTIVATE_RANGE;
- GetObjectPos(UGI_gateObj[g],objX,objY,objZ);
- if(IsPlayerInAnyVehicle(p)) { gateActivateRange += 2.0; }
- if(IsPlayerInRangeOfPoint(p,gateActivateRange,objX,objY,objZ))
- {
- if(UGI_gateLockedStatus[p][g]==0)
- {
- if(UGI_gateStatus[g]==0)
- {
- UGI_gateStatus[g]=1;
- MoveObject(UGI_gateObj[g], UGI_gatePos[g][3], UGI_gatePos[g][4], UGI_gatePos[g][5], 3.0);
- CallLocalFunction("OnGateOpen","dd",g,p);
- }
- }
- }
- if(!IsPlayerInRangeOfPoint(p,gateActivateRange,objX,objY,objZ))
- {
- if(UGI_gateStatus[g]==1)
- {
- UGI_noPersonFound=g;
- }
- }
- }
- }
- }
- if(UGI_noPersonFound!=(MAX_GATES+1))
- {
- UGI_gateStatus[UGI_noPersonFound] = 0;
- MoveObject(UGI_gateObj[UGI_noPersonFound], UGI_gatePos[UGI_noPersonFound][0], UGI_gatePos[UGI_noPersonFound][1], UGI_gatePos[UGI_noPersonFound][2], 3.0);
- CallLocalFunction("OnGateClose","d",UGI_noPersonFound);
- UGI_noPersonFound=(MAX_GATES+1);
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment