Guest User

Simple Billboard system v0.1

a guest
Jun 18th, 2012
1,913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.57 KB | None | 0 0
  1. // Simple Billboards system v0.1//
  2. //////*Author: christiand*//////
  3. //Please don't remove credits//
  4.  
  5. #define FILTERSCRIPT
  6.  
  7. #include <a_samp>
  8. #include <zcmd>
  9. #include <dini>
  10. #include <dudb>
  11.  
  12.  
  13.  
  14. #pragma tabsize 0
  15.  
  16. #define COLOR_WHITE 0xFFFFFFFF
  17. #define COLOR_RED 0xFF0000C8
  18.  
  19.  
  20. forward pay(playerid);
  21. forward nopay(playerid);
  22. forward requestdestroy(playerid);
  23.  
  24. new Float:X;
  25. new Float:Y;
  26. new Float:Z;
  27.  
  28. // CORDS FOR RENTED BILLBOARD -- YOU CAN OWN A BILLBOARD AND RENTED ONE AT SAME TIME //
  29. new Float:RX;
  30. new Float:RY;
  31. new Float:RZ;
  32.  
  33. new nopayt;
  34.  
  35. enum pBB
  36. {
  37. hasrent,
  38. hasbuy,
  39. label,
  40. paid,
  41. rentedlabel
  42. };
  43.  
  44. new pickup1;
  45. new pickup4;
  46.  
  47. new stringtext[256];
  48.  
  49. new playervariables[MAX_PLAYERS][pBB];
  50.  
  51.  
  52. #if defined FILTERSCRIPT
  53.  
  54. public OnFilterScriptInit()
  55. {
  56. print("\n-------------*********----------------");
  57. print("Simple Billboard System [fs] by christiand");
  58. print("----------------Loaded----------------\n");
  59.  
  60.  
  61.  
  62.  
  63.  
  64. pickup1 = CreatePickup(1277,1,756.1639,-949.1958,55.1867,-1);
  65. pickup4 = CreatePickup(1277,1,873.1735,-1026.0630,29.5987,-1);
  66. CreatePickup(1277,1,853.9379,-991.9512,33.1571,-1);
  67. CreatePickup(1277,1,883.9384,-974.5226,36.3131,-1);
  68.  
  69. Create3DTextLabel("Billboard Info", 0xFFFF00FF,756.1639,-949.1958,55.1867, 20,0,1);
  70. Create3DTextLabel("Billboard Info", 0xFFFF00FF,873.1735,-1026.0630,29.5987, 20,0,1);
  71. Create3DTextLabel("Billboard Info", 0xFFFF00FF,853.9379,-991.9512,33.1571, 20,0,1);
  72. Create3DTextLabel("Billboard Info", 0xFFFF00FF,883.9384,-974.5226,36.3131, 20,0,1);
  73. return 1;
  74. }
  75.  
  76. public OnFilterScriptExit()
  77. {
  78. print("\n-------------*********----------------");
  79. print("Simple Billboard System [fs] by christiand");
  80. print("----------------UnLoaded----------------\n");
  81.  
  82. return 1;
  83. }
  84.  
  85. #endif
  86.  
  87. public pay(playerid)
  88. {
  89. playervariables[playerid][paid] = 0;
  90. SendClientMessage(playerid, COLOR_RED, "You must pay your liability to Billboards company");
  91.  
  92. return 1;
  93. }
  94.  
  95. public requestdestroy(playerid)
  96. {
  97. SendClientMessage(playerid, COLOR_RED, "Your billboard was deleted. TAX for this service : 5$.");
  98. GivePlayerMoney(playerid, -5);
  99. Delete3DTextLabel(playervariables[playerid][rentedlabel]);
  100. playervariables[playerid][hasrent] = 0;
  101.  
  102. return 1;
  103. }
  104.  
  105. public nopay(playerid)
  106. {
  107.  
  108. playervariables[playerid][hasrent] = 0;
  109. Delete3DTextLabel(playervariables[playerid][label]);
  110. SendClientMessage(playerid, COLOR_RED, "WARNING: Your billboard was deleted , next time pay your liability.");
  111.  
  112. return 1;
  113. }
  114.  
  115. SaveStats(playerid)
  116. {
  117. dini_IntSet(billboard(playerid), "X", floatround(X));
  118. dini_IntSet(billboard(playerid), "Y", floatround(Y));
  119. dini_IntSet(billboard(playerid), "Z", floatround(Z));
  120. dini_IntSet(billboard(playerid), "RX", floatround(RX));
  121. dini_IntSet(billboard(playerid), "RY", floatround(RY));
  122. dini_IntSet(billboard(playerid), "RZ", floatround(RZ));
  123. dini_IntSet(billboard(playerid), "hasrent", (playervariables[playerid][hasrent]));
  124. dini_IntSet(billboard(playerid), "hasbuy", (playervariables[playerid][hasbuy]));
  125. dini_IntSet(billboard(playerid), "label", (playervariables[playerid][label]));
  126. dini_IntSet(billboard(playerid), "rentedlabel", (playervariables[playerid][rentedlabel]));
  127. dini_IntSet(billboard(playerid), "paid", (playervariables[playerid][paid]));
  128. dini_Set(billboard(playerid),"text",stringtext);
  129.  
  130. }
  131.  
  132. LoadStats(playerid)
  133. {
  134. X = dini_Int(billboard(playerid), "X");
  135. Y = dini_Int(billboard(playerid), "Y");
  136. Z = dini_Int(billboard(playerid), "Z");
  137. RX = dini_Int(billboard(playerid), "RX");
  138. RY = dini_Int(billboard(playerid), "RY");
  139. RZ = dini_Int(billboard(playerid), "RZ");
  140. playervariables[playerid][hasrent] = dini_Int(billboard(playerid), "hasrent");
  141. playervariables[playerid][hasbuy] = dini_Int(billboard(playerid), "hasbuy");
  142. playervariables[playerid][label] = dini_Int(billboard(playerid), "label");
  143. playervariables[playerid][rentedlabel] = dini_Int(billboard(playerid), "rentedlabel");
  144. playervariables[playerid][paid] = dini_Int(billboard(playerid), "paid");
  145. stringtext = dini_Get( billboard(playerid),"text" );
  146. }
  147.  
  148. stock Player(playerid)
  149. {
  150. new pname[MAX_PLAYER_NAME];
  151. GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  152.  
  153. return pname;
  154. }
  155.  
  156.  
  157. stock billboard(playerid)
  158. {
  159. new x[256];
  160. format(x, sizeof(x), "Billboards/%s.ini",udb_encode(Player(playerid)));
  161.  
  162. return x;
  163. }
  164.  
  165. public OnPlayerConnect(playerid)
  166. {
  167. LoadStats(playerid);
  168.  
  169.  
  170.  
  171.  
  172. if(playervariables[playerid][hasbuy] == 1)
  173. {
  174. Create3DTextLabel( stringtext, 0xFFFFFFFF, X, Y, Z, 60.00, 0, 0);
  175. }
  176. if(playervariables[playerid][hasrent] == 1)
  177. {
  178. Create3DTextLabel( stringtext, 0xFFFFFFFF, RX, RY, RZ, 60.00, 0, 0);
  179. }
  180.  
  181.  
  182. playervariables[playerid][paid] = 1;
  183.  
  184.  
  185. return 1;
  186. }
  187.  
  188. public OnPlayerDisconnect(playerid, reason)
  189. {
  190. if (!dini_Exists(billboard(playerid)))
  191. {
  192. dini_Create(billboard(playerid));
  193. }
  194.  
  195. SaveStats(playerid);
  196.  
  197. return 1;
  198. }
  199.  
  200.  
  201. public OnPlayerPickUpPickup(playerid, pickupid)
  202. {
  203. if(pickupid == pickup1)
  204. SetPlayerPos(playerid, 762.7893,-956.7414,58.2656);
  205.  
  206.  
  207.  
  208. if(pickupid == pickup4)
  209. SetPlayerPos(playerid, 871.9459,-1023.2238,47.9922);
  210.  
  211.  
  212.  
  213. return 1;
  214. }
  215.  
  216.  
  217. public OnPlayerUpdate(playerid)
  218. {
  219. if( playervariables[playerid][hasrent] == 1)
  220. {
  221. if( playervariables[playerid][paid] == 0 )
  222. {
  223. nopayt = SetTimer("nopay", 240000 ,0);
  224.  
  225. }
  226. }
  227.  
  228. return 1;
  229. }
  230.  
  231.  
  232. CMD:buybb(playerid, params[])
  233. {
  234. if( playervariables[playerid][hasbuy] == 0 )
  235. {
  236. if( IsPlayerInRangeOfPoint(playerid, 30.0, 871.9459,-1023.2238,47.9922) || IsPlayerInRangeOfPoint(playerid, 30.0, 762.7893,-956.7414,58.2656) )
  237. {
  238.  
  239. if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "Syntax: /buybb [text]");
  240.  
  241. GetPlayerPos(playerid, X, Y, Z);
  242. format(stringtext, sizeof(stringtext), "[ %s ]", params);
  243.  
  244. playervariables[playerid][label] = Create3DTextLabel(stringtext, 0xFFFFFFFF, X, Y, Z, 60.00, 0, 0);
  245.  
  246. GivePlayerMoney(playerid, -1000);
  247. SendClientMessage(playerid, COLOR_WHITE, "You bought succesfully billboard for $1000.");
  248. playervariables[playerid][hasbuy] = 1;
  249.  
  250. PlayerPlaySound(playerid, 1149, X, Y, Z);
  251.  
  252. }
  253. else
  254. {
  255.  
  256. SendClientMessage(playerid, COLOR_WHITE, "You are not at a place where you can buy billboard.");
  257.  
  258. }
  259. }
  260. else
  261. {
  262. SendClientMessage(playerid, COLOR_WHITE, "You already own a billboard.");
  263. }
  264.  
  265.  
  266. return 1;
  267. }
  268.  
  269. CMD:editbb(playerid, params[])
  270. {
  271.  
  272. if( IsPlayerInRangeOfPoint(playerid, 30.0, X, Y, Z) || IsPlayerInRangeOfPoint(playerid, 30.0, RX, RY, RZ) )
  273. {
  274.  
  275. if( playervariables[playerid][hasbuy] == 1 || playervariables[playerid][hasrent] == 1 )
  276. {
  277.  
  278. if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "Syntax: /editbb [text]");
  279.  
  280. format(stringtext, sizeof(stringtext), "[ %s ]", params);
  281.  
  282. Update3DTextLabelText(playervariables[playerid][label], COLOR_WHITE, stringtext);
  283.  
  284. SendClientMessage(playerid, COLOR_WHITE, "You edited your billboard , additional TAX : 3$");
  285. GivePlayerMoney(playerid, -3);
  286.  
  287. }
  288. else
  289. {
  290.  
  291. SendClientMessage(playerid, COLOR_WHITE, "You don't own or have rented a billboard.");
  292.  
  293. }
  294. }
  295. else
  296. {
  297.  
  298. SendClientMessage(playerid, COLOR_WHITE, "You are not near your billboard place.");
  299.  
  300. }
  301.  
  302. return 1;
  303. }
  304.  
  305.  
  306.  
  307. CMD:destroybb(playerid, params[])
  308. {
  309. if( IsPlayerInRangeOfPoint(playerid, 30.0, X, Y, Z) )
  310. {
  311.  
  312. if( playervariables[playerid][hasbuy] == 1 )
  313. {
  314.  
  315. Delete3DTextLabel(playervariables[playerid][label]);
  316. SendClientMessage(playerid, COLOR_WHITE, "You deleted your billboard.");
  317. playervariables[playerid][hasbuy] = 0;
  318.  
  319. }
  320. else
  321. {
  322.  
  323. SendClientMessage(playerid, COLOR_WHITE, "You don't own a billboard");
  324.  
  325. }
  326. }
  327. else
  328. {
  329.  
  330. SendClientMessage(playerid, COLOR_WHITE, "You are not near your billboard place.");
  331.  
  332. }
  333.  
  334. return 1;
  335. }
  336.  
  337. CMD:rentbb(playerid, params[])
  338. {
  339.  
  340. if( playervariables[playerid][hasrent] == 0 )
  341. {
  342. if( IsPlayerInRangeOfPoint(playerid, 30.0, 871.9459,-1023.2238,47.9922) || IsPlayerInRangeOfPoint(playerid, 30.0, 762.7893,-956.7414,58.2656) )
  343. {
  344.  
  345. if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "Syntax: /rentbb [text]");
  346.  
  347. GetPlayerPos(playerid, RX, RY, RZ);
  348.  
  349.  
  350. format(stringtext, sizeof(stringtext), "[ %s ]", params);
  351.  
  352.  
  353. playervariables[playerid][rentedlabel] = Create3DTextLabel(stringtext, 0xFFFFFFFF, RX, RY, RZ, 60.00, 0, 0);
  354.  
  355. GivePlayerMoney(playerid, -2);
  356. SendClientMessage(playerid, COLOR_WHITE, "You have rented a billboard for 2 $ / hour.");
  357. SendClientMessage(playerid, COLOR_RED, "HINT: You need to pay rent at time or billboard will get deleted.");
  358. playervariables[playerid][hasrent] = 1;
  359. playervariables[playerid][paid] = 1;
  360.  
  361. PlayerPlaySound(playerid, 1149, RX, RY, RZ);
  362.  
  363. SetTimer("pay", 3600000, 1);
  364.  
  365.  
  366. }
  367. else
  368. {
  369.  
  370. SendClientMessage(playerid, COLOR_WHITE, "You are not at a place where you can rent billboard.");
  371.  
  372. }
  373. }
  374. else
  375. {
  376. SendClientMessage(playerid, COLOR_WHITE, "You already rented a billboard.");
  377. }
  378.  
  379.  
  380.  
  381. return 1;
  382. }
  383.  
  384. CMD:payrentbb(playerid, params[])
  385. {
  386. if( playervariables[playerid][paid] == 0 )
  387. {
  388.  
  389. GivePlayerMoney(playerid, -2);
  390. SendClientMessage(playerid , COLOR_WHITE, "You paid 2$ for rented billboard");
  391. playervariables[playerid][paid] = 1;
  392. KillTimer(nopayt);
  393.  
  394. }
  395. else
  396. {
  397.  
  398. SendClientMessage(playerid, COLOR_WHITE, "You already paid");
  399.  
  400. }
  401.  
  402. return 1;
  403. }
  404.  
  405. CMD:requestdestroybb(playerid, params[])
  406. {
  407. if( playervariables[playerid][hasrent] == 1 )
  408. {
  409.  
  410. SetTimer("requestdestroy", 120000, 0);
  411. SendClientMessage(playerid, COLOR_WHITE, "You must wait 2 minutes , be patient please");
  412.  
  413. }
  414. else
  415. {
  416.  
  417. SendClientMessage(playerid, COLOR_WHITE, "You don't have an rented billboard");
  418. }
  419.  
  420. return 1;
  421. }
  422.  
  423. CMD:mybbstat(playerid, params[])
  424. {
  425. SendClientMessage(playerid, COLOR_RED, "________MY BILLBOARD STATUS________");
  426.  
  427. if( playervariables[playerid][hasrent] == 1 )
  428. {
  429. SendClientMessage(playerid, COLOR_WHITE, "Rented Billboard: YES");
  430. }
  431. else
  432. {
  433. SendClientMessage(playerid, COLOR_WHITE, "Rented Billboard: NO");
  434. }
  435.  
  436. if( playervariables[playerid][hasbuy] == 1 )
  437. {
  438. SendClientMessage(playerid, COLOR_WHITE, "Bought Billboard: YES");
  439. }
  440. else
  441. {
  442. SendClientMessage(playerid, COLOR_WHITE, "Bought Billboard: NO");
  443. }
  444.  
  445. if( playervariables[playerid][hasrent] == 1)
  446. {
  447. if( playervariables[playerid][paid] == 1 )
  448. {
  449. SendClientMessage(playerid, COLOR_WHITE, "Rent Paid?: YES");
  450. }
  451. else
  452. {
  453. SendClientMessage(playerid, COLOR_WHITE, "Rent Paid?: NO ! Pay ASAP !");
  454. SendClientMessage(playerid, COLOR_RED, "______________________________");
  455. }
  456. }
  457. else
  458. {
  459. SendClientMessage(playerid, COLOR_WHITE, "Rent Paid?: You don't have a rented billboard!");
  460. }
  461.  
  462.  
  463. return 1;
  464. }
  465.  
  466. CMD:bbhelp(playerid, params[])
  467. {
  468. SendClientMessage(playerid, COLOR_RED, "________BILLBOARD COMMANDS_______");
  469. SendClientMessage(playerid, COLOR_WHITE, "/buybb /rentbb /editbb /destroybb");
  470. SendClientMessage(playerid, COLOR_WHITE, "/payrentbb /requestdestroybb /mybbstats");
  471. SendClientMessage(playerid, COLOR_WHITE, "Thanks for using my Filescript!");
  472. SendClientMessage(playerid, COLOR_RED, "______________________________");
  473.  
  474. return 1;
  475. }
Advertisement
Add Comment
Please, Sign In to add comment