Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.31 KB | None | 0 0
  1. // Commands //
  2.  
  3. dcmd_gatehelp(playerid, params[])
  4. {
  5.     #pragma unused params
  6.     if(IsPlayerConnected(playerid))
  7.     {
  8.         SendClientMessage(playerid, 0x33CCFFAA, "------------------------------------");
  9.         SendClientMessage(playerid, 0xFF9900AA, "Gate System Help (Made by Kevin Hawk)");
  10.         SendClientMessage(playerid, 0xFFFFFFFF, "{AFAFAA}Admin Creation: {FFFFFF}/creategate /deletegate /gotogate /gateinfo");
  11.         SendClientMessage(playerid, 0xFFFFFFFF, "{AFAFAA}Admin Editing: {FFFFFF}/movegatex /movegatey /movegatez /rotategate /makegateowner");
  12.         SendClientMessage(playerid, 0xFFFFFFFF, "{AFAFAA}Gate Owner: {FFFFFF}/makegatepassword /makegatedirection");
  13.         SendClientMessage(playerid, 0xFFFFFFFF, "{AFAFAA}Anybody: {FFFFFF}/gatestatus /gate");
  14.         SendClientMessage(playerid, 0x33CCFFAA, "------------------------------------");
  15.     }
  16.     return 1;
  17. }
  18.  
  19. dcmd_creategate(playerid, params[]) // Admin Command
  20. {
  21.     if(IsPlayerConnected(playerid))
  22.     {
  23.         new type;
  24.         if(sscanf(params, "i", type)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /creategate [type] (Gates: 1-2) (Doors: 3-5)");
  25.         if(type < 1 || type > 5) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Valid types are 1, 2, 3, 4 and 5");
  26.         new Float:x, Float:y, Float:z, Float:angle;
  27.         GetPlayerFacingAngle(playerid, angle);
  28.         GetPlayerPos(playerid, x, y, z);
  29.         for(new i = 1; i < sizeof(GateInfo); i++)
  30.         {
  31.             if(!GateInfo[i][GateCreated])
  32.             {
  33.                 new message[128];
  34.                 format(message, sizeof(message), "* You have successfully created a gate. (ID %d)", i);
  35.                 SendClientMessage(playerid, 0x33CCFFAA, message);
  36.                 GateInfo[i][GateCreated] = 1;
  37.                 GateInfo[i][GateMoved] = 0;
  38.                 GateInfo[i][Angle] = angle;
  39.                 GateInfo[i][Owner] = 1;
  40.                 GateInfo[i][Password] = 1;
  41.                 GateInfo[i][Type] = type;
  42.                 if(type == 1) {GateInfo[i][GateObject] = CreateObject(969, x+1, y, z+2.5, 0, 0, angle); GateInfo[i][Type] = 1; GetObjectPos(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]);}
  43.                 else if(type == 2) {GateInfo[i][GateObject] = CreateObject(3036, x+1, y, z+2.5, 0, 0, angle); GateInfo[i][Type] = 2; GetObjectPos(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]);}
  44.                 else if(type == 3) {GateInfo[i][GateObject] = CreateObject(1569, x+1, y, z+2.5, 0, 0, angle); GateInfo[i][Type] = 3; GetObjectPos(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]);}
  45.                 else if(type == 4) {GateInfo[i][GateObject] = CreateObject(2664, x+1, y, z+2.5, 0, 0, angle); GateInfo[i][Type] = 4; GetObjectPos(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]);}
  46.                 else if(type == 5) {GateInfo[i][GateObject] = CreateObject(2930, x+1, y, z+2.5, 0, 0, angle); GateInfo[i][Type] = 5; GetObjectPos(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]);}
  47.                 savegates();
  48.                 GatesCreated ++;
  49.                 new Text[24];
  50.                 format(Text, sizeof(Text), "ID %d", i);
  51.                 GateInfo[i][GateText] = Create3DTextLabel(Text, 0x5174AEFF, GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ], 10.0, 0);
  52.                 return 1;
  53.             }
  54.         }
  55.     }
  56.     return 1;
  57. }
  58.  
  59. dcmd_deletegate(playerid, params[]) // Admin Command
  60. {
  61.     if(IsPlayerConnected(playerid))
  62.     {
  63.         new gateid;
  64.         if(sscanf(params, "i", gateid)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /gateinfo [gateid]");
  65.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  66.         new message[128];
  67.         format(message, sizeof(message), "* You have successfully deleted a gate. (ID %d)", gateid);
  68.         SendClientMessage(playerid, 0x33CCFFAA, message);
  69.         GateInfo[gateid][GateCreated] = 0;
  70.         GateInfo[gateid][GateMoved] = 0;
  71.         GateInfo[gateid][GateX] = 0;
  72.         GateInfo[gateid][GateY] = 0;
  73.         GateInfo[gateid][GateZ] = 0;
  74.         DestroyObject(GateInfo[gateid][GateObject]);
  75.         new file[16];
  76.         format(file, sizeof(file), "Gates/%d.ini", gateid);
  77.         GatesCreated --;
  78.         dini_Remove(file);
  79.         Delete3DTextLabel(GateInfo[gateid][GateText]);
  80.     }
  81.     return 1;
  82. }
  83.  
  84. dcmd_gotogate(playerid, params[]) // Admin Command
  85. {
  86.     if(IsPlayerConnected(playerid))
  87.     {
  88.         new gateid;
  89.         if(sscanf(params, "i", gateid)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /gotogate [gateid]");
  90.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  91.         if(GateInfo[gateid][GateCreated])
  92.         {
  93.             SetPlayerPos(playerid, GateInfo[gateid][GateX] +2, GateInfo[gateid][GateY] +2, GateInfo[gateid][GateZ] +2);
  94.         }
  95.     }
  96.     return 1;
  97. }
  98.  
  99. dcmd_gateinfo(playerid, params[]) // Admin Command
  100. {
  101.     if(IsPlayerConnected(playerid))
  102.     {
  103.         new gateid, status[8];
  104.         if(sscanf(params, "i", gateid)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /gateinfo [gateid]");
  105.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  106.         new message[128];
  107.         format(message, sizeof(message), "* Gate owner is %s. (ID %d)", GateInfo[gateid][Owner] , gateid);
  108.         SendClientMessage(playerid, 0x33CCFFAA, message);
  109.         format(message, sizeof(message), "* Gate password is %s. (ID %d)", GateInfo[gateid][Password] , gateid);
  110.         SendClientMessage(playerid, 0x33CCFFAA, message);
  111.         if(GateInfo[gateid][Direction] == 1) format(status, sizeof(status), "up");
  112.         if(GateInfo[gateid][Direction] == 2) format(status, sizeof(status), "down");
  113.         format(message, sizeof(message), "* Gate open direction is %s. (ID %d)", status , gateid);
  114.         SendClientMessage(playerid, 0x33CCFFAA, message);
  115.     }
  116.     return 1;
  117. }
  118.  
  119. dcmd_movegatex(playerid, params[]) // Admin Command
  120. {
  121.     if(IsPlayerConnected(playerid))
  122.     {
  123.         new gateid, Float:distance;
  124.         if(sscanf(params, "if", gateid, distance)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /movegatex [gateid] [distance]");
  125.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  126.         SetObjectPos(GateInfo[gateid][GateObject], GateInfo[gateid][GateX]+distance, GateInfo[gateid][GateY], GateInfo[gateid][GateZ]);
  127.         GetObjectPos(GateInfo[gateid][GateObject], GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ]);
  128.         Delete3DTextLabel(GateInfo[gateid][GateText]);
  129.         new Text[24];
  130.         format(Text, sizeof(Text), "ID %d", gateid);
  131.         GateInfo[gateid][GateText] = Create3DTextLabel(Text, 0x5174AEFF, GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ], 10.0, 0);
  132.         savegates();
  133.     }
  134.     return 1;
  135. }
  136.  
  137. dcmd_movegatey(playerid, params[]) // Admin Command
  138. {
  139.     if(IsPlayerConnected(playerid))
  140.     {
  141.         new gateid, Float:distance;
  142.         if(sscanf(params, "if", gateid, distance)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /movegatey [gateid] [distance]");
  143.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  144.         SetObjectPos(GateInfo[gateid][GateObject], GateInfo[gateid][GateX], GateInfo[gateid][GateY]+distance, GateInfo[gateid][GateZ]);
  145.         GetObjectPos(GateInfo[gateid][GateObject], GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ]);
  146.         Delete3DTextLabel(GateInfo[gateid][GateText]);
  147.         new Text[24];
  148.         format(Text, sizeof(Text), "ID %d", gateid);
  149.         GateInfo[gateid][GateText] = Create3DTextLabel(Text, 0x5174AEFF, GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ], 10.0, 0);
  150.         savegates();
  151.     }
  152.     return 1;
  153. }
  154.  
  155. dcmd_movegatez(playerid, params[]) // Admin Command
  156. {
  157.     if(IsPlayerConnected(playerid))
  158.     {
  159.         new gateid, Float:distance;
  160.         if(sscanf(params, "if", gateid, distance)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /movegatez [gateid] [distance]");
  161.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  162.         SetObjectPos(GateInfo[gateid][GateObject], GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ]+distance);
  163.         GetObjectPos(GateInfo[gateid][GateObject], GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ]);
  164.         Delete3DTextLabel(GateInfo[gateid][GateText]);
  165.         new Text[24];
  166.         format(Text, sizeof(Text), "ID %d", gateid);
  167.         GateInfo[gateid][GateText] = Create3DTextLabel(Text, 0x5174AEFF, GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ], 10.0, 0);
  168.         savegates();
  169.     }
  170.     return 1;
  171. }
  172.  
  173. dcmd_rotategate(playerid, params[]) // Admin Command
  174. {
  175.     if(IsPlayerConnected(playerid))
  176.     {
  177.         new gateid, Float:distance, Float:rX, Float:rY, Float:rZ;
  178.         if(sscanf(params, "if", gateid, distance)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /rotategate [gateid] [angle]");
  179.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  180.         GetObjectRot(GateInfo[gateid][GateObject], rX, rY, rZ);
  181.         SetObjectRot(GateInfo[gateid][GateObject], rX, rY, GateInfo[gateid][Angle]+distance);
  182.         GetObjectRot(GateInfo[gateid][GateObject], rX, rY, GateInfo[gateid][Angle]);
  183.         Delete3DTextLabel(GateInfo[gateid][GateText]);
  184.         new Text[24];
  185.         format(Text, sizeof(Text), "ID %d", gateid);
  186.         GateInfo[gateid][GateText] = Create3DTextLabel(Text, 0x5174AEFF, GateInfo[gateid][GateX], GateInfo[gateid][GateY], GateInfo[gateid][GateZ], 10.0, 0);
  187.         savegates();
  188.     }
  189.     return 1;
  190. }
  191.  
  192.  
  193. dcmd_makegateowner(playerid, params[]) // Admin Command
  194. {
  195.     if(IsPlayerConnected(playerid))
  196.     {
  197.         new gateid, playerb;
  198.         if(sscanf(params, "iu", gateid, playerb)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /makegateowner [gateid] [playerid]");
  199.         if(!GateInfo[gateid][GateCreated]) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: Invalid Gate ID, check /gatestatus");
  200.         new PName[MAX_PLAYER_NAME], message[128];
  201.         GetPlayerName(playerb, PName, sizeof(PName));
  202.         format(GateInfo[gateid][Owner], MAX_PLAYER_NAME, "%s", PName);
  203.         format(message, sizeof(message), "* You have successfully made a gate owned by %s. (ID %d)", PName, gateid);
  204.         SendClientMessage(playerid, 0x33CCFFAA, message);
  205.         savegates();
  206.     }
  207.     return 1;
  208. }
  209.  
  210. dcmd_makegatepassword(playerid, params[]) // Gate Owner Command
  211. {
  212.     if(IsPlayerConnected(playerid))
  213.     {
  214.         new password[128], message[128], gateid;
  215.         if(sscanf(params, "is", gateid, password)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /makegatepassword [gateid] [password]");
  216.         // Gate Owner Check
  217.         new PName[MAX_PLAYER_NAME];
  218.         GetPlayerName(playerid, PName, sizeof(PName));
  219.         if(strcmp(GateInfo[gateid][Owner], PName, false)) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: You are not the owner of this gate");
  220.         // Password Making
  221.         format(GateInfo[gateid][Password], 128, "%s", password);
  222.         format(message, sizeof(message), "* You have set your gate password to %s", GateInfo[gateid][Password]);
  223.         SendClientMessage(playerid, 0x33CCFFAA, message);
  224.         savegates();
  225.         return 1;
  226.     }
  227.     return 1;
  228. }
  229.  
  230. dcmd_makegatedirection(playerid, params[]) // Gate Owner Command
  231. {
  232.     if(IsPlayerConnected(playerid))
  233.     {
  234.         new direction[8], gateid;
  235.         if(sscanf(params, "is", gateid, direction)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /makegatedirection [gateid] [right/left/up/down]");
  236.         // Gate Owner Check
  237.         new PName[MAX_PLAYER_NAME];
  238.         GetPlayerName(playerid, PName, sizeof(PName));
  239.         if(strcmp(GateInfo[gateid][Owner], PName, false)) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: You are not the owner of this gate");
  240.         // Gate Direction
  241.         else if(!strcmp(direction, "up", true)) {GateInfo[gateid][Direction] = 1; SendClientMessage(playerid, 0x33CCFFAA, "* Your gate will now open to the up");}
  242.         else if(!strcmp(direction, "down", true)) {GateInfo[gateid][Direction] = 2; SendClientMessage(playerid, 0x33CCFFAA, "* Your gate will now open to the down");}
  243.         savegates();
  244.         return 1;
  245.     }
  246.     return 1;
  247. }
  248.  
  249. dcmd_gatestatus(playerid, params[])
  250. {
  251.     #pragma unused params
  252.     if(IsPlayerConnected(playerid))
  253.     {
  254.         new message[128];
  255.         SendClientMessage(playerid, 0x33CCFFAA, "------------------------------------");
  256.         SendClientMessage(playerid, 0xFF9900AA, "Gate System Status (Made by Kevin Hawk)");
  257.         format(message, sizeof(message), "Gates Created: %d [MAX_GATES = %d] [Gates Left: %d]", GatesCreated, MAX_GATES-1, MAX_GATES -1 -GatesCreated);
  258.         SendClientMessage(playerid, 0xFFFFFFFF, message);
  259.         SendClientMessage(playerid, 0x33CCFFAA, "------------------------------------");
  260.     }
  261.     return 1;
  262. }
  263.  
  264. dcmd_gate(playerid, params[]) // Public Command
  265. {
  266.     if(IsPlayerConnected(playerid))
  267.     {
  268.         new password[128];
  269.         if(sscanf(params, "s", password)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /gate [password]");
  270.         for(new i = 1; i < sizeof(GateInfo); i++)
  271.         {
  272.             if(IsPlayerInRangeOfPoint(playerid, 10.0, GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]))
  273.             {
  274.                 // Gate Password Check
  275.                 if(strcmp(password, GateInfo[i][Password], false)) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: You have entered a wrong gate password");
  276.                 // Gate Moving
  277.                 if(!GateInfo[i][GateMoved])
  278.                 {
  279.                     new message[128];
  280.                     format(message, sizeof(message), "* You have successfully opened a gate. (ID %d)", i);
  281.                     SendClientMessage(playerid, 0x33CCFFAA, message);
  282.                     GateInfo[i][GateMoved] = 1;
  283.                     if(GateInfo[i][Direction] == 1) {MoveObject(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]+5, 8);}
  284.                     if(GateInfo[i][Direction] == 2) {MoveObject(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ]-5, 8);}
  285.                     return 1;
  286.                 }
  287.                 else if(GateInfo[i][GateMoved])
  288.                 {
  289.                     new message[128];
  290.                     format(message, sizeof(message), "* You have successfully closed a gate. (ID %d)", i);
  291.                     SendClientMessage(playerid, 0x33CCFFAA, message);
  292.                     GateInfo[i][GateMoved] = 0;
  293.                     MoveObject(GateInfo[i][GateObject], GateInfo[i][GateX], GateInfo[i][GateY], GateInfo[i][GateZ], 50);
  294.                     return 1;
  295.                 }
  296.             }
  297.             else return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: You are not near a gate");
  298.         }
  299.     }
  300.     return 1;
  301. }
  302.  
  303. // End of Commands //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement