Guest User

AFK-System

a guest
Oct 17th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.33 KB | None | 0 0
  1. /* Dieses Filterscript wurde von Marcel_Hawkins geschrieben.
  2. Alle Rechte liegen daher bei Marcel_Hawkins!
  3. Dieses Filterscript darf bearbeitet und verwendet werden, allerdings darf
  4. es nicht als euer ausgegeben werden oder gar verkauft werden!
  5. Es ist mein erstes Filterscript das ich veröffentliche.
  6. Es ist nur ein kleines Filterscript was ich bei Bedarf weiter updaten werde!*/
  7.  
  8. #include <a_samp>
  9. #include <ocmd>
  10.  
  11. #define BLAU 0x0000FFFF
  12. #define LILA 0xFA00FFFF
  13. #define GRAU 0xB4B4B4FF
  14.  
  15. #if defined FILTERSCRIPT
  16.  
  17. public OnFilterScriptInit()
  18. {
  19. print("\n--------------------------------------");
  20. print(" kleines AFK-System by Marcel_Hawkins");
  21. print("--------------------------------------\n");
  22. return 1;
  23. }
  24.  
  25. public OnFilterScriptExit()
  26. {
  27. return 1;
  28. }
  29.  
  30. #else
  31.  
  32. main()
  33. {
  34. print("\n----------------------------------");
  35. print(" Blank Gamemode by your name here");
  36. print("----------------------------------\n");
  37. }
  38.  
  39. #endif
  40.  
  41. public OnGameModeInit()
  42. {
  43. // Don't use these lines if it's a filterscript
  44. SetGameModeText("Blank Script");
  45. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  46. return 1;
  47. }
  48.  
  49. public OnGameModeExit()
  50. {
  51. return 1;
  52. }
  53.  
  54. ocmd:afk(playerid,params[])
  55. {
  56. if(GetPVarInt(playerid,"AFK")==0)
  57. {
  58. new reason[128], string[128];
  59. if(sscanf(params,"s",reason)) return SendClientMessage(playerid,GRAU,"Benutze: /afk [Grund]");
  60. format(string,sizeof(string),"AFK-Info: der Spieler %s ist Away From Keyboard(AFK), Grund: %s!",Name(playerid),reason);
  61. SendClientMessageToAll(LILA,string);
  62. TogglePlayerControllable(playerid,0);
  63. SetPlayerVirtualWorld(playerid,2);
  64. SetPVarInt(playerid,"AFK",1);
  65. }
  66. if(GetPVarInt(playerid,"AFK")==1)
  67. {
  68. SendClientMessage(playerid,GRAU,"Du bist bereits in dem AFK-Modus. Tippe /back um zurückzukehren.");
  69. }
  70. return 1;
  71. }
  72. ocmd:back(playerid,params[])
  73. {
  74. if(GetPVarInt(playerid,"AFK")!=1)
  75. {
  76. SendClientMessage(playerid,BLAU,"Du bist nicht im AFK-Modus!");
  77. }
  78. if(GetPVarInt(playerid,"AFK")==1)
  79. {
  80. new string[128],string2[128];
  81. if(sscanf(params,"s"))
  82. format(string,sizeof(string),"AFK-Info: der Spieler %s ist aus dem Away From Keyboard(AFK) Modus zurückgekehrt.",Name(playerid));
  83. format(string2,sizeof(string2),"Hey, %s! Willkommen zurück!",Name(playerid));
  84. SendClientMessageToAll(LILA,string);
  85. GameTextForPlayer(playerid,string2,5000,2);
  86. TogglePlayerControllable(playerid,1);
  87. SetPVarInt(playerid,"AFK",0);
  88. SetPlayerVirtualWorld(playerid,0);
  89. }
  90. return 1;
  91. }
  92.  
  93. stock sscanf(string[], format[], {Float,_}:...)
  94. {
  95. #if defined isnull
  96. if (isnull(string))
  97. #else
  98. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  99. #endif
  100. {
  101. return format[0];
  102. }
  103. #pragma tabsize 4
  104. new
  105. formatPos = 0,
  106. stringPos = 0,
  107. paramPos = 2,
  108. paramCount = numargs(),
  109. delim = ' ';
  110. while (string[stringPos] && string[stringPos] <= ' ')
  111. {
  112. stringPos++;
  113. }
  114. while (paramPos < paramCount && string[stringPos])
  115. {
  116. switch (format[formatPos++])
  117. {
  118. case '\0':
  119. {
  120. return 0;
  121. }
  122. case 'i', 'd':
  123. {
  124. new
  125. neg = 1,
  126. num = 0,
  127. ch = string[stringPos];
  128. if (ch == '-')
  129. {
  130. neg = -1;
  131. ch = string[++stringPos];
  132. }
  133. do
  134. {
  135. stringPos++;
  136. if ('0' <= ch <= '9')
  137. {
  138. num = (num * 10) + (ch - '0');
  139. }
  140. else
  141. {
  142. return -1;
  143. }
  144. }
  145. while ((ch = string[stringPos]) > ' ' && ch != delim);
  146. setarg(paramPos, 0, num * neg);
  147. }
  148. case 'h', 'x':
  149. {
  150. new
  151. num = 0,
  152. ch = string[stringPos];
  153. do
  154. {
  155. stringPos++;
  156. switch (ch)
  157. {
  158. case 'x', 'X':
  159. {
  160. num = 0;
  161. continue;
  162. }
  163. case '0' .. '9':
  164. {
  165. num = (num << 4) | (ch - '0');
  166. }
  167. case 'a' .. 'f':
  168. {
  169. num = (num << 4) | (ch - ('a' - 10));
  170. }
  171. case 'A' .. 'F':
  172. {
  173. num = (num << 4) | (ch - ('A' - 10));
  174. }
  175. default:
  176. {
  177. return -1;
  178. }
  179. }
  180. }
  181. while ((ch = string[stringPos]) > ' ' && ch != delim);
  182. setarg(paramPos, 0, num);
  183. }
  184. case 'c':
  185. {
  186. setarg(paramPos, 0, string[stringPos++]);
  187. }
  188. case 'f':
  189. {
  190.  
  191. new changestr[16], changepos = 0, strpos = stringPos;
  192. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  193. {
  194. changestr[changepos++] = string[strpos++];
  195. }
  196. changestr[changepos] = '\0';
  197. setarg(paramPos,0,_:floatstr(changestr));
  198. }
  199. case 'p':
  200. {
  201. delim = format[formatPos++];
  202. continue;
  203. }
  204. case '\'':
  205. {
  206. new
  207. end = formatPos - 1,
  208. ch;
  209. while ((ch = format[++end]) && ch != '\'') {}
  210. if (!ch)
  211. {
  212. return -1;
  213. }
  214. format[end] = '\0';
  215. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  216. {
  217. if (format[end + 1])
  218. {
  219. return -1;
  220. }
  221. return 0;
  222. }
  223. format[end] = '\'';
  224. stringPos = ch + (end - formatPos);
  225. formatPos = end + 1;
  226. }
  227. case 'u':
  228. {
  229. new
  230. end = stringPos - 1,
  231. id = 0,
  232. bool:num = true,
  233. ch;
  234. while ((ch = string[++end]) && ch != delim)
  235. {
  236. if (num)
  237. {
  238. if ('0' <= ch <= '9')
  239. {
  240. id = (id * 10) + (ch - '0');
  241. }
  242. else
  243. {
  244. num = false;
  245. }
  246. }
  247. }
  248. if (num && IsPlayerConnected(id))
  249. {
  250. setarg(paramPos, 0, id);
  251. }
  252. else
  253. {
  254. #if !defined foreach
  255. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  256. #define __SSCANF_FOREACH__
  257. #endif
  258. string[end] = '\0';
  259. num = false;
  260. new
  261. name[MAX_PLAYER_NAME];
  262. id = end - stringPos;
  263. foreach (Player, playerid)
  264. {
  265. GetPlayerName(playerid, name, sizeof (name));
  266. if (!strcmp(name, string[stringPos], true, id))
  267. {
  268. setarg(paramPos, 0, playerid);
  269. num = true;
  270. break;
  271. }
  272. }
  273. if (!num)
  274. {
  275. setarg(paramPos, 0, INVALID_PLAYER_ID);
  276. }
  277. string[end] = ch;
  278. #if defined __SSCANF_FOREACH__
  279. #undef foreach
  280. #undef __SSCANF_FOREACH__
  281. #endif
  282. }
  283. stringPos = end;
  284. }
  285. case 's', 'z':
  286. {
  287. new
  288. i = 0,
  289. ch;
  290. if (format[formatPos])
  291. {
  292. while ((ch = string[stringPos++]) && ch != delim)
  293. {
  294. setarg(paramPos, i++, ch);
  295. }
  296. if (!i)
  297. {
  298. return -1;
  299. }
  300. }
  301. else
  302. {
  303. while ((ch = string[stringPos++]))
  304. {
  305. setarg(paramPos, i++, ch);
  306. }
  307. }
  308. stringPos--;
  309. setarg(paramPos, i, '\0');
  310. }
  311. default:
  312. {
  313. continue;
  314. }
  315. }
  316. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  317. {
  318. stringPos++;
  319. }
  320. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  321. {
  322. stringPos++;
  323. }
  324. paramPos++;
  325. }
  326. do
  327. {
  328. if ((delim = format[formatPos++]) > ' ')
  329. {
  330. if (delim == '\'')
  331. {
  332. while ((delim = format[formatPos++]) && delim != '\'') {}
  333. }
  334. else if (delim != 'z')
  335. {
  336. return delim;
  337. }
  338. }
  339. }
  340. while (delim > ' ');
  341. return 0;
  342. }
  343. //Name des Spielers
  344. stock Name(playerid)
  345. {
  346. new name[MAX_PLAYER_NAME];
  347. GetPlayerName(playerid,name,sizeof(name));
  348. return name;
  349. }
Advertisement
Add Comment
Please, Sign In to add comment