Guest User

Untitled

a guest
Jun 22nd, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.25 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <YSI\y_ini>
  5. #include <zcmd>
  6. #include <sscanf2>
  7. #include <CheckpointManager>
  8. #define PATH "/Tokens/%s.ini"
  9. #define COLOR_RED 0xAA3333AA
  10. #define COLOR_WHITE 0xFFFFFFFF
  11. #define COLOR_GRAD2 0xBFC0C2FF
  12. #define COLOR_GREY 0xAFAFAFAA
  13. #define COLOR_RED 0xAA3333AA
  14.  
  15. #define BUYING 1
  16.  
  17.  
  18. #define FIRSTMENU 500
  19.  
  20. public OnFilterScriptInit()
  21. {
  22.  
  23. // ******************************* [ Pick ups] *********************************
  24. // |--------------------------------------------------------------------------|*
  25. // |*
  26. // |*
  27. // |*
  28. // |--------------------------------------------------------------------------|*
  29. // *****************************************************************************
  30.  
  31. // ***************************** [ Checkpoints ] *******************************
  32. // |--------------------------------------------------------------------------|*
  33. // |*
  34. CreateCheckpoint(GLOBAL_OWNER_ID, BUYING, // |*
  35. 1717.9043, -1628.7946, 20.2077); // |*
  36.  
  37. // |*
  38. // |*
  39. // |*
  40. // |*
  41. // |*
  42. StartCheckpointSeeking(); // |*
  43. // |*
  44. // |--------------------------------------------------------------------------|*
  45. // *****************************************************************************
  46.  
  47. return 1;
  48. }
  49.  
  50. stock GetPlayerNameEx(playerid)
  51. {
  52. new name[MAX_PLAYER_NAME];
  53. GetPlayerName(playerid, name, sizeof(name));
  54. return name;
  55. }
  56.  
  57. enum pData
  58. {
  59. ptokens
  60. }
  61. new PlayerInfo[MAX_PLAYERS + 1][pData];
  62.  
  63. forward LoadUser_Data(playerid,TarID,name[],value[]);
  64. public LoadUser_Data(playerid,TarID,name[],value[])
  65. {
  66. INI_Int("Tokens:", PlayerInfo[TarID][ptokens]);
  67. INI_Int("Tokens:", PlayerInfo[playerid][ptokens]);
  68. return 1;
  69. }
  70.  
  71. stock UserPath(TarID)
  72. {
  73. new string[128],pName[MAX_PLAYER_NAME];
  74. GetPlayerName(TarID,pName,MAX_PLAYER_NAME);
  75. format(string,sizeof(string),PATH,pName);
  76. return string;
  77. }
  78.  
  79.  
  80. COMMAND:settokens(playerid, params[])
  81. {
  82. new TarID, amount;
  83. if(sscanf(params,"ui",TarID,amount)) return SendClientMessage(playerid,COLOR_RED,"Syntax: [Playerid] [tokens]");
  84. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You're not authorized to use this command");
  85. if(!IsPlayerConnected(TarID)) return SendClientMessage(playerid,COLOR_RED,"Check your entry.~n~Player is not Connected to the game");
  86. new currentok = PlayerInfo[TarID][ptokens];
  87. PlayerInfo[TarID][ptokens] = currentok + amount;
  88. new INI:File = INI_Open(UserPath(TarID));
  89. INI_SetTag(File, "VIP Tokens");
  90. INI_WriteInt(File,"Tokens:", PlayerInfo[TarID][ptokens]);
  91. INI_Close(File);
  92. return 1;
  93. }
  94.  
  95.  
  96. COMMAND:givetokens(playerid, params[])
  97. {
  98. new string[128], TarID, amount;
  99. if(sscanf(params, "us[32]d", TarID, amount))
  100. {
  101. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /give [playerid/partofname] [amount]");
  102. return 1;
  103. }
  104. if(TarID == playerid)
  105. {
  106. SendClientMessage(playerid, COLOR_GREY, "You can't use this command on yourself!");
  107. return 1;
  108. }
  109.  
  110. if(PlayerInfo[playerid][ptokens] >= amount)
  111. {
  112. PlayerInfo[TarID][ptokens] += amount;
  113. PlayerInfo[playerid][ptokens] -= amount;
  114. format(string, sizeof(string), "You have recieved %d Tokens from %s.", amount, GetPlayerNameEx(playerid));
  115. SendClientMessage(TarID, COLOR_GRAD2, string);
  116. format(string, sizeof(string), "You have given %s %d Tokens.", GetPlayerNameEx(TarID), amount);
  117. SendClientMessage(playerid, COLOR_GRAD2, string);
  118. }
  119. else
  120. {
  121. SendClientMessage(playerid, COLOR_GREY, "You don't have that much!");
  122. }
  123. return 1;
  124. }
  125.  
  126.  
  127. forward OnPlayerConnect(playerid);
  128. public OnPlayerConnect(playerid)
  129. {
  130. if(fexist(UserPath(playerid)))
  131. {
  132. INI_ParseFile(UserPath(playerid), "LoadUser_%s",.bExtra =true, .extra =playerid);
  133. }
  134. else if(!fexist(UserPath(playerid)))
  135. {
  136. new INI:File = INI_Open(UserPath(playerid));
  137. INI_SetTag(File,"VIP Tokens");
  138. INI_WriteInt(File,"Tokens:", 0);
  139. INI_Close(File);
  140. }
  141. return 1;
  142. }
  143. forward CheckTokens(playerid);
  144. public CheckTokens(playerid)
  145. {
  146. new INI:File = INI_Open(UserPath(playerid));
  147. INI_SetTag(File, "VIP Tokens");
  148. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  149. INI_Close(File);
  150. return 1;
  151. }
  152.  
  153.  
  154. public OnPlayerEnterCheckpoint(playerid)
  155. {
  156.  
  157. VerifyCheckpoint(playerid); //Asks the CpMngr to check this cp
  158. return 1;
  159.  
  160. }
  161.  
  162. public OnCheckpointEnter(playerid, checkpointid)
  163. {
  164. switch(checkpointid)
  165. {
  166. case BUYING:
  167. {
  168. ShowPlayerDialog(playerid, FIRSTMENU, DIALOG_STYLE_LIST,
  169. "Regular Players Lounge",
  170. "MP5\nShotgun\nDesert Eagle\nCombat Shotgun\nM4\nAK-47\nSniper Rifle",
  171. "Select", "Exit");
  172. }
  173. }
  174. return 1;
  175.  
  176. }
  177.  
  178. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  179. {
  180.  
  181. if(dialogid == FIRSTMENU)
  182. {
  183.  
  184. {
  185. if(response)
  186. {
  187. if(listitem == 0) // MP5
  188. {
  189.  
  190. if(PlayerInfo[playerid][ptokens] >= 5)
  191. {
  192. SendClientMessage(playerid, COLOR_GREY,"* Recieved your GUN, HAVE FUN ! ");
  193. PlayerInfo[playerid][ptokens] -= 5;
  194. GivePlayerWeapon(playerid, 29, 200);
  195. new INI:File = INI_Open(UserPath(playerid));
  196. INI_SetTag(File, "VIP Tokens");
  197. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  198. INI_Close(File);
  199. }
  200. else
  201. {
  202. SendClientMessage(playerid, COLOR_GREY,"* You cannot afford this!");
  203. }
  204. if(listitem == 1) // Shotgun
  205. {
  206.  
  207. if(PlayerInfo[playerid][ptokens] >= 5)
  208. {
  209. SendClientMessage(playerid, COLOR_GREY,"* Recieved your GUN, HAVE FUN ! ");
  210. PlayerInfo[playerid][ptokens] += -5;
  211. GivePlayerWeapon(playerid, 25, 50);
  212. new INI:File = INI_Open(UserPath(playerid));
  213. INI_SetTag(File, "VIP Tokens");
  214. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  215. INI_Close(File);
  216. }
  217. else
  218. {
  219. SendClientMessage(playerid, COLOR_GREY,"* You cannot afford this!");
  220. }
  221. if(listitem == 2) // Deagle
  222. {
  223.  
  224. if(PlayerInfo[playerid][ptokens] >= 5)
  225. {
  226. SendClientMessage(playerid, COLOR_GREY,"* Recieved your GUN, HAVE FUN ! ");
  227. PlayerInfo[playerid][ptokens] += -5;
  228. GivePlayerWeapon(playerid, 24, 100);
  229. new INI:File = INI_Open(UserPath(playerid));
  230. INI_SetTag(File, "VIP Tokens");
  231. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  232. INI_Close(File);
  233. }
  234. else
  235. {
  236. SendClientMessage(playerid, COLOR_GREY,"* You cannot afford this!");
  237. }
  238. if(listitem == 3) // Combat Shotgun
  239. {
  240.  
  241. if(PlayerInfo[playerid][ptokens] >= 5)
  242. {
  243. SendClientMessage(playerid, COLOR_GREY,"* Recieved your GUN, HAVE FUN ! ");
  244. PlayerInfo[playerid][ptokens] += -5;
  245. GivePlayerWeapon(playerid, 27, 200);
  246. new INI:File = INI_Open(UserPath(playerid));
  247. INI_SetTag(File, "VIP Tokens");
  248. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  249. INI_Close(File);
  250. }
  251. else
  252. {
  253. SendClientMessage(playerid, COLOR_GREY,"* You cannot afford this!");
  254. }
  255. if(listitem == 4) //M4
  256. {
  257.  
  258. if(PlayerInfo[playerid][ptokens] >= 5)
  259. {
  260. SendClientMessage(playerid, COLOR_GREY,"* Recieved your GUN, HAVE FUN ! ");
  261. PlayerInfo[playerid][ptokens] += -5;
  262. GivePlayerWeapon(playerid, 31, 50);
  263. new INI:File = INI_Open(UserPath(playerid));
  264. INI_SetTag(File, "VIP Tokens");
  265. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  266. INI_Close(File);
  267. }
  268. else
  269. {
  270. SendClientMessage(playerid, COLOR_GREY,"* You cannot afford this!");
  271. }
  272. if(listitem == 5) // AK
  273. {
  274.  
  275. if(PlayerInfo[playerid][ptokens] >= 5)
  276. {
  277. SendClientMessage(playerid, COLOR_GREY,"* Recieved your GUN, HAVE FUN ! ");
  278. PlayerInfo[playerid][ptokens] += -5;
  279. GivePlayerWeapon(playerid, 30, 200);
  280. new INI:File = INI_Open(UserPath(playerid));
  281. INI_SetTag(File, "VIP Tokens");
  282. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  283. INI_Close(File);
  284. }
  285. else
  286. {
  287. SendClientMessage(playerid, COLOR_GREY,"* You cannot afford this!");
  288. }
  289. if(listitem == 6) // Sniper
  290. {
  291.  
  292. if(PlayerInfo[playerid][ptokens] >= 5)
  293. {
  294. SendClientMessage(playerid, COLOR_GREY,"* Recieved your GUN, HAVE FUN ! ");
  295. PlayerInfo[playerid][ptokens] += -5;
  296. GivePlayerWeapon(playerid, 34, 50);
  297. new INI:File = INI_Open(UserPath(playerid));
  298. INI_SetTag(File, "VIP Tokens");
  299. INI_WriteInt(File,"Tokens:", PlayerInfo[playerid][ptokens]);
  300. INI_Close(File);
  301. }
  302. else
  303. {
  304. SendClientMessage(playerid, COLOR_GREY,"* You cannot afford this!");
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. return 1;
  317. }
Advertisement
Add Comment
Please, Sign In to add comment