Guest User

Oh

a guest
Dec 2nd, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.07 KB | None | 0 0
  1. #include <a_samp>
  2. #include <Dini>
  3. #include <dutils>
  4. #define FILTERSCRIPT
  5. #if defined FILTERSCRIPT
  6. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  7. #define COLOR_GREEN 0x33AA33AA
  8. #define COLOR_RED 0xAA3333AA
  9. #define COLOR_YELLOW 0xFFFF00AA
  10. #define COLOR_LIGHTBLUE 0x33CCFFAA
  11. #define COLOR_ORANGE 0xFF9900AA
  12. #pragma tabsize 0
  13. #define PlayerFile "VIP/%s.ini"
  14. public OnFilterScriptInit()
  15. {
  16. print("*Vip System By Etch*");
  17. return 1;
  18. }
  19. #endif
  20. enum PLAYER_MAIN {
  21. pName[MAX_PLAYER_NAME],
  22. Pip[16],
  23. Vip_Level
  24. }
  25. new Pinfo[MAX_PLAYERS][PLAYER_MAIN];
  26. public OnPlayerConnect(playerid)
  27. {
  28. SendClientMessage(playerid,COLOR_YELLOW,"Vip System By Etch");
  29. new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  30. if(!dini_Exists(file)) {
  31. dini_Create(file);
  32. dini_Set(file,"Name",Name);
  33. dini_Set(file,"Ip",Ip);
  34. dini_IntSet(file,"Vip_Level",0);
  35. }
  36. Pinfo[playerid][Vip_Level] = dini_Int(file,"Vip_Level");
  37. return 1;
  38. }
  39. public OnPlayerDisconnect(playerid, reason)
  40. {
  41. new file[100];
  42. format(file,sizeof(file),PlayerFile,Pinfo[playerid][pName]);
  43. dini_Set(file,"Name",Pinfo[playerid][pName]);
  44. dini_Set(file,"Ip",Pinfo[playerid][Pip]);
  45. dini_IntSet(file,"Vip_Level",Pinfo[playerid][Vip_Level]);
  46. Pinfo[playerid][Vip_Level] = 0;
  47. return 1;
  48. }
  49. public OnPlayerCommandText(playerid, cmdtext[])
  50. {
  51. dcmd(setvip,6,cmdtext);
  52. dcmd(viplevel,8,cmdtext);
  53. return 0;
  54. }
  55.  
  56. dcmd_setvip(playerid, params[])
  57. {
  58. new file[100];
  59. format(file,sizeof(file),PlayerFile,Pinfo[playerid][pName]);
  60. new string[128],string2[128];
  61. new giveplayerid, level;
  62. new playername[MAX_PLAYER_NAME],idname[MAX_PLAYER_NAME];
  63. GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  64. GetPlayerName(playerid,idname,MAX_PLAYER_NAME);
  65. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You Have To Be Rcon Admin To Use This Command!");
  66. if(sscanf(params, "ud", giveplayerid, level))return SendClientMessage(playerid, COLOR_RED, "Usage: /setvip [Playerid/Partname] [Level]");
  67. else if (giveplayerid == INVALID_PLAYER_ID)return SendClientMessage(playerid, COLOR_RED, "Player Is Not Connected");
  68. else if (level > 3)return SendClientMessage(playerid, COLOR_RED, "Maximum Vip Level Is 3");
  69. else
  70. {
  71. Pinfo[giveplayerid][Vip_Level] = level;
  72. format(string,sizeof(string),"Administrator %s Set Your Vip Level To %d",playername,level);
  73. SendClientMessage(giveplayerid,COLOR_YELLOW,string);
  74. format(string2,sizeof(string2),"%s Vip Level Is Now %d",idname,level);
  75. SendClientMessageToAll(COLOR_YELLOW,string2);
  76. dini_IntSet(file,"Vip_Level",Pinfo[playerid][Vip_Level]);
  77. }
  78. return 1;
  79. }
  80. dcmd_viplevel(playerid, params[])
  81. {
  82. #pragma unused params
  83. new string1[128],string2[128],string3[128];
  84. format(string1,sizeof(string1),"============================");
  85. format(string2,sizeof(string2),"Your V.I.P Level Is %d",Pinfo[playerid][Vip_Level]);
  86. format(string3,sizeof(string3),"============================");
  87. SendClientMessage(playerid,COLOR_YELLOW,string1);
  88. SendClientMessage(playerid,COLOR_YELLOW,string2);
  89. SendClientMessage(playerid,COLOR_YELLOW,string3);
  90. return 1;
  91. }
  92.  
  93. //------------------[SSCANF]-------------------------------------
  94. stock sscanf(string[], format[], {Float,_}:...)
  95. {
  96. #if defined isnull
  97. if (isnull(string))
  98. #else
  99. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  100. #endif
  101. {
  102. return format[0];
  103. }
  104. #pragma tabsize 4
  105. new
  106. formatPos = 0,
  107. stringPos = 0,
  108. paramPos = 2,
  109. paramCount = numargs(),
  110. delim = ' ';
  111. while (string[stringPos] && string[stringPos] <= ' ')
  112. {
  113. stringPos++;
  114. }
  115. while (paramPos < paramCount && string[stringPos])
  116. {
  117. switch (format[formatPos++])
  118. {
  119. case '\0':
  120. {
  121. return 0;
  122. }
  123. case 'i', 'd':
  124. {
  125. new
  126. neg = 1,
  127. num = 0,
  128. ch = string[stringPos];
  129. if (ch == '-')
  130. {
  131. neg = -1;
  132. ch = string[++stringPos];
  133. }
  134. do
  135. {
  136. stringPos++;
  137. if ('0' <= ch <= '9')
  138. {
  139. num = (num * 10) + (ch - '0');
  140. }
  141. else
  142. {
  143. return -1;
  144. }
  145. }
  146. while ((ch = string[stringPos]) > ' ' && ch != delim);
  147. setarg(paramPos, 0, num * neg);
  148. }
  149. case 'h', 'x':
  150. {
  151. new
  152. num = 0,
  153. ch = string[stringPos];
  154. do
  155. {
  156. stringPos++;
  157. switch (ch)
  158. {
  159. case 'x', 'X':
  160. {
  161. num = 0;
  162. continue;
  163. }
  164. case '0' .. '9':
  165. {
  166. num = (num << 4) | (ch - '0');
  167. }
  168. case 'a' .. 'f':
  169. {
  170. num = (num << 4) | (ch - ('a' - 10));
  171. }
  172. case 'A' .. 'F':
  173. {
  174. num = (num << 4) | (ch - ('A' - 10));
  175. }
  176. default:
  177. {
  178. return -1;
  179. }
  180. }
  181. }
  182. while ((ch = string[stringPos]) > ' ' && ch != delim);
  183. setarg(paramPos, 0, num);
  184. }
  185. case 'c':
  186. {
  187. setarg(paramPos, 0, string[stringPos++]);
  188. }
  189. case 'f':
  190. {
  191.  
  192. new changestr[16], changepos = 0, strpos = stringPos;
  193. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  194. {
  195. changestr[changepos++] = string[strpos++];
  196. }
  197. changestr[changepos] = '\0';
  198. setarg(paramPos,0,_:floatstr(changestr));
  199. }
  200. case 'p':
  201. {
  202. delim = format[formatPos++];
  203. continue;
  204. }
  205. case '\'':
  206. {
  207. new
  208. end = formatPos - 1,
  209. ch;
  210. while ((ch = format[++end]) && ch != '\'') {}
  211. if (!ch)
  212. {
  213. return -1;
  214. }
  215. format[end] = '\0';
  216. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  217. {
  218. if (format[end + 1])
  219. {
  220. return -1;
  221. }
  222. return 0;
  223. }
  224. format[end] = '\'';
  225. stringPos = ch + (end - formatPos);
  226. formatPos = end + 1;
  227. }
  228. case 'u':
  229. {
  230. new
  231. end = stringPos - 1,
  232. id = 0,
  233. bool:num = true,
  234. ch;
  235. while ((ch = string[++end]) && ch != delim)
  236. {
  237. if (num)
  238. {
  239. if ('0' <= ch <= '9')
  240. {
  241. id = (id * 10) + (ch - '0');
  242. }
  243. else
  244. {
  245. num = false;
  246. }
  247. }
  248. }
  249. if (num && IsPlayerConnected(id))
  250. {
  251. setarg(paramPos, 0, id);
  252. }
  253. else
  254. {
  255. #if !defined foreach
  256. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  257. #define __SSCANF_FOREACH__
  258. #endif
  259. string[end] = '\0';
  260. num = false;
  261. new
  262. name[MAX_PLAYER_NAME];
  263. id = end - stringPos;
  264. foreach (Player, playerid)
  265. {
  266. GetPlayerName(playerid, name, sizeof (name));
  267. if (!strcmp(name, string[stringPos], true, id))
  268. {
  269. setarg(paramPos, 0, playerid);
  270. num = true;
  271. break;
  272. }
  273. }
  274. if (!num)
  275. {
  276. setarg(paramPos, 0, INVALID_PLAYER_ID);
  277. }
  278. string[end] = ch;
  279. #if defined __SSCANF_FOREACH__
  280. #undef foreach
  281. #undef __SSCANF_FOREACH__
  282. #endif
  283. }
  284. stringPos = end;
  285. }
  286. case 's', 'z':
  287. {
  288. new
  289. i = 0,
  290. ch;
  291. if (format[formatPos])
  292. {
  293. while ((ch = string[stringPos++]) && ch != delim)
  294. {
  295. setarg(paramPos, i++, ch);
  296. }
  297. if (!i)
  298. {
  299. return -1;
  300. }
  301. }
  302. else
  303. {
  304. while ((ch = string[stringPos++]))
  305. {
  306. setarg(paramPos, i++, ch);
  307. }
  308. }
  309. stringPos--;
  310. setarg(paramPos, i, '\0');
  311. }
  312. default:
  313. {
  314. continue;
  315. }
  316. }
  317. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  318. {
  319. stringPos++;
  320. }
  321. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  322. {
  323. stringPos++;
  324. }
  325. paramPos++;
  326. }
  327. do
  328. {
  329. if ((delim = format[formatPos++]) > ' ')
  330. {
  331. if (delim == '\'')
  332. {
  333. while ((delim = format[formatPos++]) && delim != '\'') {}
  334. }
  335. else if (delim != 'z')
  336. {
  337. return delim;
  338. }
  339. }
  340. }
  341. while (delim > ' ');
  342. return 0;
  343. }
  344.  
  345.  
Advertisement
Add Comment
Please, Sign In to add comment