Advertisement
Guest User

Sandra

a guest
Jan 1st, 2009
1,493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.30 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define MinSkinPrice 50
  4. #define MaxSkinPrice 100
  5.  
  6. new IsInShop[MAX_PLAYERS];
  7. new KeyTimer[MAX_PLAYERS];
  8. new wait[MAX_PLAYERS];
  9. new count[MAX_PLAYERS];
  10. new HasBoughtNewSkin[MAX_PLAYERS];
  11. new Float:LastPos[MAX_PLAYERS][4], LastInterior[MAX_PLAYERS], LastVW[MAX_PLAYERS], LastSkin[MAX_PLAYERS];
  12. new Text:TextDraw[MAX_PLAYERS];
  13. new TextDrawString[MAX_PLAYERS][128];
  14. new TextdrawActive[MAX_PLAYERS];
  15. new Skin[MAX_PLAYERS];
  16. new IsDead[MAX_PLAYERS];
  17.  
  18. /*
  19. DO NOT USE THESE SKIN-ID's!!!!!! They will crash the client/server
  20. 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 273, 289
  21. */
  22.  
  23.  
  24. new AvailableSkins[] =
  25. {
  26. 0, 1, 2, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  27. 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
  28. 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48,
  29. 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
  30. 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78,
  31. 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93,
  32. 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
  33. 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
  34. 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128,
  35. 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
  36. 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 151,
  37. 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
  38. 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
  39. 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
  40. 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
  41. 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
  42. 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
  43. 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
  44. 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240,
  45. 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
  46. 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262,
  47. 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 274,
  48. 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
  49. 286, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297,
  50. 298, 299
  51. };
  52.  
  53. new SkinPrices[sizeof(AvailableSkins)];
  54.  
  55. new TotalSkins = sizeof(AvailableSkins);
  56.  
  57. public OnFilterScriptInit()
  58. {
  59. print("\n---------------------------------------------");
  60. print(" [FS]ClothingStore by =>Sandra<= Loaded! ");
  61. print("---------------------------------------------\n");
  62. MakeSkinPriceArray();
  63. return 1;
  64. }
  65.  
  66. public OnPlayerConnect(playerid)
  67. {
  68. IsInShop[playerid] = 0;
  69. KeyTimer[playerid] = -1;
  70. wait[playerid] = 0;
  71. count[playerid] = 0;
  72. HasBoughtNewSkin[playerid] = 0;
  73. LastPos[playerid][0] = 0;
  74. LastPos[playerid][1] = 0;
  75. LastPos[playerid][2] = 0;
  76. LastPos[playerid][3] = 0;
  77. LastInterior[playerid] = 0;
  78. LastVW[playerid] = 0;
  79. LastSkin[playerid] = 0;
  80. TextdrawActive[playerid] = 0;
  81. Skin[playerid] = 0;
  82. IsDead[playerid] = 0;
  83. return 1;
  84. }
  85.  
  86. public OnPlayerDisconnect(playerid, reason)
  87. {
  88. if(TextdrawActive[playerid] == 1)
  89. {
  90. TextDrawHideForPlayer(playerid, TextDraw[playerid]);
  91. TextDrawDestroy(TextDraw[playerid]);
  92. }
  93. }
  94.  
  95. public OnPlayerDeath(playerid, killerid, reason)
  96. {
  97. IsDead[playerid] = 1;
  98. return 1;
  99. }
  100.  
  101. public OnPlayerSpawn(playerid)
  102. {
  103. if(IsDead[playerid] == 1)
  104. {
  105. SetPlayerSkin(playerid, Skin[playerid]);
  106. IsDead[playerid] = 0;
  107. }
  108. return 1;
  109. }
  110.  
  111.  
  112. public OnPlayerCommandText(playerid, cmdtext[])
  113. {
  114. if (strcmp("/enterstore", cmdtext, true) == 0)
  115. {
  116. count[playerid] = 0;
  117. format(TextDrawString[playerid], 128, "~y~Press ~r~~k~~PED_SPRINT~ ~y~to buy this skin~n~Price: ~r~$%d~n~~n~~y~(%d/%d)", SkinPrices[count[playerid]], count[playerid]+1, TotalSkins);
  118. TextDraw[playerid] = TextDrawCreate(320, 390, TextDrawString[playerid]);
  119. TextDrawLetterSize(TextDraw[playerid],0.40,1.10);
  120. TextDrawAlignment(TextDraw[playerid], 2);
  121. TextDrawSetShadow(TextDraw[playerid], 0);
  122. TextDrawSetOutline(TextDraw[playerid], 1);
  123. TextDrawUseBox(TextDraw[playerid], 1);
  124. TextDrawBoxColor(TextDraw[playerid], 0x000000AA);
  125. TextDrawTextSize(TextDraw[playerid], 250, 220);
  126. TextDrawShowForPlayer(playerid, TextDraw[playerid]);
  127. TextdrawActive[playerid] = 1;
  128.  
  129. //GameTextForPlayer(playerid, str, 99999999, 3);
  130. HasBoughtNewSkin[playerid] = 0;
  131. GetPlayerPos(playerid, LastPos[playerid][0], LastPos[playerid][1], LastPos[playerid][2]);
  132. GetPlayerFacingAngle(playerid, LastPos[playerid][3]);
  133. LastInterior[playerid] = GetPlayerInterior(playerid);
  134. LastVW[playerid] = GetPlayerVirtualWorld(playerid);
  135. LastSkin[playerid] = GetPlayerSkin(playerid);
  136. SetPlayerVirtualWorld(playerid, playerid+1);
  137. SetPlayerInterior(playerid, 18);
  138. SetPlayerPos(playerid, 181.7410,-87.4888,1002.0234);
  139. SetPlayerFacingAngle(playerid, 128.0);
  140. SetPlayerCameraPos(playerid, 178.2804,-89.5319,1003.0234);
  141. SetPlayerCameraLookAt(playerid, 181.7410,-87.4888,1002.0234);
  142. TogglePlayerControllable(playerid, 0);
  143. IsInShop[playerid] = 1;
  144. KeyTimer[playerid] = SetTimerEx("CheckKeyPress", 75, 1, "i", playerid);
  145. wait[playerid] = 0;
  146. SetPlayerSkin(playerid, AvailableSkins[0]);
  147. SendClientMessage(playerid, 0x40E0D0AA, "Welcome in the clothing store. Use the arrowkeys to scroll through available skins");
  148. SendClientMessage(playerid, 0x40E0D000, "Use /exitstore to exit the store without buying a new skin.");
  149.  
  150. return 1;
  151. }
  152. if (strcmp("/exitstore", cmdtext, true) == 0)
  153. {
  154. if(IsInShop[playerid] == 1)
  155. {
  156. KillTimer(KeyTimer[playerid]);
  157. GameTextForPlayer(playerid, " ", 10, 6);
  158. SetPlayerInterior(playerid, LastInterior[playerid]);
  159. SetPlayerPos(playerid, LastPos[playerid][0], LastPos[playerid][1], LastPos[playerid][2]);
  160. SetPlayerFacingAngle(playerid, LastPos[playerid][3]);
  161. TextDrawHideForPlayer(playerid, TextDraw[playerid]);
  162. TextdrawActive[playerid] = 0;
  163. TextDrawDestroy(TextDraw[playerid]);
  164. SetPlayerVirtualWorld(playerid, LastVW[playerid]);
  165. if(HasBoughtNewSkin[playerid] == 0)
  166. {
  167. SetPlayerSkin(playerid, LastSkin[playerid]);
  168. }
  169. TogglePlayerControllable(playerid, 1);
  170. SetCameraBehindPlayer(playerid);
  171. IsInShop[playerid] = 0;
  172. wait[playerid] = 0;
  173. count[playerid] = 0;
  174. }
  175. else
  176. {
  177. SendClientMessage(playerid, 0xFF0000AA, "You're not the Clothing-Shop! Use /enterstore to enter!");
  178. }
  179. return 1;
  180. }
  181. if (strcmp("/gotoskin", cmdtext, true, 9) == 0)
  182. {
  183. if(IsInShop[playerid] == 1)
  184. {
  185. new str[128];
  186. if(!strlen(cmdtext[10]))
  187. {
  188. format(str, 128, "Use: /gotoskin [1-%d]", TotalSkins);
  189. SendClientMessage(playerid, 0xFF0000AA, str);
  190. return 1;
  191. }
  192. new skin = strval(cmdtext[10]);
  193. if(skin < 1 || skin > TotalSkins)
  194. {
  195. format(str, 128, "Invalid Number! Use /gotoskin [1-%d]", TotalSkins);
  196. SendClientMessage(playerid, 0xFF0000AA, str);
  197. return 1;
  198. }
  199. count[playerid] = skin-1;
  200. SetPlayerSkin(playerid, AvailableSkins[count[playerid]]);
  201. wait[playerid] = 1;
  202. SetTimerEx("ResetWait", 90, 0, "i", playerid);
  203. format(TextDrawString[playerid], 128, "~y~Press ~r~~k~~PED_SPRINT~ ~y~to buy this skin~n~Price: ~r~$%d~n~~n~~y~(%d/%d)", SkinPrices[count[playerid]], count[playerid]+1, TotalSkins);
  204. TextDrawHideForPlayer(playerid, TextDraw[playerid]);
  205. TextdrawActive[playerid] = 0;
  206. TextDrawSetString(TextDraw[playerid], TextDrawString[playerid]);
  207. TextDrawShowForPlayer(playerid, TextDraw[playerid]);
  208. TextdrawActive[playerid] = 1;
  209. }
  210. else
  211. {
  212. SendClientMessage(playerid, 0xFF0000AA, "You're not the Clothing-Shop! Use /enterstore to enter!");
  213. }
  214. return 1;
  215. }
  216. return 0;
  217. }
  218.  
  219. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  220. {
  221. if(IsInShop[playerid] == 1)
  222. {
  223. if (newkeys & KEY_SPRINT)
  224. {
  225. if(GetPlayerMoney(playerid) < SkinPrices[count[playerid]])
  226. {
  227. GameTextForPlayer(playerid, "~r~Not Enough Money!", 9999999, 3);
  228. }
  229. else
  230. {
  231. PlayerPlaySound(playerid, 1139, 181.7410,-87.4888,1002.023);
  232. GivePlayerMoney(playerid, (0-SkinPrices[count[playerid]]));
  233. Skin[playerid] = AvailableSkins[count[playerid]];
  234. TextDrawHideForPlayer(playerid, TextDraw[playerid]);
  235. TextdrawActive[playerid] = 0;
  236. TextDrawDestroy(TextDraw[playerid]);
  237. HasBoughtNewSkin[playerid] = 1;
  238. OnPlayerCommandText(playerid, "/exitstore");
  239. }
  240. }
  241. }
  242. }
  243.  
  244. forward CheckKeyPress(playerid);
  245. public CheckKeyPress(playerid)
  246. {
  247. if(wait[playerid] == 0)
  248. {
  249. new keys, updown, leftright;
  250. GetPlayerKeys(playerid, keys, updown, leftright);
  251. if(leftright == KEY_RIGHT)
  252. {
  253. if(IsInShop[playerid] == 1)
  254. {
  255. count[playerid]++;
  256. if(count[playerid] > TotalSkins)
  257. {
  258. count[playerid] = 0;
  259. }
  260. SetPlayerSkin(playerid, AvailableSkins[count[playerid]]);
  261. wait[playerid] = 1;
  262. SetTimerEx("ResetWait", 90, 0, "i", playerid);
  263. format(TextDrawString[playerid], 128, "~y~Press ~r~~k~~PED_SPRINT~ ~y~to buy this skin~n~Price: ~r~$%d~n~~n~~y~(%d/%d)", SkinPrices[count[playerid]], count[playerid]+1, TotalSkins);
  264. TextDrawHideForPlayer(playerid, TextDraw[playerid]);
  265. TextdrawActive[playerid] = 0;
  266. TextDrawSetString(TextDraw[playerid], TextDrawString[playerid]);
  267. TextDrawShowForPlayer(playerid, TextDraw[playerid]);
  268. TextdrawActive[playerid] = 1;
  269. }
  270. }
  271. if(leftright == KEY_LEFT)
  272. {
  273. if(IsInShop[playerid] == 1)
  274. {
  275. count[playerid]--;
  276. if(count[playerid] == -1)
  277. {
  278. count[playerid] = TotalSkins;
  279. }
  280. SetPlayerSkin(playerid, AvailableSkins[count[playerid]]);
  281. wait[playerid] = 1;
  282. SetTimerEx("ResetWait", 90, 0, "i", playerid);
  283. format(TextDrawString[playerid], 128, "~y~Press ~r~~k~~PED_SPRINT~ ~y~to buy this skin~n~Price: ~r~$%d~n~~n~~y~(%d/%d)", SkinPrices[count[playerid]], count[playerid]+1, TotalSkins);
  284. TextDrawHideForPlayer(playerid, TextDraw[playerid]);
  285. TextdrawActive[playerid] = 0;
  286. TextDrawSetString(TextDraw[playerid], TextDrawString[playerid]);
  287. TextDrawShowForPlayer(playerid, TextDraw[playerid]);
  288. TextdrawActive[playerid] = 1;
  289. }
  290. }
  291. }
  292. }
  293.  
  294. forward ResetWait(playerid);
  295. public ResetWait(playerid)
  296. {
  297. wait[playerid] = 0;
  298. }
  299.  
  300. MakeSkinPriceArray()
  301. {
  302. for(new i; i<sizeof(SkinPrices); i++)
  303. {
  304. SkinPrices[i] = (random(MaxSkinPrice-MinSkinPrice)+MinSkinPrice);
  305. }
  306. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement