Guest User

Untitled

a guest
Nov 17th, 2017
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.59 KB | None | 0 0
  1. /* Peace keeper System by Usman Memon aka Areeb */
  2. #include <a_samp>
  3. #include <dini>
  4. #include <zcmd>
  5. #include <foreach>
  6. #include <sscanf2>
  7.  
  8. // COLORS //
  9. #define COLOR_ORANGE 0xFF9900FF
  10. #define COLOR_YELLOW 0xFFFF00FF
  11. #define COLOR_WHITE 0xFFFFFFFF
  12. #define COLOR_ERROR 0xFF0000FF
  13.  
  14. // Path of pk file //
  15. #define FILE_PK "peacekeeper/%s.ini"
  16.  
  17. new pklvl[MAX_PLAYERS];
  18. new pkpm[MAX_PLAYERS];
  19. new pkicktimer[MAX_PLAYERS];
  20.  
  21. public OnFilterScriptInit()
  22. {
  23. print("\n--------------------------------------");
  24. print(" Peace Keeper System by Usman");
  25. print("--------------------------------------\n");
  26. return 1;
  27. }
  28.  
  29. public OnPlayerConnect(playerid)
  30. {
  31. new pname[MAX_PLAYER_NAME], filepk[MAX_PLAYERS];
  32. GetPlayerName(playerid, pname, sizeof(pname));
  33. format(filepk, sizeof(filepk), FILE_PK, pname);
  34. pklvl[playerid] = dini_Int(filepk, "pklvl");
  35. if(!fexist(filepk))
  36. {
  37. dini_Create(filepk);
  38. dini_IntSet(filepk, "pklvl", 0);
  39. }
  40. pklvl[playerid] = dini_Int(filepk, "pklvl");
  41. pkpm[playerid] = 0;
  42. return 1;
  43. }
  44.  
  45. public OnPlayerDisconnect(playerid, reason)
  46. {
  47. new pname[MAX_PLAYER_NAME], filepk[MAX_PLAYERS];
  48. GetPlayerName(playerid, pname, sizeof(pname));
  49. format(filepk, sizeof(filepk), FILE_PK, pname);
  50. dini_IntSet(filepk, "pklvl", pklvl[playerid]);
  51. pklvl[playerid] = 0;
  52. return 1;
  53. }
  54.  
  55.  
  56. CMD:setpeacekeeper(playerid, params[])
  57. {
  58. if (!IsPlayerAdmin(playerid)) return 0;
  59. new giveplayerid, moneys1, giveplayer[25], playername[25], string[256], filepk[MAX_PLAYERS];
  60. if (sscanf(params, "ud", giveplayerid, moneys1)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /setpeacekeeper [playerid] [0 = not Peace keeper, 1 = peace keeper]");
  61. if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
  62. if (moneys1 < 0 || moneys1 > 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: Invalid peacekeeper level.");
  63. GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
  64. if (moneys1 == pklvl[giveplayerid])
  65. {
  66. format(string, 64, "%s is already peacekeeper level %d.", giveplayer, moneys1);
  67. SendClientMessage(playerid, COLOR_WHITE, string);
  68. return 1;
  69. }
  70. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  71. if (moneys1 == 0)
  72. {
  73. pklvl[giveplayerid] = 0;
  74. format(filepk, sizeof(filepk), FILE_PK, giveplayer);
  75. dini_IntSet(filepk, "pklvl", 0);
  76. SendClientMessage(playerid, -1, "You have been remove from peacekeeper");
  77.  
  78. }
  79. else
  80. {
  81. pklvl[giveplayerid] = 1;
  82. format(filepk, sizeof(filepk), FILE_PK, giveplayer);
  83. dini_IntSet(filepk, "pklvl", 1);
  84. format(string, 64, "You have been set as peacekeeper.");
  85. SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  86. format(string, 64, "You have set %s as peacekeeper.", giveplayer);
  87. SendClientMessage(playerid, COLOR_YELLOW, string);
  88. }
  89. return 1;
  90. }
  91.  
  92. CMD:pkcmds(playerid, params[])
  93. {
  94. if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
  95. SendClientMessage(playerid, COLOR_ORANGE, "~Peace Keeper Command");
  96. SendClientMessage(playerid, COLOR_WHITE, "/pgoto, /pget, /pksay, /pkc, /pkpm, /pkkick");
  97. return 1;
  98. }
  99.  
  100. CMD:pkc(playerid, params[])
  101. {
  102. new tmp[256], playername[25], string[256];
  103. if (pklvl[playerid] < 1) return 0;
  104. if (sscanf(params, "s[128]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pkc [message]");
  105. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  106. format(string, sizeof(string), "{FF9900}PeaceKeeper Chat [%s] %s", playername, tmp);
  107. for (new i = 0; i < MAX_PLAYERS; i++)
  108. {
  109. if (IsPlayerConnected(i) && pklvl[i])
  110. {
  111. if(pklvl[playerid] == 1) SendClientMessage(i, -1, string);
  112. }
  113. }
  114. return 1;
  115. }
  116.  
  117. CMD:pksay(playerid, params[])
  118. {
  119. new tmp[256], playername[25], string[256];
  120. if (pklvl[playerid] < 1) return 0;
  121. if (sscanf(params, "s[128]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pksay [message]");
  122. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  123. format(string, sizeof(string), "* {FF9900}Peacekeeper {FFFFFF}- %s: %s", playername, tmp);
  124. SendClientMessageToAll(COLOR_WHITE, string);
  125. return 1;
  126. }
  127.  
  128. CMD:pks(playerid,params[])
  129. {
  130. SendClientMessage(playerid, COLOR_ORANGE, "Current Peace Keepers Online..");
  131. new count=0;
  132. new string[256], pname[MAX_PLAYER_NAME];
  133. foreach(Player, i){
  134. if (IsPlayerConnected(i)){
  135. if (pklvl[i] == 1){
  136. GetPlayerName(i,pname,sizeof(pname));
  137. format(string, 128, "%s - ({FFCC00}Peace Keeper{FFFFFF})", pname);
  138. SendClientMessage(playerid, COLOR_WHITE, string);
  139. count++;}
  140. }
  141. }
  142. if(count==0)
  143. SendClientMessage(playerid, COLOR_WHITE,"There are currently no pk members online.");
  144. return 1;
  145. }
  146.  
  147. CMD:pkpm(playerid, params[])
  148. {
  149. new tmp[256], giveplayerid, giveplayer[25], playername[25],string[256];
  150. if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
  151. GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
  152. if (sscanf(params, "us[128]", giveplayerid, tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /pm [playerid] [message]");
  153. if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
  154. if (giveplayerid == playerid) return SendClientMessage(playerid, COLOR_ERROR, "Error: You can't send private message to your self!");
  155. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  156. GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
  157. format(string, sizeof(string), "PM received from %s(%d):{ffffff} %s", playername, playerid, tmp);
  158. SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  159. format(string,sizeof(string), "{FFFF00}PM delivered to %s(%d):{ffffff} %s", giveplayer, giveplayerid, tmp);
  160. SendClientMessage(playerid, COLOR_YELLOW, string);
  161. PlayerPlaySound(giveplayerid, 1056, 0.0, 0.0, 0.0);
  162. pkpm[giveplayerid] = 1;
  163. SetPVarInt(giveplayerid, "AdminId", playerid);
  164. SendClientMessage(giveplayerid, COLOR_YELLOW, "You can use /pmreply to reply peacekeeper.");
  165. return 1;
  166. }
  167. CMD:pmreply(playerid, params[])
  168. {
  169. new id = GetPVarInt(playerid, "AdminId");
  170. new tmp[256], str[256], name[MAX_PLAYER_NAME];
  171. if(pkpm[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "An admin didnt pm you to reply.");
  172. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ERROR, "The admin that pmed you has CUTTOFF");
  173. if(sscanf(params, "s", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /areply [message]");
  174. GetPlayerName(playerid, name, sizeof(name));
  175. format(str, sizeof(str), "PM reply: {FFFFFF}%s.", tmp);
  176. SendClientMessage(playerid, COLOR_YELLOW, str);
  177. format(str, sizeof(str), "PM from %s(ID%d): {FFFFFF}%s.", name, playerid, tmp);
  178. SendClientMessage(id, COLOR_ERROR, str);
  179. pkpm[playerid] = 0;
  180. SetPVarInt(id, "AdminId", 0);
  181. return 1;
  182. }
  183.  
  184. CMD:pkgoto(playerid, params[])
  185. {
  186. new giveplayerid, Float:gx, Float:gy, Float:gz, string[256];
  187. if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
  188. if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pkgoto [playerid]");
  189. if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
  190. new pname[MAX_PLAYER_NAME];
  191. GetPlayerName(giveplayerid, pname, sizeof(pname));
  192. GetPlayerPos(giveplayerid, gx, gy, gz);
  193. SetPlayerPos(playerid, gx, gy, gz+1);
  194. format(string, sizeof(string), "You have warped to player %s (Id%d).", pname, giveplayerid);
  195. SendClientMessage(playerid, COLOR_ORANGE , string);
  196. return 1;
  197. }
  198.  
  199. CMD:pkget(playerid, params[])
  200. {
  201. new giveplayerid, Float:gx, Float:gy, Float:gz, string[256];
  202. if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
  203. if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pkget [playerid]");
  204. if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
  205. new pname[MAX_PLAYER_NAME];
  206. GetPlayerName(giveplayerid, pname, sizeof(pname));
  207. SetCameraBehindPlayer(giveplayerid);
  208. GetPlayerPos(playerid, gx, gy, gz);
  209. SetPlayerPos(giveplayerid, gx+2, gy+2, gz);
  210. SetPlayerInterior(giveplayerid, GetPlayerInterior(playerid));
  211. format(string, sizeof(string), "You have warped player %s (Id%d) to your position", pname, giveplayerid);
  212. SendClientMessage(playerid, COLOR_ORANGE, string);
  213. SendClientMessage(giveplayerid, COLOR_ORANGE , "An peacekeeper have warped you to his position.");
  214. return 1;
  215. }
  216.  
  217. CMD:pkkick(playerid, params[])
  218. {
  219. if(pklvl[playerid] < 1) return SendClientMessage(playerid, COLOR_ERROR, "Error: You are not peace keeper.");
  220. new string[256], giveplayerid, resaon[256], pname[MAX_PLAYER_NAME];
  221. if (sscanf(params, "us[128]", giveplayerid, resaon)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pkkick [playerid] [resaon]");
  222. if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_ERROR, "Error: Inactive player id!");
  223. GetPlayerName(giveplayerid, pname, sizeof(pname));
  224. format(string, sizeof(string), "An admin has kicked player %s for %s", pname, resaon);
  225. SendClientMessageToAll(COLOR_ERROR, string);
  226. pkicktimer[giveplayerid] = SetTimerEx("KickBanTimer", 50, 0, "dd", giveplayerid, 1);
  227. return 1;
  228. }
  229. forward KickBanTimer(playerid, kickban);
  230. public KickBanTimer(playerid, kickban)
  231. {
  232. switch (kickban)
  233. {
  234. case 1: Kick(playerid);
  235. case 2: Ban(playerid);
  236. }
  237. KillTimer(pkicktimer[playerid]);
  238. pkicktimer[playerid] = 0;
  239. }
Add Comment
Please, Sign In to add comment