Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. ---------------------------------------
  2. --[[ © Soner Saykaci ]]--
  3. --------------------------------------
  4.  
  5. Garagen = {}
  6.  
  7. local torxml = xmlLoadFile("tore.xml")
  8. local tore = xmlNodeGetChildren(torxml)
  9. local count = 0
  10. for i,node in ipairs(tore) do
  11. _G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))] = createObject(xmlNodeGetAttribute(node,"Modell"),xmlNodeGetAttribute(node,"X"),xmlNodeGetAttribute(node,"Y"),xmlNodeGetAttribute(node,"Z"),0,0,xmlNodeGetAttribute(node,"Rot"))
  12. setElementData(_G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))],"ID",xmlNodeGetAttribute(node,"ID"))
  13. setElementData(_G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))],"Ort",xmlNodeGetAttribute(node,"Ort"))
  14. setElementData(_G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))],"Preis",tonumber(xmlNodeGetAttribute(node,"Preis")))
  15. setElementData(_G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))],"Besitzer",xmlNodeGetAttribute(node,"Besitzer"))
  16. setElementData(_G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))],"Z",tonumber(xmlNodeGetAttribute(node,"Z")))
  17. Garagen[_G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))]]=true
  18. count = count + 1
  19. local col = createColSphere(xmlNodeGetAttribute(node,"X"),xmlNodeGetAttribute(node,"Y"),xmlNodeGetAttribute(node,"Z"),10)
  20. setElementData(col,"Tor",_G["GaragenTor"..tonumber(xmlNodeGetAttribute(node,"ID"))])
  21. addEventHandler("onColShapeHit",col,function ( player )
  22. local Gate = getElementData(source,"Tor")
  23. if getElementType(player) == "player" then
  24. if getPlayerName(player) == "Keiner" then return end
  25. if getElementData(Gate,"Besitzer") == getPlayerName(player) then
  26. local x,y,_ = getElementPosition(Gate)
  27. local z = getElementData(Gate,"Z")
  28. moveObject(Gate,2000,x,y,z-15)
  29. end
  30. end
  31. end)
  32. addEventHandler("onColShapeLeave",col,function ( player )
  33. local Gate = getElementData(source,"Tor")
  34. if getElementType(player) == "player" then
  35. if getPlayerName(player) == "Keiner" then return end
  36. if getElementData(Gate,"Besitzer") == getPlayerName(player) then
  37. local x,y,_ = getElementPosition(Gate)
  38. local z = getElementData(Gate,"Z")
  39. moveObject(Gate,2000,x,y,z)
  40. end
  41. end
  42. end)
  43. end
  44. outputServerLog("[Garagensystem] Es wurde(n) "..count.. " Garage gefunden!")
  45. xmlUnloadFile(torxml)
  46.  
  47.  
  48.  
  49.  
  50. function onGarageClick ( _1,_2,object )
  51. if Garagen[object] then
  52. triggerClientEvent(source,"showGaragenGUI",source,object)
  53. end
  54. end
  55. addEventHandler("onPlayerClick",getRootElement(),onGarageClick)
  56.  
  57.  
  58.  
  59. addEvent("buyTor",true)
  60. addEventHandler("buyTor",getRootElement(),function ( id)
  61. if getPlayerName(source) == "Keiner" then return end
  62. if getElementData(_G["GaragenTor"..id],"Besitzer") == "Keiner" then
  63. if getPlayerMoney(source) >= getElementData(_G["GaragenTor"..id],"Preis") then
  64. setElementData(_G["GaragenTor"..id],"Besitzer",getPlayerName(source))
  65. local torxml = xmlLoadFile("tore.xml")
  66. local tore = xmlNodeGetChildren(torxml)
  67. for i,node in ipairs(tore) do
  68. if tonumber(xmlNodeGetAttribute(node,"ID")) == tonumber(id) then
  69. xmlNodeSetAttribute(node,"Besitzer",getPlayerName(source))
  70. end
  71. end
  72. takePlayerMoney(source,getElementData(_G["GaragenTor"..id],"Preis"))
  73. xmlSaveFile(torxml)
  74. xmlUnloadFile(torxml)
  75. outputChatBox("Du hast es erfolgreich gekauft!",source,0,125,0)
  76. else
  77. outputChatBox("Du hast nicht soviel Geld dabei!",source,125,0,0)
  78. end
  79. else
  80. outputChatBox("Diese Garage kannst du nicht kaufen!",source,125,0,0)
  81. end
  82. end)
  83.  
  84. addEvent("sellTor",true)
  85. addEventHandler("sellTor",getRootElement(),function ( id)
  86. if getPlayerName(source) == "Keiner" then return end
  87. if getElementData(_G["GaragenTor"..id],"Besitzer") == getPlayerName(source) then
  88. setElementData(_G["GaragenTor"..id],"Besitzer","Keiner")
  89. local torxml = xmlLoadFile("tore.xml")
  90. local tore = xmlNodeGetChildren(torxml)
  91. for i,node in ipairs(tore) do
  92. if tonumber(xmlNodeGetAttribute(node,"ID")) == tonumber(id) then
  93. xmlNodeSetAttribute(node,"Besitzer","Keiner")
  94. end
  95. end
  96. xmlSaveFile(torxml)
  97. xmlUnloadFile(torxml)
  98. givePlayerMoney(source,getElementData(_G["GaragenTor"..id],"Preis"))
  99. outputChatBox("Du hast es erfolgreich gekauft!",source,0,125,0)
  100. else
  101. outputChatBox("Diese Garage kannst du nicht verkaufen!",source,125,0,0)
  102. end
  103. end)
  104.  
  105. addEvent("closeTor",true)
  106. addEventHandler("closeTor",getRootElement(),function ( id)
  107. if getPlayerName(source) == "Keiner" then return end
  108. if getElementData(_G["GaragenTor"..id],"Besitzer") == getPlayerName(source) then
  109. if getElementData(_G["GaragenTor"..id],"Open") == true then
  110. local x,y,_ = getElementPosition(_G["GaragenTor"..id])
  111. local z = getElementData(_G["GaragenTor"..id],"Z")
  112. moveObject(_G["GaragenTor"..id],2000,x,y,z)
  113. setElementData(_G["GaragenTor"..id],"Open",false)
  114. else
  115. outputChatBox("Das Tor ist bereits zu!",source,125,0,0)
  116. end
  117. else
  118. outputChatBox("Du kannst dieses Tor nicht öffnen!",source,125,0,0)
  119. end
  120. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement