Advertisement
Guest User

Sa-mp furniture system by jueix

a guest
May 28th, 2012
3,932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.34 KB | None | 0 0
  1. //furniture buying and saving system by jueix.
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <dini>
  6. #include <dudb>
  7. #include <zcmd>
  8. #include <streamer>
  9. //coord saver of objects
  10. new Float:CX;
  11. new Float:CY;
  12. new Float:CZ;
  13. new Float:BX;
  14. new Float:BY;
  15. new Float:BZ;
  16. new Float:TX;
  17. new Float:TY;
  18. new Float:TZ;
  19. enum
  20. Finfo
  21. {
  22. NAME,
  23. HASCHAIR,
  24. HASBED,
  25. HASTABLE,
  26. CHAIRID,
  27. BEDID,
  28. TABLEID,
  29. Cworld,
  30. Cint,
  31. Tworld,
  32. Tint,
  33. Bworld,
  34. Bint,
  35. Pc,
  36. Pt,
  37. Pb
  38. };
  39.  
  40. new fInfo[MAX_PLAYERS][Finfo];
  41.  
  42. public OnFilterScriptInit()
  43. {
  44. print("\n--------------------------------------");
  45. print(" furniture system buy jueix.");
  46. print("--------------------------------------\n");
  47. CreateObject(1498, -1132.59, -2859.42, 269.56, 0.00, 0.00, 107.20);
  48. CreateObject(3032, -1143.17, -2865.04, 270.78, 0.00, 0.00, 18.13);
  49. CreateObject(3032, -1145.59, -2863.70, 271.01, 0.00, 0.00, 288.70);
  50. CreateObject(3032, -1148.15, -2855.98, 271.01, 0.00, 0.00, 288.70);
  51. CreateObject(1498, -1146.03, -2861.80, 269.56, 0.00, 0.00, 108.55);
  52. CreateObject(3032, -1146.55, -2853.71, 270.78, 0.00, 0.00, 192.00);
  53. CreateObject(3032, -1134.70, -2852.66, 270.78, 0.00, 0.00, 289.13);
  54. CreateObject(3032, -1133.48, -2861.87, 270.78, 0.00, 0.00, 18.70);
  55. CreateObject(19506, -1140.95, -2857.92, 271.40, 0.00, 0.00, 18.54);
  56. CreateObject(3032, -1136.56, -2862.93, 270.78, 0.00, 0.00, 18.70);
  57. CreateObject(3032, -1139.78, -2863.99, 270.78, 0.00, 0.00, 18.13);
  58. CreateObject(2626, -1143.30, -2863.27, 270.08, 0.00, 0.00, 200.28);
  59. CreateObject(1802, -1146.44, -2858.14, 269.62, 0.00, 0.00, 19.80);
  60. CreateObject(2566, -1141.98, -2855.60, 270.06, 0.00, 0.00, 20.14);
  61. CreateObject(2762, -1134.76, -2855.95, 269.92, 0.00, 0.00, 110.32);
  62. CreateObject(1704, -1135.72, -2861.89, 269.57, 0.00, 0.00, 200.08);
  63. CreateObject(1708, -1139.69, -2863.49, 269.47, 0.00, 0.00, 197.16);
  64. return 1;
  65. }
  66.  
  67. public OnPlayerConnect(playerid)
  68. {
  69. LoadStats(playerid);
  70. if(fInfo[playerid][Pt] == 1)
  71. {
  72. CreateDynamicObject(fInfo[playerid][TABLEID], TX, TY, TZ, 0, 0, 0, fInfo[playerid][Tworld], fInfo[playerid][Tint], -1, 200.0);
  73. }
  74. if(fInfo[playerid][Pc] == 1)
  75. {
  76. CreateDynamicObject(fInfo[playerid][CHAIRID], CX, CY, CZ, 0, 0, 0, fInfo[playerid][Cworld], fInfo[playerid][Cint], -1, 200.0);
  77. }
  78. if(fInfo[playerid][Pb] == 1)
  79. {
  80. CreateDynamicObject(fInfo[playerid][BEDID], BX, BY, BZ, 0, 0, 0, fInfo[playerid][Bworld], fInfo[playerid][Bint], -1, 200.0);
  81. }
  82. return 1;
  83. }
  84.  
  85. public OnPlayerDisconnect(playerid, reason)
  86. {
  87. if (!dini_Exists(furn(playerid)))
  88. {
  89. dini_Create(furn(playerid));
  90. }
  91. SaveStats(playerid);
  92. return 1;
  93. }
  94.  
  95.  
  96. public OnFilterScriptExit()
  97. {
  98. return 1;
  99. }
  100.  
  101. COMMAND:fshop(playerid, params[]) // or CMD:mycommand(playerid, params[])
  102. {
  103. SetPlayerPos(playerid, -1146.44, -2858.14, 269.62);
  104. return 1;
  105. }
  106. //buys
  107. COMMAND:buychair(playerid, params[]) // or CMD:mycommand(playerid, params[])
  108. {
  109. IsPlayerInRangeOfPoint(playerid, 1.0, -1136.4224,-2861.4194,270.5641);
  110. if(fInfo[playerid][HASCHAIR] == 0)
  111. {
  112. fInfo[playerid][HASCHAIR] = 1;
  113. fInfo[playerid][CHAIRID] = 1704;
  114. GivePlayerMoney(playerid, -270);
  115. SendClientMessage(playerid, 0xFFFFFF,"You have bought a leather chair for £270.");
  116. SendClientMessage(playerid, 0xFFFFFF,"In this verison of the filterscript you can only have 1 chair");
  117. SendClientMessage(playerid, 0xFFFFFF,"go to an area you want your chair to be and type /placechair");
  118. }
  119. IsPlayerInRangeOfPoint(playerid, 1.0, -1140.2141,-2862.9775,270.5641);
  120. if(fInfo[playerid][HASCHAIR] == 0)
  121. {
  122. fInfo[playerid][HASCHAIR] = 1;
  123. fInfo[playerid][CHAIRID] = 1708;
  124. GivePlayerMoney(playerid, -150);
  125. SendClientMessage(playerid, 0xFFFFFF,"You have bought a chair for £150.");
  126. SendClientMessage(playerid, 0xFFFFFF,"In this verison of the filterscript you can only have 1 chair");
  127. SendClientMessage(playerid, 0xFFFFFF,"go to an area you want your chair to be and type /placechair");
  128. }
  129. return 1;
  130. }
  131.  
  132. COMMAND:buybed(playerid, params[]) // or CMD:mycommand(playerid, params[])
  133. {
  134. IsPlayerInRangeOfPoint(playerid, 1.0, -1146.0715,-2857.3557,270.5641);
  135. if(fInfo[playerid][HASBED] == 0)
  136. {
  137. fInfo[playerid][HASBED] = 1;
  138. fInfo[playerid][BEDID] = 1802;
  139. GivePlayerMoney(playerid, -500);
  140. SendClientMessage(playerid, 0xFFFFFF,"You have bought a kingsize bed for £500.");
  141. SendClientMessage(playerid, 0xFFFFFF,"In this verison of the filterscript you can only have 1 bed");
  142. SendClientMessage(playerid, 0xFFFFFF,"go to an area you want your chair to be and type /placebed");
  143. }
  144. IsPlayerInRangeOfPoint(playerid, 1.0, -1140.2225,-2855.2290,270.5641);
  145. if(fInfo[playerid][HASBED] == 0)
  146. {
  147. fInfo[playerid][HASBED] = 1;
  148. fInfo[playerid][BEDID] = 2566;
  149. GivePlayerMoney(playerid, -1230);
  150. SendClientMessage(playerid, 0xFFFFFF,"You have bought the bed with bed side cabinets for £1230.");
  151. SendClientMessage(playerid, 0xFFFFFF,"In this verison of the filterscript you can only have 1 bed");
  152. SendClientMessage(playerid, 0xFFFFFF,"go to an area you want your bed to be and type /placebed");
  153. }
  154. else {
  155. SendClientMessage(playerid, 0xFFFFFF,"you all ready own a bed or you are not in a furniture shop.");
  156. }
  157. return 1;
  158. }
  159.  
  160. COMMAND:buytable(playerid, params[]) // or CMD:mycommand(playerid, params[])
  161. {
  162. IsPlayerInRangeOfPoint(playerid, 1.0, -1135.6499,-2856.1558,270.5641);
  163. if(fInfo[playerid][HASTABLE] == 0 && fInfo[playerid][Pt] == 0)
  164. {
  165. fInfo[playerid][HASTABLE] = 1;
  166. fInfo[playerid][TABLEID] = 2762;
  167. GivePlayerMoney(playerid, -50);
  168. SendClientMessage(playerid, 0xFFFFFF,"You have bought a wooden coffe table for £50.");
  169. SendClientMessage(playerid, 0xFFFFFF,"In this verison of the filterscript you can only have 1 table");
  170. SendClientMessage(playerid, 0xFFFFFF,"go to an area you want your table to be and type /placetable");
  171. }
  172. else {
  173. SendClientMessage(playerid, 0xFFFFFF,"you all ready own a table or you are not in a furniture shop.");
  174. }
  175. return 1;
  176. }
  177. //placing
  178. COMMAND:placechair(playerid, params[]) // or CMD:mycommand(playerid, params[])
  179. {
  180. if(fInfo[playerid][HASCHAIR] == 1 && fInfo[playerid][Pc] == 0)
  181. {
  182. new Float:x;
  183. new Float:y;
  184. new Float:z;
  185.  
  186.  
  187. GetPlayerPos(playerid,x,y,z);
  188. CX = x;
  189. CY = y;
  190. CZ = z - 0.8;
  191. fInfo[playerid][Cint] = GetPlayerInterior(playerid);
  192. fInfo[playerid][Cworld] = GetPlayerVirtualWorld(playerid);
  193. fInfo[playerid][Pc] = 1;
  194.  
  195. CreateDynamicObject(fInfo[playerid][CHAIRID], CX, CY, CZ, 0, 0, 0, fInfo[playerid][Cworld], fInfo[playerid][Cint], -1, 200.0);
  196. }
  197. else {
  198. SendClientMessage(playerid, 0xFFFFFF,"you don't have a chair please buy one from the furniture shop.");
  199. SendClientMessage(playerid, 0xFFFFFF,"Or you have allready planted it.");
  200. }
  201. return 1;
  202. }
  203.  
  204. COMMAND:placetable(playerid, params[]) // or CMD:mycommand(playerid, params[])
  205. {
  206. if(fInfo[playerid][HASTABLE] == 1 && fInfo[playerid][Pt] == 0)
  207. {
  208. new Float:x;
  209. new Float:y;
  210. new Float:z;
  211.  
  212.  
  213. GetPlayerPos(playerid,x,y,z);
  214. TX = x;
  215. TY = y;
  216. TZ = z - 0.8;
  217. fInfo[playerid][Tint] = GetPlayerInterior(playerid);
  218. fInfo[playerid][Tworld] = GetPlayerVirtualWorld(playerid);
  219. fInfo[playerid][Pt] = 1;
  220.  
  221. CreateDynamicObject(fInfo[playerid][TABLEID], TX, TY, TZ, 0, 0, 0, fInfo[playerid][Tworld], fInfo[playerid][Tint], -1, 200.0);
  222. }
  223. else {
  224. SendClientMessage(playerid, 0xFFFFFF,"you don't have a table please buy one from the furniture shop.");
  225. SendClientMessage(playerid, 0xFFFFFF,"Or you have allready placed it.");
  226. }
  227. return 1;
  228. }
  229.  
  230. COMMAND:placebed(playerid, params[]) // or CMD:mycommand(playerid, params[])
  231. {
  232. if(fInfo[playerid][HASBED] == 1 && fInfo[playerid][Pb] == 0)
  233. {
  234. new Float:x;
  235. new Float:y;
  236. new Float:z;
  237.  
  238.  
  239. GetPlayerPos(playerid,x,y,z);
  240. BX = x;
  241. BY = y;
  242. BZ = z - 0.8;
  243. fInfo[playerid][Bint] = GetPlayerInterior(playerid);
  244. fInfo[playerid][Bworld] = GetPlayerVirtualWorld(playerid);
  245. fInfo[playerid][Pb] = 1;
  246.  
  247. CreateDynamicObject(fInfo[playerid][BEDID], BX, BY, BZ, 0, 0, 0, fInfo[playerid][Bworld], fInfo[playerid][Bint], -1, 200.0);
  248. }
  249. else {
  250. SendClientMessage(playerid, 0xFFFFFF,"you don't have a bed please buy one from the furniture shop.");
  251. SendClientMessage(playerid, 0xFFFFFF,"Or you have allready placed it.");
  252. }
  253. return 1;
  254. }
  255.  
  256. Player(playerid)
  257. {
  258. new player[MAX_PLAYER_NAME];
  259. GetPlayerName(playerid, player, sizeof(player));
  260. return player;
  261. }
  262.  
  263. furn(playerid)
  264. {
  265. new a[256]; format(a, sizeof(a), "%s.ini",udb_encode(Player(playerid)));
  266. return a;
  267. }
  268.  
  269. SaveStats(playerid)
  270. {
  271. dini_IntSet(furn(playerid), "CX", floatround(CX));
  272. dini_IntSet(furn(playerid), "CY", floatround(CY));
  273. dini_IntSet(furn(playerid), "CZ", floatround(CZ));
  274. dini_IntSet(furn(playerid), "TX", floatround(TX));
  275. dini_IntSet(furn(playerid), "TY", floatround(TY));
  276. dini_IntSet(furn(playerid), "TZ", floatround(TZ));
  277. dini_IntSet(furn(playerid), "BX", floatround(BX));
  278. dini_IntSet(furn(playerid), "BY", floatround(BY));
  279. dini_IntSet(furn(playerid), "BZ", floatround(BZ));
  280. dini_IntSet(furn(playerid), "HASCHAIR", (fInfo[playerid][HASCHAIR]));
  281. dini_IntSet(furn(playerid), "HASTABLE", (fInfo[playerid][HASTABLE]));
  282. dini_IntSet(furn(playerid), "HASBED", (fInfo[playerid][HASBED]));
  283. dini_IntSet(furn(playerid), "Cworld", (fInfo[playerid][Cworld]));
  284. dini_IntSet(furn(playerid), "Cint", (fInfo[playerid][Cint]));
  285. dini_IntSet(furn(playerid), "Tworld", (fInfo[playerid][Tworld]));
  286. dini_IntSet(furn(playerid), "Tint", (fInfo[playerid][Tint]));
  287. dini_IntSet(furn(playerid), "Bworld", (fInfo[playerid][Bworld]));
  288. dini_IntSet(furn(playerid), "Bint", (fInfo[playerid][Bint]));
  289. dini_IntSet(furn(playerid), "HasPlacedChair", (fInfo[playerid][Pc]));
  290. dini_IntSet(furn(playerid), "HasPlacedTable", (fInfo[playerid][Pt]));
  291. dini_IntSet(furn(playerid), "HasPlacedBed", (fInfo[playerid][Pb]));
  292. dini_IntSet(furn(playerid), "CHAIRID", (fInfo[playerid][CHAIRID]));
  293. dini_IntSet(furn(playerid), "TABLEID", (fInfo[playerid][TABLEID]));
  294. dini_IntSet(furn(playerid), "BEDID", (fInfo[playerid][BEDID]));
  295. }
  296.  
  297. LoadStats(playerid)
  298. {
  299. CX = dini_Int(furn(playerid), "CX");
  300. CY = dini_Int(furn(playerid), "CY");
  301. CZ = dini_Int(furn(playerid), "CZ");
  302. TX = dini_Int(furn(playerid), "TX");
  303. TY = dini_Int(furn(playerid), "TY");
  304. TZ = dini_Int(furn(playerid), "TZ");
  305. BX = dini_Int(furn(playerid), "BX");
  306. BY = dini_Int(furn(playerid), "BY");
  307. BZ = dini_Int(furn(playerid), "BZ");
  308. fInfo[playerid][HASCHAIR] = dini_Int(furn(playerid), "HASCHAIR");
  309. fInfo[playerid][HASTABLE] = dini_Int(furn(playerid), "HASTABLE");
  310. fInfo[playerid][HASBED] = dini_Int(furn(playerid), "HASBED");
  311. fInfo[playerid][Cworld] = dini_Int(furn(playerid), "Cworld");
  312. fInfo[playerid][Cint] = dini_Int(furn(playerid), "Cint");
  313. fInfo[playerid][Tworld] = dini_Int(furn(playerid), "Tworld");
  314. fInfo[playerid][Tint] = dini_Int(furn(playerid), "Tint");
  315. fInfo[playerid][Bworld] = dini_Int(furn(playerid), "Bworld");
  316. fInfo[playerid][Bint] = dini_Int(furn(playerid), "Bint");
  317. fInfo[playerid][Pc] = dini_Int(furn(playerid), "HasPlacedChair");
  318. fInfo[playerid][Pt] = dini_Int(furn(playerid), "HasPlacedTable");
  319. fInfo[playerid][Pb] = dini_Int(furn(playerid), "HasPlacedBed");
  320. fInfo[playerid][CHAIRID] = dini_Int(furn(playerid), "CHAIRID");
  321. fInfo[playerid][TABLEID] = dini_Int(furn(playerid), "TABLEID");
  322. fInfo[playerid][BEDID] = dini_Int(furn(playerid), "BEDID");
  323. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement