Guest User

Untitled

a guest
Nov 7th, 2016
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <dini>
  7. #include <zcmd>
  8.  
  9. #define COLOR_GREY 0xAFAFAFAA
  10. #define COLOR_GREEN 0x33AA33AA
  11. #define COLOR_ORANGE 0xFF9900AA
  12. #define COLOR_RED 0xAA3333AA
  13. #define COLOR_YELLOW 0xFFFF00AA
  14. #define SERVER_USER_FILE "Coins/%s.ini"
  15.  
  16. enum pInfo
  17. {
  18. pCoins
  19. }
  20. new PlayerInfo[MAX_PLAYERS][pInfo];
  21.  
  22. new PlayerText:Cashbar[MAX_PLAYERS];
  23. new PlayerText:Cashbar1[MAX_PLAYERS];
  24. new PlayerText:Cashbar2[MAX_PLAYERS];
  25. new PlayerText:Cashbar3[MAX_PLAYERS];
  26. new PlayerText:Cashbar4[MAX_PLAYERS];
  27. new PlayerText:Cashbar5[MAX_PLAYERS];
  28. new PlayerText:Cashbar6[MAX_PLAYERS];
  29.  
  30. public OnFilterScriptInit()
  31. {
  32. SetTimer("cashbarreload",1000,true);
  33. return 1;
  34. }
  35.  
  36. public OnFilterScriptExit()
  37. {
  38. return 1;
  39. }
  40.  
  41. public OnPlayerConnect(playerid)
  42. {
  43. new name[MAX_PLAYER_NAME], file[256];
  44. GetPlayerName( playerid, name, sizeof name ); // Added thiz
  45. format(file, sizeof(file), SERVER_USER_FILE, name);
  46. if (!dini_Exists(file))
  47. {
  48. dini_Create(file);
  49. dini_IntSet(file, "Coins",PlayerInfo[playerid][pCoins] = 0);
  50. }
  51. if(fexist(file))
  52. {
  53. GiveCoins(playerid, dini_Int(file, "Coins")-PlayerInfo[playerid][pCoins]);
  54. }
  55. LoadTDs(playerid);
  56. return 1;
  57. }
  58.  
  59. public OnPlayerDisconnect(playerid, reason)
  60. {
  61. new name[MAX_PLAYER_NAME], file[256];
  62. GetPlayerName(playerid, name, sizeof(name));
  63. format(file, sizeof(file), SERVER_USER_FILE, name);
  64. dini_IntSet(file, "Coins", PlayerInfo[playerid][pCoins]);
  65. return 1;
  66. }
  67.  
  68. public OnPlayerSpawn(playerid)
  69. {
  70. new iString[70];
  71. PlayerTextDrawShow(playerid, Cashbar[playerid]);
  72. PlayerTextDrawShow(playerid, Cashbar1[playerid]);
  73. PlayerTextDrawShow(playerid, Cashbar2[playerid]);
  74. PlayerTextDrawShow(playerid, Cashbar3[playerid]);
  75. PlayerTextDrawShow(playerid, Cashbar4[playerid]);
  76. PlayerTextDrawShow(playerid, Cashbar5[playerid]);
  77. PlayerTextDrawShow(playerid, Cashbar6[playerid]);
  78. format(iString, sizeof(iString), "%d", PlayerInfo[playerid][pCoins]);
  79. PlayerTextDrawSetString(playerid, Cashbar2[playerid], iString);
  80. SetTimerEx("cashbar", 500, false, "i", playerid);
  81. return 1;
  82. }
  83.  
  84. stock LoadTDs(playerid)
  85. {
  86. Cashbar[playerid] = CreatePlayerTextDraw(playerid,495.000000, 78.000000, "Box");
  87. PlayerTextDrawBackgroundColor(playerid,Cashbar[playerid], 255);
  88. PlayerTextDrawFont(playerid,Cashbar[playerid], 5);
  89. PlayerTextDrawLetterSize(playerid,Cashbar[playerid], 0.500000, -4.000000);
  90. PlayerTextDrawColor(playerid,Cashbar[playerid], -1);
  91. PlayerTextDrawSetOutline(playerid,Cashbar[playerid], 1);
  92. PlayerTextDrawSetProportional(playerid,Cashbar[playerid], 1);
  93. PlayerTextDrawUseBox(playerid,Cashbar[playerid], 1);
  94. PlayerTextDrawBoxColor(playerid,Cashbar[playerid], 16711935);
  95. PlayerTextDrawTextSize(playerid,Cashbar[playerid], 116.000000, 21.000000);
  96. PlayerTextDrawSetPreviewModel(playerid, Cashbar[playerid], 4);
  97. PlayerTextDrawSetPreviewRot(playerid, Cashbar[playerid], -16.000000, 0.000000, -55.000000, 412.000000);
  98. PlayerTextDrawSetSelectable(playerid,Cashbar[playerid], 0);
  99.  
  100. Cashbar1[playerid] = CreatePlayerTextDraw(playerid,497.000000, 79.000000, "Coins:");
  101. PlayerTextDrawBackgroundColor(playerid,Cashbar1[playerid], 0);
  102. PlayerTextDrawFont(playerid,Cashbar1[playerid], 1);
  103. PlayerTextDrawLetterSize(playerid,Cashbar1[playerid], 0.310000, 1.699999);
  104. PlayerTextDrawColor(playerid,Cashbar1[playerid], 566597375);
  105. PlayerTextDrawSetOutline(playerid,Cashbar1[playerid], 0);
  106. PlayerTextDrawSetProportional(playerid,Cashbar1[playerid], 1);
  107. PlayerTextDrawSetShadow(playerid,Cashbar1[playerid], 1);
  108. PlayerTextDrawSetPreviewModel(playerid, Cashbar1[playerid], 1274);
  109. PlayerTextDrawSetPreviewRot(playerid, Cashbar1[playerid], -16.000000, 0.000000, 200.000000, 1.000000);
  110. PlayerTextDrawSetSelectable(playerid,Cashbar1[playerid], 0);
  111.  
  112. Cashbar2[playerid] = CreatePlayerTextDraw(playerid,531.000000, 83.000000, "544,444,444,4");
  113. PlayerTextDrawBackgroundColor(playerid,Cashbar2[playerid], 255);
  114. PlayerTextDrawFont(playerid,Cashbar2[playerid], 1);
  115. PlayerTextDrawLetterSize(playerid,Cashbar2[playerid], 0.300000, 1.100000);
  116. PlayerTextDrawColor(playerid,Cashbar2[playerid], -1);
  117. PlayerTextDrawSetOutline(playerid,Cashbar2[playerid], 0);
  118. PlayerTextDrawSetProportional(playerid,Cashbar2[playerid], 1);
  119. PlayerTextDrawSetShadow(playerid,Cashbar2[playerid], 1);
  120. PlayerTextDrawSetSelectable(playerid,Cashbar2[playerid], 0);
  121.  
  122. Cashbar3[playerid] = CreatePlayerTextDraw(playerid,495.000000, 78.000000, "Box");
  123. PlayerTextDrawBackgroundColor(playerid,Cashbar3[playerid], -457637633);
  124. PlayerTextDrawFont(playerid,Cashbar3[playerid], 5);
  125. PlayerTextDrawLetterSize(playerid,Cashbar3[playerid], 0.500000, -4.000000);
  126. PlayerTextDrawColor(playerid,Cashbar3[playerid], -1);
  127. PlayerTextDrawSetOutline(playerid,Cashbar3[playerid], 1);
  128. PlayerTextDrawSetProportional(playerid,Cashbar3[playerid], 1);
  129. PlayerTextDrawUseBox(playerid,Cashbar3[playerid], 1);
  130. PlayerTextDrawBoxColor(playerid,Cashbar3[playerid], 16711935);
  131. PlayerTextDrawTextSize(playerid,Cashbar3[playerid], 116.000000, 2.000000);
  132. PlayerTextDrawSetPreviewModel(playerid, Cashbar3[playerid], 4);
  133. PlayerTextDrawSetPreviewRot(playerid, Cashbar3[playerid], -16.000000, 0.000000, -55.000000, 412.000000);
  134. PlayerTextDrawSetSelectable(playerid,Cashbar3[playerid], 0);
  135.  
  136. Cashbar4[playerid] = CreatePlayerTextDraw(playerid,495.000000, 97.000000, "Box");
  137. PlayerTextDrawBackgroundColor(playerid,Cashbar4[playerid], -457637633);
  138. PlayerTextDrawFont(playerid,Cashbar4[playerid], 5);
  139. PlayerTextDrawLetterSize(playerid,Cashbar4[playerid], 0.500000, -4.000000);
  140. PlayerTextDrawColor(playerid,Cashbar4[playerid], -1);
  141. PlayerTextDrawSetOutline(playerid,Cashbar4[playerid], 1);
  142. PlayerTextDrawSetProportional(playerid,Cashbar4[playerid], 1);
  143. PlayerTextDrawUseBox(playerid,Cashbar4[playerid], 1);
  144. PlayerTextDrawBoxColor(playerid,Cashbar4[playerid], 16711935);
  145. PlayerTextDrawTextSize(playerid,Cashbar4[playerid], 116.000000, 2.000000);
  146. PlayerTextDrawSetPreviewModel(playerid, Cashbar4[playerid], 4);
  147. PlayerTextDrawSetPreviewRot(playerid, Cashbar4[playerid], -16.000000, 0.000000, -55.000000, 412.000000);
  148. PlayerTextDrawSetSelectable(playerid,Cashbar4[playerid], 0);
  149.  
  150. Cashbar5[playerid] = CreatePlayerTextDraw(playerid,495.000000, 99.000000, "Box");
  151. PlayerTextDrawBackgroundColor(playerid,Cashbar5[playerid], -457637633);
  152. PlayerTextDrawFont(playerid,Cashbar5[playerid], 5);
  153. PlayerTextDrawLetterSize(playerid,Cashbar5[playerid], 0.500000, -4.000000);
  154. PlayerTextDrawColor(playerid,Cashbar5[playerid], -1);
  155. PlayerTextDrawSetOutline(playerid,Cashbar5[playerid], 1);
  156. PlayerTextDrawSetProportional(playerid,Cashbar5[playerid], 1);
  157. PlayerTextDrawUseBox(playerid,Cashbar5[playerid], 1);
  158. PlayerTextDrawBoxColor(playerid,Cashbar5[playerid], 16711935);
  159. PlayerTextDrawTextSize(playerid,Cashbar5[playerid], -3.000000, -21.000000);
  160. PlayerTextDrawSetPreviewModel(playerid, Cashbar5[playerid], 4);
  161. PlayerTextDrawSetPreviewRot(playerid, Cashbar5[playerid], -16.000000, 0.000000, -55.000000, 412.000000);
  162. PlayerTextDrawSetSelectable(playerid,Cashbar5[playerid], 0);
  163.  
  164. Cashbar6[playerid] = CreatePlayerTextDraw(playerid,614.000000, 99.000000, "Box");
  165. PlayerTextDrawBackgroundColor(playerid,Cashbar6[playerid], -457637633);
  166. PlayerTextDrawFont(playerid,Cashbar6[playerid], 5);
  167. PlayerTextDrawLetterSize(playerid,Cashbar6[playerid], 0.500000, -4.000000);
  168. PlayerTextDrawColor(playerid,Cashbar6[playerid], -1);
  169. PlayerTextDrawSetOutline(playerid,Cashbar6[playerid], 1);
  170. PlayerTextDrawSetProportional(playerid,Cashbar6[playerid], 1);
  171. PlayerTextDrawUseBox(playerid,Cashbar6[playerid], 1);
  172. PlayerTextDrawBoxColor(playerid,Cashbar6[playerid], 16711935);
  173. PlayerTextDrawTextSize(playerid,Cashbar6[playerid], -3.000000, -21.000000);
  174. PlayerTextDrawSetPreviewModel(playerid, Cashbar6[playerid], 4);
  175. PlayerTextDrawSetPreviewRot(playerid, Cashbar6[playerid], -16.000000, 0.000000, -55.000000, 412.000000);
  176. PlayerTextDrawSetSelectable(playerid,Cashbar6[playerid], 0);
  177. }
  178.  
  179. stock GiveOneCoin(playerid)
  180. {
  181. PlayerInfo[playerid][pCash]++;
  182. PlayerTextDrawShow(playerid, Cashbar3[playerid]);
  183. SetTimerEx("received", 4000, false, "i", playerid);
  184. }
  185.  
  186. stock GiveCoins(playerid, coins)
  187. {
  188. PlayerInfo[playerid][pCoins]+=coins;
  189. PlayerTextDrawShow(playerid, Cashbar3[playerid]);
  190. SetTimerEx("received", 4000, false, "i", playerid);
  191. return 1;
  192. }
  193.  
  194. forward received(playerid);
  195. public received(playerid)
  196. {
  197. PlayerTextDrawHide(playerid, Cashbar3[playerid]);
  198. return 1;
  199. }
  200.  
  201. forward cashbarreload();
  202. public cashbarreload()
  203. {
  204. for(new i=0; i<MAX_PLAYERS; i++)
  205. {
  206. new iString[75];
  207. format(iString, sizeof(iString), "%d", PlayerInfo[i][pCoins]);
  208. PlayerTextDrawSetString(i, Cashbar2[i], iString);
  209. }
  210. return 1;
  211. }
Advertisement
Add Comment
Please, Sign In to add comment