Skylive77

[FS] Server Monitor 2.0

Jun 6th, 2011
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.14 KB | None | 0 0
  1. //****************************************************************
  2. //****************************************************************
  3. //** Server Monitoring System v2.0 by Skylive77 **
  4. //** **
  5. //** Release 2.0 : **
  6. //** -RCON Chating **
  7. //** -SeeIp Option **
  8. //** -Help Command **
  9. //** -Monitor Command **
  10. //** -Monitor new Fonction **
  11. //** **
  12. //** **
  13. //****************************************************************
  14. //****************************************************************
  15. #include <a_samp>
  16. #define FILTERSCRIPT
  17. #define COLOR_WHITE 0xFFFFFFAA
  18. #define COLOR_MONITOR 0xB0C4DEFF
  19. #define COLOR_MONITOR1 0xCDFF00FF
  20. #define COLOR_MONITOR2 0x91FF00FF
  21. #define COLOR_CHAT 0x00FFE632
  22. #define COLOR_ALERTE 0xFF5A0093
  23. #define MAX_STRING 255
  24. #define COLOR_GRAD2 0xBFC0C2FF
  25.  
  26. forward SendServerMessage(color,const string[]);
  27. forward SendRCONMessage(color,const string[]);
  28. new playername[MAX_PLAYER_NAME];
  29. new sendername[MAX_PLAYER_NAME];
  30. new playerip[64];
  31. new MaxP;
  32. new totalon;
  33. new TotalConnections;
  34. new TotalTimeouts;
  35. new TotalKicks;
  36. new TotalCommands;
  37. new TotalChatMessages;
  38. new COKRCON;
  39. new CECHRCON;
  40.  
  41. #if defined FILTERSCRIPT
  42.  
  43. public OnFilterScriptInit()
  44. {
  45. print("\n--------------------------------------");
  46. print(" Server Monitoring by Skylive77 loaded");
  47. print("--------------------------------------\n");
  48. MaxP = GetMaxPlayers();
  49. new stringload[256];
  50. format(stringload, sizeof(stringload), "Server Monitoring chargé avec succès!");
  51. SendRCONMessage(COLOR_MONITOR1,stringload);
  52. return 1;
  53. }
  54.  
  55. public OnFilterScriptExit()
  56. {
  57. print("\n--------------------------------------");
  58. print(" Server Monitoring by Skylive77 unloaded");
  59. print("--------------------------------------\n");
  60. new stringunload[256];
  61. format(stringunload, sizeof(stringunload), "Server Monitoring tué avec succès!");
  62. SendRCONMessage(COLOR_ALERTE,stringunload);
  63. return 1;
  64. }
  65.  
  66. #else
  67.  
  68. main()
  69. {
  70. print("\n----------------------------------");
  71. print(" Server Monitoring by Skylive77");
  72. print("----------------------------------\n");
  73. }
  74.  
  75. #endif
  76.  
  77. public OnPlayerCommandText(playerid, cmdtext[])
  78. {
  79. TotalCommands++;
  80. new idx;
  81. new string[256];
  82. new cmd[256];
  83. cmd = strtok(cmdtext, idx);
  84. if(strcmp(cmdtext, "/allplayersip", true) == 0)
  85. {
  86. if (IsPlayerAdmin(playerid))
  87. {
  88. for(new j = 0; j < MAX_PLAYERS; j++)
  89. {
  90. if(IsPlayerConnected(j))
  91. {
  92. GetPlayerIp(j,playerip,sizeof(playerip));
  93. GetPlayerName(j, playername, sizeof(playername));
  94. format(string, 256, "Player Detected !! IP : %s, Name : %s.", playerip, playername);
  95. SendClientMessage(playerid,COLOR_MONITOR,string);
  96. }
  97. }
  98. }
  99. else
  100. {
  101. SendClientMessage(playerid, COLOR_GRAD2, "ERROR : Vous n'êtes pas Admin!");
  102. return 1;
  103. }
  104. return 1;
  105. }
  106. if(strcmp(cmdtext, "/mhelp", true) == 0)
  107. {
  108. if (IsPlayerAdmin(playerid))
  109. {
  110. SendClientMessage(playerid,COLOR_WHITE,"------------------------| Server Monitor Help Center |----------------------");
  111. SendClientMessage(playerid,COLOR_MONITOR,"Server Monitor HELP : /ssay /allplayersip /monitor.");
  112. SendClientMessage(playerid,COLOR_MONITOR,"Server Monitor HELP : /mc.");
  113. }
  114. else
  115. {
  116. SendClientMessage(playerid, COLOR_GRAD2, "ERROR : Vous n'êtes pas Admin!");
  117. return 1;
  118. }
  119. return 1;
  120. }
  121. if(strcmp(cmdtext, "/monitor", true) == 0)
  122. {
  123. if (IsPlayerAdmin(playerid))
  124. {
  125. totalon = 0;
  126. for(new i=0; i<MAX_PLAYERS; i++)
  127. {
  128. if(IsPlayerConnected(i))
  129. {
  130. if(totalon == 0)
  131. {
  132. totalon = 1;
  133. }
  134. else if (totalon > 0)
  135. {
  136. totalon++;
  137. }
  138. }
  139. }
  140. SendClientMessage(playerid,COLOR_WHITE,"----------------| Server Monitor |----------------");
  141. format(string, 256, "Players Online : %i/%i.", totalon, MaxP);
  142. SendClientMessage(playerid,COLOR_MONITOR1,string);
  143. new restant = MaxP-totalon;
  144. format(string, 256, "Slots available : %i.", restant);
  145. SendClientMessage(playerid,COLOR_MONITOR1,string);
  146. format(string, 256, "Total Connection : %d.", TotalConnections);
  147. SendClientMessage(playerid,COLOR_MONITOR1,string);
  148. format(string, 256, "Total Players Crash : %d.", TotalTimeouts);
  149. SendClientMessage(playerid,COLOR_MONITOR1,string);
  150. format(string, 256, "Total Players Quit : %d.", TotalKicks);
  151. SendClientMessage(playerid,COLOR_MONITOR1,string);
  152. format(string, 256, "Total Commands Used : %d.", TotalCommands);
  153. SendClientMessage(playerid,COLOR_MONITOR1,string);
  154. format(string, 256, "Total Messages Send : %d.", TotalChatMessages);
  155. SendClientMessage(playerid,COLOR_MONITOR1,string);
  156. format(string, 256, "Conexions au RCON (Echec) : %d.", CECHRCON);
  157. SendClientMessage(playerid,COLOR_MONITOR1,string);
  158. format(string, 256, "Conexions au RCON (Réussie) : %d.", COKRCON);
  159. SendClientMessage(playerid,COLOR_MONITOR1,string);
  160. SendClientMessage(playerid,COLOR_WHITE,"--------------------------------");
  161. format(string, 256, "RCON Admins Online :");
  162. SendClientMessage(playerid,COLOR_MONITOR2,string);
  163. for(new i = 0; i < MAX_PLAYERS; i++)
  164. {
  165. if(IsPlayerConnected(i))
  166. {
  167. if(IsPlayerAdmin(i))
  168. {
  169. new ip[64];
  170. GetPlayerName(i, sendername, sizeof(sendername));
  171. GetPlayerIp(i,ip,sizeof(ip));
  172. format(string, 256, "Name : %s, IP : %s", sendername, ip);
  173. SendClientMessage(playerid, COLOR_MONITOR2, string);
  174. }
  175. }
  176. }
  177. }
  178. else
  179. {
  180. SendClientMessage(playerid, COLOR_GRAD2, "ERROR : Vous n'êtes pas Admin!");
  181. return 1;
  182. }
  183. return 1;
  184. }
  185. if(strcmp(cmd,"/ssay",true)==0)
  186. {
  187. if (IsPlayerAdmin(playerid))
  188. {
  189. new length = strlen(cmdtext);
  190. while ((idx < length) && (cmdtext[idx] <= ' '))
  191. {
  192. idx++;
  193. }
  194. new offset = idx;
  195. new result[MAX_STRING];
  196. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  197. {
  198. result[idx - offset] = cmdtext[idx];
  199. idx++;
  200. }
  201. result[idx - offset] = EOS;
  202. if(!strlen(result))
  203. {
  204. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /s(erver)say [message]");
  205. return 1;
  206. }
  207. format(string, sizeof(string), "Server: %s", result);
  208. SendServerMessage(COLOR_MONITOR,string);
  209. }
  210. else
  211. {
  212. SendClientMessage(playerid, COLOR_GRAD2, "ERROR : Vous n'êtes pas Admin!");
  213. return 1;
  214. }
  215. return 1;
  216. }
  217. if(strcmp(cmd,"/mc",true)==0)
  218. {
  219. if (IsPlayerAdmin(playerid))
  220. {
  221. new length = strlen(cmdtext);
  222. while ((idx < length) && (cmdtext[idx] <= ' '))
  223. {
  224. idx++;
  225. }
  226. new offset = idx;
  227. new result[MAX_STRING];
  228. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  229. {
  230. result[idx - offset] = cmdtext[idx];
  231. idx++;
  232. }
  233. result[idx - offset] = EOS;
  234. if(!strlen(result))
  235. {
  236. SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /mc [chat]");
  237. return 1;
  238. }
  239. GetPlayerName(playerid, sendername, sizeof(sendername));
  240. format(string, sizeof(string), "RCON Admin %s: %s", sendername,result);
  241. SendRCONMessage(COLOR_CHAT,string);
  242. }
  243. else
  244. {
  245. SendClientMessage(playerid, COLOR_GRAD2, "ERROR : Vous n'êtes pas Admin!");
  246. return 1;
  247. }
  248. return 1;
  249. }
  250. return 0;
  251. }
  252.  
  253. public OnRconLoginAttempt(ip[], password[], success)
  254. {
  255. if(!success) //If the password was incorrect
  256. {
  257. CECHRCON++;
  258. }
  259. else
  260. {
  261. COKRCON++;
  262. }
  263. return 1;
  264. }
  265.  
  266. public SendServerMessage(color,const string[])
  267. {
  268. for(new i = 0; i < MAX_PLAYERS; i++)
  269. {
  270. if(IsPlayerConnected(i))
  271. {
  272. SendClientMessage(i, color, string);
  273. }
  274. }
  275. }
  276.  
  277. public OnPlayerText(playerid, text[])
  278. {
  279. TotalChatMessages++;
  280. return 1;
  281. }
  282.  
  283. public SendRCONMessage(color,const string[])
  284. {
  285. for(new i = 0; i < MAX_PLAYERS; i++)
  286. {
  287. if(IsPlayerConnected(i))
  288. {
  289. if (IsPlayerAdmin(i))
  290. {
  291. SendClientMessage(i, color, string);
  292. }
  293. }
  294. }
  295. }
  296.  
  297. public OnPlayerConnect(playerid)
  298. {
  299. TotalConnections++;
  300. return 1;
  301. }
  302.  
  303. public OnPlayerDisconnect(playerid, reason)
  304. {
  305. switch(reason)
  306. {
  307. case 0: { TotalTimeouts++; }
  308. case 2: { TotalKicks++; }
  309. }
  310. return 1;
  311. }
  312.  
  313. strtok(const string[], &index,seperator=' ')
  314. {
  315. new length = strlen(string);
  316. new offset = index;
  317. new result[128];
  318. while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
  319. {
  320. result[index - offset] = string[index];
  321. index++;
  322. }
  323.  
  324. result[index - offset] = EOS;
  325. if ((index < length) && (string[index] == seperator))
  326. {
  327. index++;
  328. }
  329. return result;
  330. }
Advertisement
Add Comment
Please, Sign In to add comment