Advertisement
Guest User

Untitled

a guest
May 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.63 KB | None | 0 0
  1. --=================================================================================================================--
  2. --=================================================================================================================--
  3. --=================================================================================================================--
  4. local HOSPITAL_PRICE = 100
  5. local HOSPITAL_LENGHT = 2.1
  6. local HOSPITAL_BLOODTIMER = 75
  7. local HOSPITAL_UNTILFIRSTAID = "45.000"
  8. local HOSPITAL_FIRSTPERSON_TIMER = 0.5
  9. local HOSPITAL_MARKET = { 1177.75, -1323.24, 14.09, 0, 0, -86.81, "All Saints General", 1181.55, -1319.66, 13.58, 0, 0, 127.03 }
  10. local HOSPITAL_MONTGOMERY = { 1242.79, 329.95, 19.76, 0, 0, -21.13, "Crippen Memorial", 1241.82, 334.13, 19.55, 0, 0, -170.11 }
  11. local HOSPITAL_JEFFERSON = { 2012.62, -1435.74, 13.55, 0, 0, 136.74, "County General", 2010.69, -1440.31, 13.56, 0, 0, -28.22 }
  12. local HOSPITAL_BLOOD_LITE = {   50.0, 25.0 }
  13. local HOSPITAL_BLOOD_MIDDLE = { 25.0, 15.0 }
  14. local HOSPITAL_BLOOD_HARD = {   15.0, 0.0 }
  15. --=================================================================================================================--
  16. --=================================================================================================================--
  17. --=================================================================================================================--
  18. local Hospital = {}
  19. Hospital.Window = {}
  20. Hospital.Button = {}
  21. Hospital.Memo = {}
  22. Hospital.Checkbox = {}
  23. Hospital.Label = {}
  24. Hospital.Edit = {}
  25. Hospital.Progress = {}
  26. Hospital.Grid = {}
  27. Hospital.Image = {}
  28. --=================================================================================================================--
  29. --=================================================================================================================--
  30. --=================================================================================================================--
  31. function HospitalCountdown()
  32.     if tonumber(Hospital["count"]) < 0.1 then
  33.         removeEventHandler("onClientRender", getRootElement(), HospitalCountdown)
  34.         removeEventHandler("onClientPreRender", getRootElement(), adjustCamera)
  35.         removeEventHandler("onClientCursorMove", getRootElement(), adjustCursor)
  36.         Hospital["count"] = "0.0000"
  37.         HospitalSystem()
  38.     end
  39.     --=================================================================================================================--
  40.     dxDrawRectangle(7.0,485.0,135.0,42.0,tocolor(0,0,0,100),false)
  41.     dxDrawText("0:"..gettok(Hospital["count"],1,string.byte('.'))..":"..gettok(Hospital["count"],2,string.byte('.')).."\n"..getLanguageText("HOSPITAL", "COUNTDOWN"),13.0,491.0,136.0,525.0,tocolor(255,255,255,255),1.0,"default-bold","left","top",false,false,false)
  42. end
  43.  
  44. function getLanguageText(text, text)
  45.     return "No Language XML"
  46. end
  47.  
  48. function HospitalWindow()
  49.     Hospital.Window[1] = guiCreateWindow(0.0953,0.251,0.4148,0.4111,"Hospital",true)
  50.     Hospital.Image[1] = guiCreateStaticImage(0.0169,0.0356,0.354,0.4228,"Bilder/hospital_symbol.png",true,Hospital.Window[1])
  51.     Hospital.Grid[1] = guiCreateGridList(0.4689,0.0641,0.5104,0.3872,true,Hospital.Window[1])
  52.     guiGridListSetSelectionMode(Hospital.Grid[1],2)
  53.     Hospital.Label[1] = guiCreateLabel(0.0406,0.0491,0.8635,0.1779,getLanguageText("HOSPITAL", "G_RECS"),true,Hospital.Grid[1])
  54.     guiLabelSetColor(Hospital.Label[1],255,255,255)
  55.     guiLabelSetVerticalAlign(Hospital.Label[1],"top")
  56.     guiLabelSetHorizontalAlign(Hospital.Label[1],"left",false)
  57.     guiSetFont(Hospital.Label[1],"default-bold-small")
  58.     Hospital.Label[2] = guiCreateLabel(0.0369,0.0798,0.5867,0.1166,"______________________",true,Hospital.Grid[1])
  59.     guiLabelSetColor(Hospital.Label[2],255,255,255)
  60.     guiLabelSetVerticalAlign(Hospital.Label[2],"top")
  61.     guiLabelSetHorizontalAlign(Hospital.Label[2],"left",false)
  62.     Hospital.Label[3] = guiCreateLabel(0.0406,0.2393,0.8745,0.6687,string.format(getLanguageText("HOSPITAL", "GUI_DATA"), getPlayerName(getLocalPlayer()), tostring(getElementData(getLocalPlayer(),"age")), 'Stable', Hospital["hospital"], 'Spaeter'),true,Hospital.Grid[1])
  63.     guiSetAlpha(Hospital.Label[3],0.60000002384186)
  64.     guiLabelSetColor(Hospital.Label[3],255,255,255)
  65.     guiLabelSetVerticalAlign(Hospital.Label[3],"top")
  66.     guiLabelSetHorizontalAlign(Hospital.Label[3],"left",false)
  67.     guiSetFont(Hospital.Label[3],"default-bold-small")
  68.     Hospital.Button[1] = guiCreateButton(0.3898,0.4751,0.1657,0.0309,"Maximize",true,Hospital.Window[1])
  69.     guiSetFont(Hospital.Button[1],"default-bold-small")
  70.     Hospital.Image[2] = guiCreateStaticImage(0.823,0.5534,0.1582,0.4204,"Bilder/hospital_doctor.png",true,Hospital.Window[1])
  71.     Hospital.Checkbox[1] = guiCreateCheckBox(0.0282,0.658,0.2731,0.0404,getLanguageText("HOSPITAL", "GUI_POLICE"),false,true,Hospital.Window[1])
  72.     guiCheckBoxSetSelected(Hospital.Checkbox[1],true)
  73.     guiSetFont(Hospital.Checkbox[1],"default-bold-small")
  74.     Hospital.Memo[1] = guiCreateMemo(0.0282,0.715,0.5254,0.2447,"Strafanzeige stellen",true,Hospital.Window[1])
  75.     guiSetAlpha(Hospital.Memo[1],0.60000002384186)
  76.     Hospital.Edit[1] = guiCreateEdit(0.3277,0.6508,0.2241,0.0451,Hospital["killer"],true,Hospital.Window[1])
  77.     Hospital.Label[4] = guiCreateLabel(0.339,0.6247,0.1262,0.0356,"Killer",true,Hospital.Window[1])
  78.     guiLabelSetColor(Hospital.Label[4],255,255,255)
  79.     guiLabelSetVerticalAlign(Hospital.Label[4],"top")
  80.     guiLabelSetHorizontalAlign(Hospital.Label[4],"left",false)
  81.     guiSetFont(Hospital.Label[4],"default-small")
  82.     Hospital.Button[2] = guiCreateButton(0.5763,0.9192,0.2373,0.038,"Anzeige aufgeben",true,Hospital.Window[1])
  83.     guiSetFont(Hospital.Button[2],"default-bold-small")
  84.     Hospital.Label[5] = guiCreateLabel(0.58,0.8385,0.2335,0.0689,getLanguageText("HOSPITAL", "GUI_SIGNS"),true,Hospital.Window[1])
  85.     guiLabelSetColor(Hospital.Label[5],255,255,255)
  86.     guiLabelSetVerticalAlign(Hospital.Label[5],"top")
  87.     guiLabelSetHorizontalAlign(Hospital.Label[5],"left",false)
  88.     guiSetFont(Hospital.Label[5],"default-bold-small")
  89.     Hospital.Progress[1] = guiCreateProgressBar(0.5706,0.7696,0.2467,0.0546,true,Hospital.Window[1])
  90.     guiSetAlpha(Hospital.Progress[1],0.5)
  91.     guiProgressBarSetProgress(Hospital.Progress[1],23)
  92.     Hospital.Label[6] = guiCreateLabel(0.5838,0.7435,0.1789,0.0285,"Behandlungsfortschritt:",true,Hospital.Window[1])
  93.     guiLabelSetColor(Hospital.Label[6],255,255,255)
  94.     guiLabelSetVerticalAlign(Hospital.Label[6],"top")
  95.     guiLabelSetHorizontalAlign(Hospital.Label[6],"left",false)
  96.     guiSetFont(Hospital.Label[6],"default-small")
  97. end
  98.  
  99. --=================================================================================================================--
  100. --=================================================================================================================--
  101. --=================================================================================================================--
  102.  
  103. function DeathSystem(killer, weapon, bodypart)
  104.     if not killer then
  105.         Hospital["killer"] = "N/A"
  106.     else
  107.         Hospital["killer"] = getPlayerName(killer)
  108.     end
  109.     Hospital["x"], Hospital["y"], Hospital["z"] = getElementPosition(source)
  110.     Hospital["locations"] = {
  111.     getMeterDistance(Hospital["x"], Hospital["y"], Hospital["z"], HOSPITAL_MARKET[1], HOSPITAL_MARKET[2], HOSPITAL_MARKET[3]),
  112.     getMeterDistance(Hospital["x"], Hospital["y"], Hospital["z"], HOSPITAL_MONTGOMERY[1], HOSPITAL_MONTGOMERY[2], HOSPITAL_MONTGOMERY[3]),
  113.     getMeterDistance(Hospital["x"], Hospital["y"], Hospital["z"], HOSPITAL_JEFFERSON[1], HOSPITAL_JEFFERSON[2], HOSPITAL_JEFFERSON[3]) }
  114.                            
  115.     for i = 1, #Hospital["locations"] do
  116.         if Hospital["distance"] == nil or Hospital["distance"] == 0 then
  117.             Hospital["distance"] = Hospital["locations"][i]
  118.         else
  119.             if Hospital["distance"] > Hospital["locations"][i] then
  120.                 Hospital["distance"] = Hospital["locations"][i]
  121.                 Hospital["hospital"] = i
  122.             end
  123.         end
  124.     end
  125.    
  126.     if Hospital["hospital"] == 1 then   Hospital["hospital"] = HOSPITAL_MARKET[7]
  127.     elseif Hospital["hospital"] == 2 then   Hospital["hospital"] = HOSPITAL_MONTGOMERY[7]
  128.     elseif Hospital["hospital"] == 3 then   Hospital["hospital"] = HOSPITAL_JEFFERSON[7]
  129.     end
  130.    
  131.     HospitalSystem()   
  132.     setTimer(FirstPerson, 1000*HOSPITAL_FIRSTPERSON_TIMER, 1)
  133. end
  134.  
  135. function outputError(text)
  136.     outputChatBox(text)
  137. end
  138.  
  139. function DamageSystem(attacker, weapon, bodypart, loss)
  140.     outputError("DamageSystem triggered")
  141.     if isTimer(Hospital["timer"]) then
  142.         killTimer(Hospital["timer"])
  143.     end
  144.     outputError("DamageSystem - Line")
  145.     if getElementHealth(getLocalPlayer()) > HOSPITAL_BLOOD_LITE[1] and getElementHealth(getLocalPlayer()) < HOSPITAL_BLOOD_LITE[2] then
  146.         Hospital["timer"] = setTimer(DamageBlood, HOSPITAL_BLOODTIMER*1000, 0, "HOSPITAL_BLOOD_LITE")
  147.        
  148.     elseif getElementHealth(getLocalPlayer()) > HOSPITAL_BLOOD_MIDDLE[1] and getElementHealth(getLocalPlayer()) < HOSPITAL_BLOOD_MIDDLE[2] then
  149.         Hospital["timer"] = setTimer(DamageBlood, HOSPITAL_BLOODTIMER*1000, 0, "HOSPITAL_BLOOD_MIDDLE")
  150.        
  151.     elseif getElementHealth(getLocalPlayer()) > HOSPITAL_BLOOD_HARD[1] and getElementHealth(getLocalPlayer()) < HOSPITAL_BLOOD_HARD[2] then
  152.         Hospital["timer"] = setTimer(DamageBlood, HOSPITAL_BLOODTIMER*1000, 0, "HOSPITAL_BLOOD_HARD")
  153.     end
  154.     outputError("DamageSystem - DamageSystem passed")
  155. end
  156.  
  157. function DamageBlood(typ)
  158.     if typ == "HOSPITAL_BLOOD_LITE" then
  159.         outputChatBox(getLanguageText("HOSPITAL", "PED_BLOOD_LITE"), 255, 255, 255, true)
  160.         Hospital["damage_x"], Hospital["damage_y"], Hospital["damage_z"] = getElementPosition(getLocalPlayer())
  161.         fxAddBlood ( Hospital["damage_x"], Hospital["damage_y"], Hospital["damage_z"]-2, 0.00000, 0.00000, 0.00000, math.random(1,2), 1)
  162.     elseif typ == "HOSPITAL_BLOOD_MIDDLE" then
  163.         outputChatBox(getLanguageText("HOSPITAL", "HOSPITAL_BLOOD_MIDDLE"), 255, 255, 255, true)
  164.         Hospital["damage_x"], Hospital["damage_y"], Hospital["damage_z"] = getElementPosition(getLocalPlayer())
  165.         fxAddBlood ( Hospital["damage_x"], Hospital["damage_y"], Hospital["damage_z"]-2, 0.00000, 0.00000, 0.00000, math.random(2,3), 1)
  166.     elseif typ == "HOSPITAL_BLOOD_HARD" then
  167.         outputChatBox(getLanguageText("HOSPITAL", "HOSPITAL_BLOOD_HARD"), 255, 255, 255, true)
  168.         Hospital["damage_x"], Hospital["damage_y"], Hospital["damage_z"] = getElementPosition(getLocalPlayer())
  169.         fxAddBlood ( Hospital["damage_x"], Hospital["damage_y"], Hospital["damage_z"]-2, 0.00000, 0.00000, 0.00000, math.random(3,4), 1)
  170.     end
  171. end
  172.  
  173. function HospitalSystem()
  174.     HospitalWindow()
  175.     for i = 1, 2 do
  176.         addEventHandler("onClientGUIClick", Hospital.Button[i], HospitalClick, false)
  177.     end
  178. end
  179.  
  180. function HospitalClick(button, state)
  181.     if button == "left" then
  182.         if state == Hospital.Button[1] then
  183.             Buttontext = ""..(guiGetText(Hospital.Button[1]) == "Maximize" and "Maximize" or "Minimize")..""
  184.             if guiGetText(Hospital.Button[1]) == "Maximize" then
  185.                 guiSetText(Hospital.Button[1], "Minimize")
  186.             else
  187.                 guiSetText(Hospital.Button[1], "Maximize")
  188.             end
  189.             addEventHandler("onClientRender", getRootElement(), HospitalMenu)
  190.         elseif state == Hospital.Button[2] then
  191.             outputChatBox("Not completed")
  192.         end
  193.     end
  194. end
  195.  
  196. function HospitalMenu()
  197.     local MAIN_BIG_SIZEWINDOW = 0.251
  198.     local MAIN_SMALL_SIZEWINDOW = 0.151
  199.     local MAIN_VALUE_SETSIZE = 0.01
  200.     --
  201.     Hospital["main_x"], Hospital["main_y"] = guiGetSize(Hospital.Window[1], true)
  202.     if Hospital["main_y"] < MAIN_BIG_SIZEWINDOW then
  203.         guiSetSize(Hospital.Window[1], Hospital["main_x"], Hospital["main_y"]+MAIN_VALUE_SETSIZE, true)
  204.         if Hospital["main_y"] > MAIN_SMALL_SIZEWINDOW then
  205.             removeEventHandler("onClientRender", getRootElement(), HospitalMenu)
  206.         end
  207.     elseif Hospital["main_y"] > MAIN_SMALL_SIZEWINDOW then
  208.         guiSetSize(Hospital.Window[1], Hospital["main_x"], Hospital["main_y"]-MAIN_VALUE_SETSIZE, true)
  209.         if Hospital["main_y"] < MAIN_BIG_SIZEWINDOW then
  210.             removeEventHandler("onClientRender", getRootElement(), HospitalMenu)
  211.         end
  212.     end
  213. end
  214. --=================================================================================================================--
  215. --=================================================================================================================--
  216. --=================================================================================================================--
  217. function FirstPerson()
  218.     Hospital["fperson"] = true
  219.     Hospital["count"] = HOSPITAL_UNTILFIRSTAID
  220.     addEventHandler("onClientRender", getRootElement(), HospitalCountdown)
  221.     addEventHandler("onClientPreRender", getRootElement(), adjustCamera)
  222.     addEventHandler("onClientCursorMove", getRootElement(), adjustCursor)
  223. end
  224.  
  225. function adjustCamera(timeSlice)
  226.     Hospital["count"] = tonumber(Hospital["count"])-timeSlice
  227.     if Hospital["fperson"] == true then
  228.         Hospital["head_x"], Hospital["head_y"], Hospital["head_z"] = getPedBonePosition(getLocalPlayer(), 6)
  229.         setCameraMatrix(Hospital["head_x"], Hospital["head_y"], Hospital["head_z"], Hospital["head_x"] + Hospital["absoulute_x"], Hospital["head_y"] + Hospital["absoulute_y"], Hospital["head_z"] + Hospital["absoulute_z"])
  230.     end
  231. end
  232.  
  233. function adjustCursor(cursorX, cursorY, absoluteX, absoluteY, worldX, worldY, worldZ)
  234.     Hospital["cursor_x"], Hospital["cursor_y"], Hospital["cursor_z"] = getCameraMatrix()
  235.     Hospital["absoulute_x"] = (worldX-Hospital["cursor_x"])/300
  236.     Hospital["absoulute_y"] = (worldY-Hospital["cursor_y"])/300
  237.     Hospital["absoulute_z"] = (worldZ-Hospital["cursor_z"])/300
  238. end
  239. --=================================================================================================================--
  240. --=================================================================================================================--
  241. --=================================================================================================================--
  242. addEventHandler("OnClientPlayerDamage", getRootElement(), DamageSystem)
  243. addEventHandler("OnClientPlayerWasted", getRootElement(), DeathSystem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement