Guest User

Untitled

a guest
Jan 26th, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.53 KB | None | 0 0
  1. -------------------------------------
  2. -- HOUSE SYSTEM CREATED BY NONEATME --
  3. -- -- - DO NOT REMOVE CREDITS - -- ---
  4. --YOU ARE NOT ALLOWED TO COMPILE THIS-
  5. --------------------------------------
  6.  
  7. -- EVENTS --
  8.  
  9. addEvent("onClientHouseSystemGUIStart", true)
  10. addEvent("onClientHouseSystemMenueOpen", true)
  11. addEvent("onClientHouseSystemMenueUpdate", true)
  12. addEvent("onClientHouseSystemColshapeAdd", true)
  13. addEvent("onClientHouseSystemInfoMenueOpen", true)
  14.  
  15. -- SOME SETTINGS --
  16.  
  17. local gMe = getLocalPlayer()
  18.  
  19. local houseInteriors = { -- I don't really use tables
  20. [1] = "223.0538482666, 1287.3552246094, 1082.140625, 1, Shitty house 1",
  21. [2] = "2233.6594238281, -1114.9837646484, 1050.8828125, 5, Hotel room 1",
  22. [3] = "2365.22265625, -1135.5612792969, 1050.8825683594, 8, Modern house 1",
  23. [4] = "2282.9401855469, -1140.1246337891, 1050.8984375, 11, Hotel room 2",
  24. [5] = "2196.7075195313, -1204.3569335938, 1049.0234375, 6, Modern house 2",
  25. [6] = "2270.0834960938, -1210.4854736328, 1047.5625, 10, Modern house 3",
  26. [7] = "2308.755859375, -1212.5498046875, 1049.0234375, 6, Shitty house 2",
  27. [8] = "2217.7729492188, -1076.2110595703, 1050.484375, 1, Hotel room 3",
  28. [9] = "2237.5009765625, -1080.9367675781, 1049.0234375, 2, Good house 1",
  29. [10] = "2317.7609863281, -1026.4268798828, 1050.2177734375, 9, Good Stair house 1",
  30. [11] = "261.05038452148, 1284.7646484375, 1080.2578125, 4, Goood house 2",
  31. [12] = "140.18000793457, 1366.7183837891, 1083.859375, 5, Modern house 4(Rich)",
  32. [13] = "83.037002563477, 1322.6156005859, 1083.8662109375, 9, Good Stair house 2",
  33. [14] = "-283.92623901367, 1471.0096435547, 1084.375, 15, Good Stair house 3",
  34. [15] = "-261.03778076172, 1456.6539306641, 1084.3671875, 4, Good Stair house 4",
  35. [16] = "-42.609268188477, 1405.8033447266, 1084.4296875, 8, Shitty house 3",
  36. [17] = "-68.839866638184, 1351.4775390625, 1080.2109375, 6, Shitty house 4",
  37. [18] = "2333.068359375, -1077.0648193359, 1049.0234375, 6, Shitty house 5",
  38. [19] = "1261.1168212891, -785.38037109375, 1091.90625, 5, Mad Doggs Mansion",
  39. [20] = "2215.1145019531, -1150.4993896484, 1025.796875, 15, Jefferson Motel",
  40. [21] = "2352.4575195313, -1180.9454345703, 1027.9765625, 5, Burning desire house(Buggy)",
  41. [22] = "421.94845581055, 2536.5021972656, 10, 10, Abandoned Tower",
  42. [23] = "2495.9753417969, -1692.4174804688, 1014.7421875, 3, Johnson house",
  43. [24] = "-2158.7209472656, 642.83074951172, 1052.375, 1, Bet Interior",
  44. [25] = "1701.1682128906, -1667.759765625, 20.21875, 18, Atrium lobby",
  45. [26] = "2324.499, -1147.071, 1050.71, 12, Modern House 5(Rich)",
  46. [27] = "244.411987,305.032989,999.148437, 1, 1 Room house",
  47. [28] = "271.884979,306.631988,999.148437, 2, 1 Room house",
  48. [29] = "302.180999,300.722991,999.148437, 4, 1 Room house",
  49. }
  50.  
  51. local Guivar = 0 -- createhouse Menue
  52. local Guivar2 = 0 -- MENUE
  53. local Guivar3 = 0
  54.  
  55. local Fenster = {}
  56. local Knopf = {}
  57. local Label = {}
  58. local Edit = {}
  59. local Grid = {}
  60. local Bild = {}
  61.  
  62. local Fenster2 = {}
  63. local Knopf2 = {}
  64. local Label2 = {}
  65. local Edit2 = {}
  66. local Radio2 = {}
  67. local Checkbox2 = {}
  68. local Grid2 = {}
  69.  
  70. local Fenster3 = {}
  71. local Knopf3 = {}
  72. local Label3 = {}
  73. --------------------
  74. -- EVENT HANDLERS --
  75. --------------------
  76.  
  77.  
  78.  
  79. -- MENUE UPDATE --
  80.  
  81. addEventHandler("onClientHouseSystemMenueUpdate", getRootElement(), function(string, value, int)
  82. if(Guivar2 == 0) then return end
  83. if(string == "LOCKED") then
  84. if(value == 0) then
  85. guiSetText(Knopf2[6], "Lock house")
  86. else
  87. guiSetText(Knopf2[6], "Unlock house")
  88. end
  89. elseif(string == "MONEY") then
  90. guiSetText(Label2[3], "Current Money:\n"..value.."$")
  91. elseif(string == "WEAPON") then
  92. if(value == 1) then
  93. if(type(int) == "string") then
  94. guiSetText(Label2[6], "Slot 1: "..getWeaponNameFromID(gettok(int, 1, ",")).."\nAmmo: "..gettok(int, 2, ","))
  95. else
  96. guiSetText(Label2[6], "Slot 1: -\nAmmo: -")
  97. end
  98. elseif(value == 2) then
  99. if(type(int) == "string") then
  100. guiSetText(Label2[7], "Slot 2: "..getWeaponNameFromID(gettok(int, 1, ",")).."\nAmmo: "..gettok(int, 2, ","))
  101. else
  102. guiSetText(Label2[7], "Slot 2: -\nAmmo: -")
  103. end
  104. elseif(value == 3) then
  105. if(type(int) == "string") then
  106. guiSetText(Label2[9], "Slot 3: "..getWeaponNameFromID(gettok(int, 1, ",")).."\nAmmo: "..gettok(int, 2, ","))
  107. else
  108. guiSetText(Label2[9], "Slot 3: -\nAmmo: -")
  109. end
  110. end
  111. elseif(string == "RENTABLE") then
  112. if(value == true) then
  113. guiSetText(Knopf2[9], "Set unrentable")
  114. else
  115. guiSetText(Knopf2[9], "Set rentable")
  116. end
  117. elseif(string == "RENTALPRICE") then
  118. guiSetText(Label2[15], "Rentalprice: $"..value)
  119. elseif(string == "TENANDS") then
  120. guiGridListClear(Grid2[1])
  121. for index, player in pairs(value) do
  122. if(player ~= "no-one") then
  123. local row = guiGridListAddRow(Grid2[1])
  124. guiGridListSetItemText(Grid2[1], row, 1, player, false, false)
  125. end
  126. end
  127. end
  128. end)
  129.  
  130. -- INFO MENUE --
  131.  
  132.  
  133. addEventHandler("onClientHouseSystemInfoMenueOpen", gMe, function(owner, x, y, z, price, locked, rentable, rentalprice, id, doingrent, isrentedin, canadd)
  134. if(Guivar3 == 1) then
  135. destroyElement(Fenster3[1])
  136. showCursor(false)
  137. Guivar3 = 0
  138. return
  139. end
  140. Guivar3 = 1
  141. showCursor(true)
  142. guiSetInputMode("no_binds_when_editing")
  143.  
  144. -- Make the variables --
  145.  
  146. local lockedstate = "no"
  147. if(tonumber(locked) == 1) then lockedstate = "yes" end
  148. local rentstate = "no"
  149. if(tonumber(rentable) == 1) then rentstate = "yes" end
  150.  
  151. local X, Y, Width, Height = getMiddleGuiPosition(270,251)
  152. Fenster3[1] = guiCreateWindow(X, Y, Width, Height,"Houseinformation",false)
  153. Label3[1] = guiCreateLabel(12,43,253,15,"House ID: "..id,false,Fenster3[1])
  154. guiLabelSetHorizontalAlign(Label3[1],"center",false)
  155. guiSetFont(Label3[1],"default-bold-small")
  156. Label3[2] = guiCreateLabel(10,22,257,15,"House Informations:",false,Fenster3[1])
  157. guiLabelSetHorizontalAlign(Label3[2],"center",false)
  158. guiSetFont(Label3[2],"default-bold-small")
  159. Label3[3] = guiCreateLabel(10,25,259,15,"_______________________",false,Fenster3[1])
  160. guiLabelSetColor(Label3[3],0, 255, 0)
  161. guiLabelSetHorizontalAlign(Label3[3],"center",false)
  162. Label3[4] = guiCreateLabel(12,61,251,18,"Location: "..getZoneName(x, y, z, false),false,Fenster3[1])
  163. guiLabelSetHorizontalAlign(Label3[4],"center",false)
  164. guiSetFont(Label3[4],"default-bold-small")
  165. Label3[5] = guiCreateLabel(12,81,250,14,"Owner: "..owner,false,Fenster3[1])
  166. guiLabelSetHorizontalAlign(Label3[5],"center",false)
  167. guiSetFont(Label3[5],"default-bold-small")
  168. Label3[6] = guiCreateLabel(12,100,252,15,"Price: $"..price,false,Fenster3[1])
  169. guiLabelSetHorizontalAlign(Label3[6],"center",false)
  170. guiSetFont(Label3[6],"default-bold-small")
  171. Label3[7] = guiCreateLabel(12,118,250,14,"Rentable: "..rentstate,false,Fenster3[1])
  172. guiLabelSetHorizontalAlign(Label3[7],"center",false)
  173. guiSetFont(Label3[7],"default-bold-small")
  174. Label3[8] = guiCreateLabel(12,137,247,14,"Rentalprice: $"..rentalprice,false,Fenster3[1])
  175. guiLabelSetHorizontalAlign(Label3[8],"center",false)
  176. guiSetFont(Label3[8],"default-bold-small")
  177. Label3[9] = guiCreateLabel(12,155,247,12,"Locked: "..lockedstate,false,Fenster3[1])
  178. guiLabelSetHorizontalAlign(Label3[9],"center",false)
  179. guiSetFont(Label3[9],"default-bold-small")
  180. Knopf3[1] = guiCreateButton(9,175,124,32,"Buy house",false,Fenster3[1])
  181. Knopf3[2] = guiCreateButton(137,175,124,32,"Rent house",false,Fenster3[1])
  182. Knopf3[3] = guiCreateButton(9,210,124,32,"Close",false,Fenster3[1])
  183. Knopf3[4] = guiCreateButton(137,209,124,32,"Enter",false,Fenster3[1])
  184.  
  185. --------------
  186. -- SETTINGS --
  187. --------------
  188.  
  189. -- ENTER BUTTON --
  190. if(getPlayerName(gMe) ~= owner) then
  191. if(isrentedin == true) then
  192.  
  193. else
  194. if(tonumber(locked) == 1) then
  195. guiSetEnabled(Knopf3[4], false)
  196. end
  197. end
  198. end
  199.  
  200. -- RENT HOUSE BUTTON --
  201. if(getPlayerName(gMe) == owner) then
  202. guiSetEnabled(Knopf3[2], false)
  203. else
  204. if(doingrent == true) or(owner == "no-one") or (tonumber(rentable) == 0) or (canadd == false) then
  205. guiSetEnabled(Knopf3[2], false)
  206. end
  207. if(isrentedin == true) then
  208. guiSetEnabled(Knopf3[2], true)
  209. guiSetText(Knopf3[2], "Unrent house")
  210. end
  211. end
  212.  
  213. -- BUYHOUSE BUTTON --
  214. if(owner ~= "no-one") then
  215. guiSetEnabled(Knopf3[1], false)
  216. if(owner == getPlayerName(gMe)) then
  217. guiSetEnabled(Knopf3[1], true)
  218. guiSetText(Knopf3[1], "Sell house")
  219. end
  220. end
  221. -- EVENT HANDLERS --
  222.  
  223. -- RENT --
  224.  
  225. addEventHandler("onClientGUIClick", Knopf3[2], function()
  226. local text = guiGetText(Knopf3[2])
  227. Guivar3 = 0
  228. showCursor(false)
  229. destroyElement(Fenster3[1])
  230. if(text == "Rent house") then
  231. triggerServerEvent("onHouseSystemInfoRent", gMe, id, true)
  232. else
  233. triggerServerEvent("onHouseSystemInfoRent", gMe, id, false)
  234. end
  235. end, false)
  236.  
  237. -- BUY HOUSE --
  238. addEventHandler("onClientGUIClick", Knopf3[1], function()
  239. local text = guiGetText(Knopf3[1])
  240. Guivar3 = 0
  241. showCursor(false)
  242. destroyElement(Fenster3[1])
  243. if (text == "Buy house") then
  244. triggerServerEvent("onHouseSystemInfoBuy", gMe, id, true)
  245. else
  246. triggerServerEvent("onHouseSystemInfoBuy", gMe, id, false)
  247. end
  248. end, false)
  249.  
  250. -- ENTER --
  251. addEventHandler("onClientGUIClick", Knopf3[4], function()
  252. Guivar3 = 0
  253. showCursor(false)
  254. destroyElement(Fenster3[1])
  255. triggerServerEvent("onHouseSystemInfoEnter", gMe, id)
  256. end, false)
  257.  
  258. -- CANCEL --
  259. addEventHandler("onClientGUIClick", Knopf3[3], function()
  260. Guivar3 = 0
  261. showCursor(false)
  262. destroyElement(Fenster3[1])
  263. end, false)
  264. end)
  265.  
  266. -- OPEN MENUE --
  267.  
  268.  
  269. addEventHandler("onClientHouseSystemMenueOpen", gMe, function(owner, locked, money, weap1, weap2, weap3, id, rentable, rent, tenands)
  270. if(locked == nil) then
  271.  
  272. else
  273. if(Guivar2 == 1) then return end
  274. Guivar2 = 1
  275. guiSetInputMode("no_binds_when_editing")
  276. showCursor(true)
  277.  
  278. local X, Y, Width, Height = getMiddleGuiPosition(752,218)
  279. Fenster2[1] = guiCreateWindow(X, Y, Width, Height, "Housemenue",false)
  280. Label2[1] = guiCreateLabel(149,23,81,14,"Weapons",false,Fenster2[1])
  281. guiSetFont(Label2[1],"default-bold-small")
  282. Label2[2] = guiCreateLabel(144,24,92,14,"__________",false,Fenster2[1])
  283. guiLabelSetColor(Label2[2],0, 255, 0)
  284. Label2[3] = guiCreateLabel(17,40,106,32,"Current Money:\n0$",false,Fenster2[1])
  285. guiSetFont(Label2[3],"default-bold-small")
  286. Edit2[1] = guiCreateEdit(16,75,109,24,"",false,Fenster2[1])
  287. Knopf2[1] = guiCreateButton(16,105,110,29,"Deposit",false,Fenster2[1])
  288. Knopf2[2] = guiCreateButton(16,136,110,29,"Withdraw",false,Fenster2[1])
  289. Knopf2[3] = guiCreateButton(15,175,110,29,"Close",false,Fenster2[1])
  290. Label2[4] = guiCreateLabel(18,23,47,15,"Money",false,Fenster2[1])
  291. guiSetFont(Label2[4],"default-bold-small")
  292. Label2[5] = guiCreateLabel(13,24,92,14,"__________",false,Fenster2[1])
  293. guiLabelSetColor(Label2[5],0,255,0)
  294. Label2[6] = guiCreateLabel(142,50,139,33,"Slot 1: -\nAmmo: -",false,Fenster2[1])
  295. guiLabelSetVerticalAlign(Label2[6],"center")
  296. guiLabelSetHorizontalAlign(Label2[6],"center",false)
  297. guiSetFont(Label2[6],"default-bold-small")
  298. Label2[7] = guiCreateLabel(139,95,139,33,"Slot 2: -\nAmmo: -",false,Fenster2[1])
  299. guiLabelSetVerticalAlign(Label2[7],"center")
  300. guiLabelSetHorizontalAlign(Label2[7],"center",false)
  301. guiSetFont(Label2[7],"default-bold-small")
  302. Label2[8] = guiCreateLabel(141,76,139,15,"_________________________",false,Fenster2[1])
  303. guiLabelSetColor(Label2[8],0,255,0)
  304. guiSetFont(Label2[8],"default-bold-small")
  305. Label2[9] = guiCreateLabel(137,138,139,33,"Slot 3: -\nAmmo: -",false,Fenster2[1])
  306. guiLabelSetVerticalAlign(Label2[9],"center")
  307. guiLabelSetHorizontalAlign(Label2[9],"center",false)
  308. guiSetFont(Label2[9],"default-bold-small")
  309. Label2[10] = guiCreateLabel(138,121,139,15,"_________________________",false,Fenster2[1])
  310. guiLabelSetColor(Label2[10],0,255,0)
  311. guiSetFont(Label2[10],"default-bold-small")
  312. Label2[11] = guiCreateLabel(130,188,164,14,"_______________________________________________",false,Fenster2[1])
  313. guiLabelSetColor(Label2[11],0,255,0)
  314. guiSetFont(Label2[11],"default-bold-small")
  315. Radio2[1] = guiCreateRadioButton(303,27,108,21,"Weapon slot 1",false,Fenster2[1])
  316. guiSetFont(Radio2[1],"default-bold-small")
  317. Radio2[2] = guiCreateRadioButton(303,47,108,21,"Weapon slot 2",false,Fenster2[1])
  318. guiSetFont(Radio2[2],"default-bold-small")
  319. Radio2[3] = guiCreateRadioButton(303,67,108,21,"Weapon slot 3",false,Fenster2[1])
  320. guiRadioButtonSetSelected(Radio2[3],true)
  321. guiSetFont(Radio2[3],"default-bold-small")
  322. Knopf2[4] = guiCreateButton(301,104,107,30,"Deposit Weapon",false,Fenster2[1])
  323. Knopf2[5] = guiCreateButton(301,142,107,30,"Take Weapon",false,Fenster2[1])
  324. Knopf2[6] = guiCreateButton(301,175,107,29,"Lock house",false,Fenster2[1])
  325. Label2[12] = guiCreateLabel(412,22,10,189,"|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n",false,Fenster2[1])
  326. guiLabelSetColor(Label2[12],0, 255, 0)
  327. guiSetFont(Label2[12],"default-small")
  328. Label2[13] = guiCreateLabel(424,24,137,15,"Rent",false,Fenster2[1])
  329. guiSetFont(Label2[13],"default-bold-small")
  330. Label2[14] = guiCreateLabel(424,24,92,14,"__________",false,Fenster2[1])
  331. guiLabelSetColor(Label2[14],0,255,0)
  332. Label2[15] = guiCreateLabel(424,41,137,15,"Rentalprice: $0",false,Fenster2[1])
  333. guiSetFont(Label2[15],"default-bold-small")
  334. Edit2[2] = guiCreateEdit(441,58,75,24,"",false,Fenster2[1])
  335. Knopf2[7] = guiCreateButton(424,88,114,27,"Set rentalprice",false,Fenster2[1])
  336. Label2[16] = guiCreateLabel(425,60,20,22,"$",false,Fenster2[1])
  337. guiSetFont(Label2[16],"default-bold-small")
  338. Grid2[1] = guiCreateGridList(559,34,184,175,false,Fenster2[1])
  339. guiGridListSetSelectionMode(Grid2[1],1)
  340.  
  341. guiGridListAddColumn(Grid2[1],"Tenant",0.8)
  342. Knopf2[8] = guiCreateButton(422,171,115,30,"Remove tenant",false,Fenster2[1])
  343. Checkbox2[1] = guiCreateCheckBox(425,116,111,17,"Are you sure?",false,false,Fenster2[1])
  344. guiSetFont(Checkbox2[1],"default-bold-small")
  345. Knopf2[9] = guiCreateButton(423,137,115,30,"Set rentable",false,Fenster2[1])
  346. -- SET THE SETTINGS --
  347. -- TENANDS --
  348. guiGridListClear(Grid2[1])
  349. for index, player in pairs(tenands) do
  350. if(player ~= "no-one") then
  351. local row = guiGridListAddRow(Grid2[1])
  352. guiGridListSetItemText(Grid2[1], row, 1, player, false, false)
  353. end
  354. end
  355. -- RENTABLE --
  356. rentable = tonumber(rentable)
  357. if(rentable == 1) then
  358. guiSetText(Knopf2[9], "Set not rentable")
  359. end
  360. -- RENTALPRICE
  361. guiSetText(Label2[15], "Rentalprice: $"..rent)
  362.  
  363. -- LOCKED --
  364. locked = tonumber(locked)
  365. if(locked == 1) then
  366. guiSetText(Knopf2[6], "Unlock house")
  367. end
  368.  
  369. -- MONEY --
  370. guiSetText(Label2[3], "Current Money:\n"..money.."$")
  371.  
  372.  
  373. -- WEAPONS --
  374.  
  375. if(tonumber(weap1) == nil) then
  376. local weapon, ammo = gettok(weap1, 1, ","), gettok(weap1, 2, ",")
  377. if(weapon) and (ammo) then
  378. guiSetText(Label2[6], "Slot 1: "..getWeaponNameFromID(weapon).."\nAmmo: "..ammo)
  379. end
  380. end
  381. if(tonumber(weap2) == nil) then
  382. local weapon, ammo = gettok(weap2, 1, ","), gettok(weap2, 2, ",")
  383. if(weapon) and (ammo) then
  384. guiSetText(Label2[7], "Slot 2: "..getWeaponNameFromID(weapon).."\nAmmo: "..ammo)
  385. end
  386. end
  387. if(tonumber(weap3) == nil) then
  388. local weapon, ammo = gettok(weap3, 1, ","), gettok(weap3, 2, ",")
  389. if(weapon) and (ammo) then
  390. guiSetText(Label2[9], "Slot 3: "..getWeaponNameFromID(weapon).."\nAmmo: "..ammo)
  391. end
  392. end
  393. -- EVENT HANDLERS --
  394.  
  395. -- REMOVE TENANDS --
  396.  
  397. addEventHandler("onClientGUIClick", Knopf2[8], function()
  398. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  399. local user = guiGridListGetItemText(Grid2[1], guiGridListGetSelectedItem(Grid2[1]), 1)
  400. if(user == "") or (user == " ") then return end
  401. if(guiCheckBoxGetSelected(Checkbox2[1]) == false) then outputChatBox("You must be sure!", 255, 0, 0) return end
  402. triggerServerEvent("onHouseSystemTenandRemove", gMe, id, user)
  403. end, false)
  404.  
  405. -- SET RENTALPRICE --
  406. addEventHandler("onClientGUIClick", Knopf2[7], function()
  407. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  408. local value = tonumber(guiGetText(Edit2[2]))
  409. if(value == nil) or(value < 1) or (value > 20000) then outputChatBox("Bad input!", 255, 0, 0) return end
  410. value = math.floor(value)
  411. triggerServerEvent("onHouseSystemRentalprice", gMe, id, value)
  412. end, false)
  413.  
  414. -- SET RENTABLE --
  415. addEventHandler("onClientGUIClick", Knopf2[9], function()
  416. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  417. triggerServerEvent("onHouseSystemRentableSwitch", gMe, id)
  418. end, false)
  419.  
  420. -- WEAPON DEPOSIT --
  421. addEventHandler("onClientGUIClick", Knopf2[4], function()
  422. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  423. local radio = {}
  424. for i = 1, #Radio2, 1 do
  425. radio[i] = guiRadioButtonGetSelected(Radio2[i])
  426. end
  427. if(radio[1] == true) then
  428. triggerServerEvent("onHouseSystemWeaponDeposit", gMe, id, 1)
  429. elseif(radio[2] == true) then
  430. triggerServerEvent("onHouseSystemWeaponDeposit", gMe, id, 2)
  431. else
  432. triggerServerEvent("onHouseSystemWeaponDeposit", gMe, id, 3)
  433. end
  434. end, false)
  435.  
  436. -- WEAPON WITHDRAW--
  437. addEventHandler("onClientGUIClick", Knopf2[5], function()
  438. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  439. local radio = {}
  440. for i = 1, #Radio2, 1 do
  441. radio[i] = guiRadioButtonGetSelected(Radio2[i])
  442. end
  443. if(radio[1] == true) then
  444. triggerServerEvent("onHouseSystemWeaponWithdraw", gMe, id, 1)
  445. elseif(radio[2] == true) then
  446. triggerServerEvent("onHouseSystemWeaponWithdraw", gMe, id, 2)
  447. else
  448. triggerServerEvent("onHouseSystemWeaponWithdraw", gMe, id, 3)
  449. end
  450. end, false)
  451. -- MONEY WITHDRAW --
  452. addEventHandler("onClientGUIClick", Knopf2[2], function()
  453. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  454. local value = guiGetText(Edit2[1])
  455. if(value == "") then return end
  456. value = tonumber(value)
  457. if(value < 0) then outputChatBox("Bad money input!", 255, 0, 0) return end
  458. value = math.floor(value)
  459. triggerServerEvent("onHouseSystemHouseWithdraw", gMe, id, value)
  460. end, false)
  461.  
  462. -- MONEY DEPOSIT --
  463. addEventHandler("onClientGUIClick", Knopf2[1], function()
  464. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  465. local value = guiGetText(Edit2[1])
  466. if(value == "") then return end
  467. value = tonumber(value)
  468. if(value < 0) or (value > getPlayerMoney(gMe)-1) then outputChatBox("Bad money input!", 255, 0, 0) return end
  469. value = math.floor(value)
  470. triggerServerEvent("onHouseSystemHouseDeposit", gMe, id, value)
  471. end, false)
  472.  
  473. -- LOCK HOUSE --
  474. addEventHandler("onClientGUIClick", Knopf2[6], function()
  475. if(owner == false) then outputChatBox("You are not the owner of this house!", 255, 0, 0) return end
  476. triggerServerEvent("onHouseSystemHouseLock", gMe, id)
  477. end, false)
  478.  
  479. -- CANCEL --
  480. addEventHandler("onClientGUIClick", Knopf2[3], function()
  481. Guivar2 = 0
  482. showCursor(false)
  483. destroyElement(Fenster2[1])
  484. end, false)
  485. end
  486. end)
  487.  
  488. -- ON GUI START --
  489.  
  490. addEventHandler("onClientHouseSystemGUIStart", gMe, function()
  491. if(Guivar == 1) then return end
  492. Guivar = 1
  493. guiSetInputMode("no_binds_when_editing")
  494.  
  495. showCursor(true)
  496.  
  497. local X, Y, Width, Height = getMiddleGuiPosition(787,269) -- I'm too lazy :D
  498. Fenster[1] = guiCreateWindow(X, Y, Width, Height, "House creation[House System by Noneatme]",false)
  499. Label[1] = guiCreateLabel(495,24,107,17,"Interior preview:",false,Fenster[1])
  500. guiSetFont(Label[1],"default-bold-small")
  501. Label[2] = guiCreateLabel(490,27,124,15,"___________________",false,Fenster[1])
  502. guiLabelSetColor(Label[2],0, 255, 0)
  503. Edit[1] = guiCreateEdit(159,84,33,27,"",false,Fenster[1]) -- X INT
  504. Label[3] = guiCreateLabel(161,52,135,30,"X, Y, Z and INT\nof the House(Inside):",false,Fenster[1])
  505. guiSetFont(Label[3],"default-bold-small")
  506. Edit[2] = guiCreateEdit(196,84,33,27,"",false,Fenster[1]) -- Y INT
  507. Edit[3] = guiCreateEdit(234,84,33,27,"",false,Fenster[1]) -- Z INT
  508. Knopf[1] = guiCreateButton(156,116,112,32,"Set ----->",false,Fenster[1])
  509. Edit[4] = guiCreateEdit(17,177,80,27,"",false,Fenster[1]) -- PRICE
  510. Label[4] = guiCreateLabel(103,183,19,22,"$",false,Fenster[1])
  511. guiSetFont(Label[4],"default-bold-small")
  512. Knopf[2] = guiCreateButton(13,221,112,32,"Cancel",false,Fenster[1])
  513. Knopf[3] = guiCreateButton(132,221,107,31,"Create House",false,Fenster[1])
  514. Label[5] = guiCreateLabel(15,22,107,17,"Creation settings:",false,Fenster[1])
  515. guiSetFont(Label[5],"default-bold-small")
  516. Label[6] = guiCreateLabel(10,25,124,15,"___________________",false,Fenster[1])
  517. guiLabelSetColor(Label[6],0,255,0)
  518. Knopf[4] = guiCreateButton(15,114,112,32,"My Position",false,Fenster[1])
  519. Label[7] = guiCreateLabel(20,50,135,30,"X, Y, Z Position\nof the House(Outside):",false,Fenster[1])
  520. guiSetFont(Label[7],"default-bold-small")
  521. Label[8] = guiCreateLabel(18,157,46,19,"Price:",false,Fenster[1])
  522. guiSetFont(Label[8],"default-bold-small")
  523. Edit[5] = guiCreateEdit(18,82,33,27,"",false,Fenster[1]) -- X House
  524. Edit[6] = guiCreateEdit(55,82,33,27,"",false,Fenster[1]) -- Y ""
  525. Edit[7] = guiCreateEdit(93,82,33,27,"",false,Fenster[1]) -- Z ""
  526. Grid[1] = guiCreateGridList(314,23,162,237,false,Fenster[1])
  527. guiGridListSetSelectionMode(Grid[1],1)
  528.  
  529. guiGridListAddColumn(Grid[1],"ID",0.2)
  530.  
  531. guiGridListAddColumn(Grid[1],"Description",1)
  532.  
  533. Edit[8] = guiCreateEdit(272,84,33,27,"",false,Fenster[1]) -- INT INT
  534. Bild[1] = guiCreateStaticImage(486,51,290,204,"data/images/choose.jpg",false,Fenster[1])
  535. Label[9] = guiCreateLabel(164,22,107,17,"Interior:",false,Fenster[1])
  536. guiSetFont(Label[9],"default-bold-small")
  537. Label[10] = guiCreateLabel(159,25,124,15,"___________________",false,Fenster[1])
  538. guiLabelSetColor(Label[10],0,255,0)
  539.  
  540. -- FILL THE LIST --
  541. for i = 1, #houseInteriors, 1 do
  542. local row = guiGridListAddRow(Grid[1])
  543. guiGridListSetItemText(Grid[1], row, 1, i, false, false)
  544. guiGridListSetItemText(Grid[1], row, 2, gettok(houseInteriors[i], 5, string.byte(",")), false, false)
  545. end
  546. -- GRIDLIST EVENT --
  547. addEventHandler("onClientGUIClick", Grid[1], function()
  548. local text = guiGridListGetItemText(Grid[1], guiGridListGetSelectedItem(Grid[1]), 1)
  549. if(text == "") or (text == " ") then
  550. guiStaticImageLoadImage(Bild[1], "data/images/choose.jpg")
  551. else
  552. if(fileExists("data/images/"..text..".jpg")) then
  553. guiStaticImageLoadImage(Bild[1], "data/images/"..text..".jpg")
  554. else
  555. guiStaticImageLoadImage(Bild[1], "data/images/choose.jpg")
  556. end
  557. end
  558. end, false)
  559. ---------------------------
  560. -- BUTTON EVENT HANDLERS --
  561. ---------------------------
  562.  
  563. -- CREATE HOUSE BUTTON --
  564. addEventHandler("onClientGUIClick", Knopf[3], function()
  565. local x, y, z, intx, inty, intz, int, price = guiGetText(Edit[5]), guiGetText(Edit[6]), guiGetText(Edit[7]), guiGetText(Edit[1]), guiGetText(Edit[2]), guiGetText(Edit[3]), guiGetText(Edit[8]), guiGetText(Edit[4])
  566. if(x == "") or (y == "") or (z == "") or (intx == "") or (inty == "") or (intz == "") then outputChatBox("You must insert a value in all text fields!", 255, 0, 0) return end
  567. price = tonumber(price)
  568. if(price < 0) or (price > 10000000) then outputChatBox("Bad Price!", 255, 0, 0) return end
  569. triggerServerEvent("onHouseSystemHouseCreate", gMe, x, y, z, int, intx, inty, intz, price)
  570. end, false)
  571.  
  572. -- INTERIOR BUTTON --
  573. addEventHandler("onClientGUIClick", Knopf[1], function()
  574. local id = tonumber(guiGridListGetItemText(Grid[1], guiGridListGetSelectedItem(Grid[1]), 1))
  575. if(id == nil) then outputChatBox("You must select a house interior!", 255, 0, 0) return end
  576. local text = houseInteriors[id]
  577. local x, y, z, int = gettok(text, 1, string.byte(",")), gettok(text, 2, string.byte(",")), gettok(text, 3, string.byte(",")), gettok(text, 4, string.byte(","))
  578. guiSetText(Edit[1], x)
  579. guiSetText(Edit[2], y)
  580. guiSetText(Edit[3], z)
  581. guiSetText(Edit[8], int)
  582. end, false)
  583.  
  584. -- MY POSITION BUTTON --
  585. addEventHandler("onClientGUIClick", Knopf[4], function()
  586. local x, y, z = getElementPosition(gMe)
  587. guiSetText(Edit[5], x)
  588. guiSetText(Edit[6], y)
  589. guiSetText(Edit[7], z)
  590. end, false)
  591.  
  592. -- CANCEL BUTTON --
  593. addEventHandler("onClientGUIClick", Knopf[2], function()
  594. Guivar = 0
  595. showCursor(false)
  596. destroyElement(Fenster[1])
  597. end, false)
  598. end)
  599.  
  600. ------------
  601. -- RENDER --
  602. ------------
  603.  
  604. -- Streamed in Houses --
  605. local streamedHouses = {}
  606.  
  607. addEventHandler("onClientElementStreamIn", getRootElement(), function()
  608. if(getElementType(source) == "colshape") and (getElementData(source, "house") == true) then
  609. streamedHouses[source] = source
  610. end
  611. end)
  612.  
  613. addEventHandler("onClientElementStreamOut", getRootElement(), function()
  614. if(getElementType(source) == "colshape") and (getElementData(source, "house") == true) then
  615. if(streamedHouses[source] == true) then
  616. streamedHouses[source] = nil
  617. end
  618. end
  619. end)
  620.  
  621. for index, shit in pairs(getElementsByType("colshape", getRootElement(), true)) do
  622. if(getElementType(shit) == "colshape") and (getElementData(shit, "house") == true) then
  623. streamedHouses[shit] = shit
  624. end
  625. end
  626.  
  627. -- COLSHAPE ADD --
  628.  
  629. addEventHandler("onClientHouseSystemColshapeAdd", getRootElement(), function(shit)
  630. streamedHouses[shit] = shit
  631. end)
  632.  
  633. addEventHandler("onClientRender", getRootElement(), function()
  634. for index, house in pairs(streamedHouses) do
  635. if(house ~= false) and (house ~= nil) then
  636. if(isElement(house)) then
  637. local x, y, z = getElementPosition(house)
  638. local x2, y2, z2 = getElementPosition(gMe)
  639. if(isLineOfSightClear(x, y, z, x2, y2, z2, true, true, false, true)) then
  640. z = z+0.5
  641. local sx, sy = getScreenFromWorldPosition(x, y, z)
  642. if(sx) and (sy) then
  643. local distance = getDistanceBetweenElements(house, gMe)
  644. if(distance < 20) then
  645. local fontbig = 2-(distance/10)
  646. -- DRAW --
  647. local owner = getElementData(house, "OWNER")
  648. local price = getElementData(house, "PRICE")
  649. local locked = getElementData(house, "LOCKED")
  650. local houseid = getElementData(house, "ID")
  651. local lockedstate = "unlocked"
  652. if(tonumber(locked) == 1) then lockedstate = "locked" end
  653. local zone = getZoneName(x, y, z, false)
  654. if(owner) and (price) and (locked) and (houseid) then
  655. if(owner ~= "no-one") then
  656. local rentable, rentalprice = tonumber(getElementData(house, "RENTABLE")), getElementData(house, "RENTALPRICE")
  657. if(rentable == 1) then
  658. dxDrawText("House: "..houseid.." ("..zone..")\nOwner: "..owner.."\nPrice: $"..price.."\nThis house is rentable. Rentalprice: $"..rentalprice.."\nThis House is "..lockedstate..".", sx+2, sy+2, sx, sy, tocolor(0, 0, 0, 200), fontbig, "default-bold", "center")
  659. dxDrawText("House: "..houseid.." ("..zone..")\nOwner: "..owner.."\nPrice: $"..price.."\nThis house is rentable. Rentalprice: $"..rentalprice.."\nThis House is "..lockedstate..".", sx+2, sy+2, sx, sy, tocolor(255, 255, 255, 200), fontbig, "default-bold", "center")
  660. else
  661. dxDrawText("House: "..houseid.." ("..zone..")\nOwner: "..owner.."\nPrice: $"..price.."\nNot rentable\nThis house is "..lockedstate..".", sx+2, sy+2, sx, sy, tocolor(0, 0, 0, 200), fontbig, "default-bold", "center")
  662. dxDrawText("House: "..houseid.." ("..zone..")\nOwner: "..owner.."\nPrice: $"..price.."\nNot rentable\nThis house is "..lockedstate..".", sx, sy, sx, sy, tocolor(255, 255, 255, 200), fontbig, "default-bold", "center")
  663. end
  664. else
  665. dxDrawText("House: "..houseid.." ("..zone..")\nOwner: "..owner.."\nPrice: $"..price.."\nTo buy this house, use /buyhouse\nThis house is "..lockedstate..".", sx+2, sy+2, sx, sy, tocolor(0, 0, 0, 200), fontbig, "default-bold", "center")
  666. dxDrawText("House: "..houseid.." ("..zone..")\nOwner: "..owner.."\nPrice: $"..price.."\nTo buy this house, use /buyhouse\nThis house is "..lockedstate..".", sx, sy, sx, sy, tocolor(255, 255, 255, 200), fontbig, "default-bold", "center")
  667. end
  668. end
  669. end
  670. end
  671. end
  672. else
  673. house = nil
  674. end
  675. end
  676. end
  677. end)
  678.  
  679. ------------------------
  680. -- SETTINGS FUNCTIONS --
  681. ------------------------
  682.  
  683. function getMiddleGuiPosition(lol, lol2)
  684.  
  685. local sWidth, sHeight = guiGetScreenSize()
  686.  
  687. local Width,Height = lol, lol2
  688. local X = (sWidth/2) - (Width/2)
  689. local Y = (sHeight/2) - (Height/2)
  690.  
  691. return X, Y, Width, Height
  692. end
  693.  
  694. function getDistanceBetweenElements(element1, element2)
  695. local x, y, z = getElementPosition(element1)
  696. local x1, y1, z1 = getElementPosition(element2)
  697. return getDistanceBetweenPoints3D(x, y, z, x1, y1, z1)
  698. end
Advertisement
Add Comment
Please, Sign In to add comment