Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- •••• • • •••• ••••• ••••• •• •• ••••• •••••
- • • • • • • • • • • • • •
- •••• • • •••• • ••• • • • • ••••• •
- • • • • • • • • • •
- •••• • •••• • ••••• • • ••••• •••••
- * S32_AutoGates - Create automatic gates with just one line!
- * Copyright(c)System32
- * This file is provided as is (no warranties)
- * Functions: 11
- * Credits:
- * System32 - Almost everything!
- * Y_Less - y_timers & foreach!
- * That is basically it, have fun with this include and easy scripting!
- */
- #include <a_samp>
- #include <foreach>
- #include <YSI\y_timers>
- #define MAX_AUTOGATES 100
- new Iterator: AutoGates<MAX_AUTOGATES>, agID;
- enum agInfo
- {
- agModelID,
- Float: agX,
- Float: agY,
- Float: agZ,
- Float: agrX,
- Float: agrY,
- Float: agrZ,
- Float: agNewX,
- Float: agNewY,
- Float: agNewZ,
- Float: agSpeed,
- agStatus,
- bool: agCreated,
- agObject
- };
- new AutoGateInfo[MAX_AUTOGATES][agInfo];
- /*
- • Function: CreateAutoGate(modelid, Float: X, Float: Y, Float: Z, Float: rX, Float: rY, Float: rZ, Float: NewX, Float: NewY, Float: NewZ, Float: Speed)
- • Usage: Creating automatic gate!
- • Parameters:
- modelid: ID of object
- X, Y, Z, rX, rY, rZ: position and rotation of object
- NewX, NewY, NewZ: New poistion of object
- Speed: Speed of object when he moves
- • Example: CreateAutoGate(969, 1019.00000000,-1846.69995117,12.30000019,0.00000000,0.00000000,280.00000000, 1019.00000000,-1846.69995117,9.60000038, 3.0);
- */
- stock CreateAutoGate(modelid, Float: X, Float: Y, Float: Z, Float: rX, Float: rY, Float: rZ, Float: NewX, Float: NewY, Float: NewZ, Float: Speed)
- {
- AutoGateInfo[agID][agModelID] = modelid;
- AutoGateInfo[agID][agX] = X;
- AutoGateInfo[agID][agY] = Y;
- AutoGateInfo[agID][agZ] = Z;
- AutoGateInfo[agID][agrX] = rX;
- AutoGateInfo[agID][agrY] = rY;
- AutoGateInfo[agID][agrZ] = rZ;
- AutoGateInfo[agID][agNewX] = NewX;
- AutoGateInfo[agID][agNewY] = NewY;
- AutoGateInfo[agID][agNewZ] = NewZ;
- AutoGateInfo[agID][agSpeed] = Speed;
- AutoGateInfo[agID][agObject] = CreateObject(AutoGateInfo[agID][agModelID], AutoGateInfo[agID][agX], AutoGateInfo[agID][agY], AutoGateInfo[agID][agZ], AutoGateInfo[agID][agrX], AutoGateInfo[agID][agrY], AutoGateInfo[agID][agrZ], 300.0);
- AutoGateInfo[agID][agCreated] = true;
- Iter_Add(AutoGates, agID);
- agID ++;
- }
- /*
- • Function: DestroyAutoGate(gateid)
- • Usage: Destroying automatic gate!
- • Parameters:
- gateid: ID of specific gate
- • Example: DestroyAutoGate(1);
- */
- stock DestroyAutoGate(gateid)
- {
- AutoGateInfo[gateid][agModelID] = 0;
- AutoGateInfo[gateid][agX] = 0.0;
- AutoGateInfo[gateid][agY] = 0.0;
- AutoGateInfo[gateid][agZ] = 0.0;
- AutoGateInfo[gateid][agrX] = 0.0;
- AutoGateInfo[gateid][agrY] = 0.0;
- AutoGateInfo[gateid][agrZ] = 0.0;
- AutoGateInfo[gateid][agNewX] = 0.0;
- AutoGateInfo[gateid][agNewY] = 0.0;
- AutoGateInfo[gateid][agNewZ] = 0.0;
- AutoGateInfo[gateid][agSpeed] = 0.0;
- AutoGateInfo[gateid][agObject] = DestroyObject(AutoGateInfo[gateid][agObject]);
- AutoGateInfo[agID][agCreated] = false;
- Iter_Remove(AutoGates, gateid);
- }
- /*
- • Function: GetTotalAutoGates()
- • Usage: Getting all created gates!
- • Parameters:
- no parameteres
- • Example: printf("Total auto gates: %d", GetTotalAutoGates());
- */
- stock GetTotalAutoGates() return Iter_Count(AutoGates);
- /*
- • Function: GetAutoGatePos(gateid, &Float: x, &Float: y, &Float: z)
- • Usage: Getting position of gate!
- • Parameters:
- X, Y, Z: Parameters in which will be stored position
- • Example:
- new Float: Pos[3];
- GetAutoGatePos(2, Pos[0], Pos[1], Pos[2]);
- printf("Gate X: %f, Gate Y: %f, Gate Z: %f", Pos[0], Pos[1], Pos[2]);
- */
- stock GetAutoGatePos(gateid, &Float: X, &Float: Y, &Float: Z)
- {
- X = AutoGateInfo[gateid][agX];
- Y = AutoGateInfo[gateid][agY];
- Z = AutoGateInfo[gateid][agZ];
- }
- /*
- • Function: GetAutoGateNewPos(gateid, &Float: x, &Float: y, &Float: z)
- • Usage: Getting new position of autogate!
- • Parameters:
- X, Y, Z: Parameters in which will be stored new position
- • Example:
- new Float: Pos[3];
- GetAutoGateNewPos(2, Pos[0], Pos[1], Pos[2]);
- printf("Gate New X: %f, Gate New Y: %f, Gate New Z: %f", Pos[0], Pos[1], Pos[2]);
- */
- stock GetAutoGateNewPos(gateid, &Float: X, &Float: Y, &Float: Z)
- {
- X = AutoGateInfo[gateid][agNewX];
- Y = AutoGateInfo[gateid][agNewY];
- Z = AutoGateInfo[gateid][agNewZ];
- }
- /*
- • Function: GetAutoGateRot(gateid, &Float: x, &Float: y, &Float: z)
- • Usage: Getting rotation of gate!
- • Parameters:
- X, Y, Z: Parameters in which will be stored rotation
- • Example:
- new Float: Pos[3];
- GetAutoGateRot(2, Pos[0], Pos[1], Pos[2]);
- printf("Gate rot X: %f, Gate rot Y: %f, Gate rot Z: %f", Pos[0], Pos[1], Pos[2]);
- */
- stock GetAutoGateRot(gateid, &Float: X, &Float: Y, &Float: Z)
- {
- X = AutoGateInfo[gateid][agrX];
- Y = AutoGateInfo[gateid][agrY];
- Z = AutoGateInfo[gateid][agrZ];
- }
- /*
- • Function: IsPlayerInRangeOfAutoGate(playerid, gateid, Float: Range)
- • Usage: Checking is player in range of specific gate!
- • Parameters:
- playerid: ID of player
- gateid: ID of gate
- Range: range in which can player be
- • Example:
- if(IsPlayerInRangeOfAutoGate(playerid, 4, 10.0) SendClientMessage(playerid, -1, "You are in range of auto gate 4");
- */
- stock IsPlayerInRangeOfAutoGate(playerid, gateid, Float: Range)
- {
- if(IsPlayerInRangeOfPoint(playerid, Range, AutoGateInfo[gateid][agX], AutoGateInfo[gateid][agY], AutoGateInfo[gateid][agZ])) return 1;
- return 0;
- }
- /*
- • Function: IsPlayerInRangeOfAnyAutoGate(playerid, Float: Range)
- • Usage: Checking is player in range of any gate!
- • Parameters:
- playerid: ID of player
- Range: range in which can player be
- • Example:
- if(IsPlayerInRangeOfAnyAutoGate(playerid, 10.0) SendClientMessage(playerid, -1, "You are in range of some auto gate");
- */
- stock IsPlayerInRangeOfAnyAutoGate(playerid, Float: Range)
- {
- foreach(AutoGates, ag)
- {
- if(IsPlayerInRangeOfPoint(playerid, Range, AutoGateInfo[ag][agX], AutoGateInfo[ag][agY], AutoGateInfo[ag][agZ])) return 1;
- }
- return 0;
- }
- /*
- • Function: GetAutoGateModelID(gateid)
- • Usage: Getting the model of gate!
- • Parameters:
- gateid: ID of gate
- • Example:
- printf("Model ID of gate 2 is: %d", GetAutoGateModelID(2));
- */
- stock GetAutoGateModelID(gateid) return AutoGateInfo[gateid][agModelID];
- /*
- • Function: GetAutoGateSpeed(gateid, &Float: Speed)
- • Usage: Getting the speed of gate!
- • Parameters:
- gateid: ID of gate
- Speed: Parametere in which will be stored speed
- • Example:
- new Float: Speed;
- GetAutoGateSpeed(12, Speed);
- printf("Speed of gate 12 is: %f", Speed);
- */
- stock GetAutoGateSpeed(gateid, &Float: Speed)
- {
- Speed = AutoGateInfo[gateid][agSpeed];
- }
- /*
- • Function: IsValidAutoGate(gateid)
- • Usage: Checking is specific gate valid gate!
- • Parameters:
- gateid: ID of gate
- • Example:
- if(IsValidAutoGate(2)) printf("Gate 2 is valid!");
- */
- stock IsValidAutoGate(gateid)
- {
- if(AutoGateInfo[gateid][agCreated] == true) return 1;
- return 0;
- }
- task CheckAutoGates[500]()
- {
- foreach(AutoGates, ag)
- {
- foreach(Player, i)
- {
- if(IsPlayerInRangeOfPoint(i, 10.0, AutoGateInfo[ag][agX], AutoGateInfo[ag][agY], AutoGateInfo[ag][agZ])) AutoGateInfo[ag][agStatus] = 1;
- else AutoGateInfo[ag][agStatus] = 0;
- }
- if(AutoGateInfo[ag][agStatus] == 1) MoveObject(AutoGateInfo[ag][agObject], AutoGateInfo[ag][agNewX], AutoGateInfo[ag][agNewY], AutoGateInfo[ag][agNewZ], AutoGateInfo[ag][agSpeed]);
- else MoveObject(AutoGateInfo[ag][agObject], AutoGateInfo[ag][agX], AutoGateInfo[ag][agY], AutoGateInfo[ag][agZ], AutoGateInfo[ag][agSpeed]);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement