Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [lua]addEvent("doSlenderClientPlaySound", true)
- addEvent("onSlenderClientTaschenlampe", true)
- addEvent("doSlenderClientSendMessage", true)
- -- VARIABLES --
- local slender_font = dxCreateFont("data/fonts/COPRGTB.ttf", 50)
- sound = {}
- local textd = {}
- local slendyshock = false
- wasted = false
- local s_en = false
- taschenlampstate = true
- textd["status"] = false
- textd["text"] = ""
- textd["timer"] = false
- local sprinttimer
- local cantsprint = true
- local fade = 0
- local atSelection = false
- local select_button = {}
- current_map = false
- alpha_selection = {}
- alpha_selection["industry"] = 200
- alpha_selection["forest"] = 200
- -- EVENTS AN FUNCTIONS --
- addEventHandler("doSlenderClientPlaySound", getLocalPlayer(), function(url, bool)
- playSound("data/sounds/"..url, bool)
- end)
- addEventHandler("onSlenderClientTaschenlampe", getLocalPlayer(), function(state)
- if(fertig ~= true) then
- if(state == true) then
- setFogDistance(0)
- else
- setFogDistance(-500)
- end
- taschenlampstate = state
- end
- end)
- local function collect_page(id)
- pages = pages+1
- pages_done[id] = true
- triggerEvent("doSlenderClientSendMessage", localPlayer, "Pages "..pages.."/8")
- playSound("data/sounds/page_collect.mp3", false)
- if(pages == 1) then
- sound["page1"] = playSound("data/sounds/music_page_1.mp3", true)
- end
- if(pages == 3) then
- sound["page3"] = playSound("data/sounds/music_page_3.mp3", true)
- setTimer(function()
- destroyElement(sound["page1"])
- end, 2000, 1)
- end
- if(pages == 6) then
- sound["page6"] = playSound("data/sounds/music_page_6.mp3", true)
- setTimer(function()
- destroyElement(sound["page3"])
- end, 2000, 1)
- end
- refresh_slender_ai(pages)
- end
- local function slender_page_check()
- for i = 1, 8, 1 do
- local x, y, z = getElementPosition(localPlayer)
- local x2, y2, z2 = page_location[current_map][i][1], page_location[current_map][i][2], page_location[current_map][i][3]
- if(getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 3) and (pages_done[i] ~= true) then
- collect_page(i)
- break;
- end
- end
- end
- local function triggerResourceStart(theMap)
- if(theMap == "forest") then
- sound["grillen"] = playSound3D("data/sounds/grillen2.mp3", -742.23272705078, -2068.0236816406, 20.0146446228027, true)
- setSoundMaxDistance(sound["grillen"], 500)
- elseif(theMap == "city") then
- elseif(theMap == "industry") then
- end
- setTimer(function()
- triggerEvent("doSlenderClientSendMessage", localPlayer, "Press 'Fire' to turn the Flashlight on/off,", 4000)
- setTimer(function()
- triggerEvent("doSlenderClientSendMessage", localPlayer, "Press 'E' to pick up pages.")
- end, 4000, 1)
- end, 4000, 1)
- -- SPRINT --
- setGameSpeed(0.<!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\" /><!-- s8) -->
- bindKey("sprint", "both", function(key, state)
- if(state == "down") then
- if(cantsprint == true) then
- setGameSpeed(1.2)
- sprinttimer = setTimer(function()
- local gs = getGameSpeed()
- gs = gs-0.05
- if(gs > 0.9) then
- setGameSpeed(gs)
- else
- if(cantsprint == true) then
- cantsprint = false
- setTimer(function()
- cantsprint = true
- end, 10000, 1)
- setSoundVolume(playSound("data/sounds/breathing.mp3", false), 0.<!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\" /><!-- s8) -->
- end
- end
- end, 1000, -1)
- end
- else
- if(isTimer(sprinttimer)) then
- killTimer(sprinttimer)
- end
- setGameSpeed(0.<!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\" /><!-- s8) -->
- end
- end)
- bindKey("e", "down", slender_page_check)
- -- SOUNDS --
- sound["staticlong"] = playSound("data/sounds/static_long.mp3", true)
- setSoundVolume(sound["staticlong"], 0)
- end
- local function deleteSelectionButtons()
- for index, k in pairs(select_button) do
- destroyElement(k)
- end
- atSelection = false
- setTimer(function()
- triggerServerEvent("doClientSpawnPlayerToServer", localPlayer, current_map)
- triggerResourceStart(current_map)
- end, 1000, 1)
- showCursor(false)
- end
- local function buildSelectionButtons()
- --[[
- dxDrawImage(sx/2-(275/1600*sx), sy/2-(200/900*sy), 501/1600*sx, 103/900*sy, "data/img/selection_forest.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["forest"]))
- dxDrawImage(sx/2-(275/1600*sx), sy/2-(80/900*sy), 501/1600*sx, 103/900*sy, "data/img/selection_industry.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["industry"]))
- -- TEXT --
- local scale = 0.5/1600*sx
- dxDrawText("CHOOSE A MAP", sx/2-(200/1600*sx), sy/2-(300/900*sy), sx/2, sy/2, tocolor(255, 255, 255), scale, slender_font)
- scale = 0.3/1600*sx
- dxDrawText("FOREST", sx/2-(270/1600*sx), sy/2-(125/900*sy), sx/2, sy/2, tocolor(255, 255, 255, alpha_selection["forest"]), scale, slender_font)
- dxDrawText("INDUSTRY", sx/2-(270/1600*sx), sy/2-(5/900*sy), sx/2, sy/2, tocolor(255, 255, 255, alpha_selection["forest"]), scale, slender_font)
- ]]
- local sx, sy = guiGetScreenSize()
- select_button["forest"] = guiCreateButton(sx/2-(275/1600*sx), sy/2-(200/900*sy), 501/1600*sx, 103/900*sy, "", false)
- select_button["industry"] = guiCreateButton(sx/2-(275/1600*sx), sy/2-(80/900*sy), 501/1600*sx, 103/900*sy, "", false)
- guiSetAlpha(select_button["forest"], 0)
- guiSetAlpha(select_button["industry"], 0)
- addEventHandler("onClientMouseEnter", select_button["forest"], function()
- alpha_selection["forest"] = 255
- playSoundFrontEnd(41)
- end)
- addEventHandler("onClientMouseLeave", select_button["forest"], function()
- alpha_selection["forest"] = 200
- end)
- addEventHandler("onClientGUIClick", select_button["forest"], function()
- deleteSelectionButtons()
- current_map = "forest"
- end, false)
- addEventHandler("onClientMouseEnter", select_button["industry"], function()
- alpha_selection["industry"] = 255
- playSoundFrontEnd(41)
- end)
- addEventHandler("onClientMouseLeave", select_button["industry"], function()
- alpha_selection["industry"] = 200
- end)
- addEventHandler("onClientGUIClick", select_button["industry"], function()
- deleteSelectionButtons()
- current_map = "industry"
- end, false)
- end
- addEventHandler("onClientResourceStart", getResourceRootElement(), function()
- for i = 1, 30, 1 do
- outputChatBox(" ")
- end
- showPlayerHudComponent("all", false)
- -- triggerServerEvent("doClientSpawnPlayerToServer", getLocalPlayer())
- -- SELECTION --
- addEventHandler("onClientPlayerDamage", localPlayer, cancelEvent)
- atSelection = true
- buildSelectionButtons()
- showCursor(true)
- fadeCamera(true)
- setCameraMatrix(2226.3798828125, -2209.3366699219, 14.26592540741, 2293.7722167969, -2135.7702636719, 21.066173553467)
- end)
- function try_slender_again()
- -- triggerServerEvent("doClientSpawnPlayerToServer", getLocalPlayer(), current_map)
- atSelection = true
- buildSelectionButtons()
- showCursor(true)
- fadeCamera(true)
- setCameraMatrix(2226.3798828125, -2209.3366699219, 14.26592540741, 2293.7722167969, -2135.7702636719, 21.066173553467)
- unbindKey("enter", "down", try_slender_again)
- wasted = false
- slendyshock = false
- s_en = false
- fertig = false
- pages = 0
- last_ai = 1
- fade = 0
- for i = 1, 8, 1 do
- pages_done[i] = false
- end
- if(isTimer(ai_data["timer"])) then
- killTimer(ai_data["timer"])
- end
- end
- local function slender_player_wasted()
- if(isElement(sound["page1"])) then
- destroyElement(sound["page1"])
- end
- if(isElement(sound["page3"])) then
- destroyElement(sound["page3"])
- end
- if(isElement(sound["page6"])) then
- destroyElement(sound["page6"])
- end
- playSound("data/sounds/bum.mp3", false)
- wasted = true
- setTimer(function()
- s_en = true
- setSoundVolume(sound["staticlong"], 1.0)
- setTimer(function()
- s_en = false
- setSoundVolume(sound["staticlong"], 0.0)
- setTimer(function()
- s_en = true
- setSoundVolume(sound["staticlong"], 1.0)
- setTimer(function()
- s_en = false
- setSoundVolume(sound["staticlong"], 0.0)
- setTimer(function()
- s_en = true
- setSoundVolume(sound["staticlong"], 1.0)
- setTimer(function()
- s_en = false
- setSoundVolume(sound["staticlong"], 0.0)
- setTimer(function()
- triggerEvent("doSlenderClientSendMessage", localPlayer, "Press enter to try again.")
- bindKey("enter", "down", try_slender_again)
- end, 1000, 1)
- end, 500, 1)
- end, 150, 1)
- end, 250, 1)
- end, 200, 1)
- end, 50, 1)
- end, 100, 1)
- destroyElement(slendy)
- page = 0
- for i = 1, 8, 1 do
- pages_done[i] = false
- end
- if(isTimer(ai_data["timer"])) then
- killTimer(ai_data["timer"])
- end
- end
- -- addCommandHandler("die", slender_player_wasted)
- -- CLIENT RENDER --
- local function slender_render()
- if(atSelection == false) then
- local sx, sy = guiGetScreenSize()
- local scale
- -- PAGES --
- for i = 1, 8, 1 do
- if(pages_done[i] == false) then
- dxDrawMaterialLine3D(page_location[current_map][i][1], page_location[current_map][i][2], page_location[current_map][i][3]+0.5, page_location[current_map][i][1], page_location[current_map][i][2], page_location[current_map][i][3]-0.5, page_mat[i], 0.9, tocolor(255,255,255,255), page_facel[current_map][i][1],page_facel[current_map][i][2], page_facel[current_map][i][3])
- end
- end
- -- SLENDER --
- if(isElement(slendy)) then
- -- ROT --
- local x3, y3, z3 = getElementPosition(slendy)
- local x4, y4, z4 = getElementPosition(localPlayer)
- local rot = math.atan2(y4 - y3, x4 - x3) * 180 / math.pi
- rot = rot-90
- setPedRotation(slendy, rot)
- -- BUM CHECK --
- local x, y, z = getElementPosition(localPlayer)
- local x2, y2, z2 = getElementPosition(slendy)
- if(isElementOnScreen(slendy)) and (isLineOfSightClear(x, y, z, x2, y2, z2, true, true, false, true)) and (getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) < 5) then
- if(slendyshock == false) then
- slendyshock = true
- playSound("data/sounds/bum.mp3", false)
- end
- else
- slendyshock = false
- end
- -- FADE --
- local distance = getDistanceBetweenPoints3D(x3, y3, z3, x4, y4, z4)
- if(taschenlampstate == true) then
- distance = 0
- end
- if(isElementOnScreen(slendy)) and (isLineOfSightClear(x, y, z, x2, y2, z2, true, true, false, true)) and (distance < 10) then
- fade = fade+1
- dxDrawImage(0, 0, sx, sy, "data/img/slender.png", 0, 0, 0, tocolor(255, 255, 255, fade))
- dxDrawImage(0, 0, sx, sy, "data/img/static.png", 0, 0, 0, tocolor(255, 255, 255, fade))
- setSoundVolume(sound["staticlong"], fade/2.55/100)
- if(fade > 200) then
- if(page ~= <!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\" /><!-- s8) --> then
- if(wasted == false) then
- slender_player_wasted()
- end
- end
- end
- else
- if(fade > 0) then
- fade = fade-0.5
- dxDrawImage(0, 0, sx, sy, "data/img/slender.png", 0, 0, 0, tocolor(255, 255, 255, fade))
- dxDrawImage(0, 0, sx, sy, "data/img/static.png", 0, 0, 0, tocolor(255, 255, 255, fade))
- setSoundVolume(sound["staticlong"], fade/2.55/100)
- end
- end
- end
- if(wasted == true) then
- dxDrawRectangle(0, 0, sx, sy, tocolor(0, 0, 0, 255))
- if(s_en == true) then
- dxDrawImage(0, 0, sx, sy, "data/img/static.png", 0, 0, 0, tocolor(255, 255, 255, 255))
- dxDrawImage(0, 0, sx, sy, "data/img/slender.png", 0, 0, 0, tocolor(255, 255, 255, 200))
- end
- end
- if(textd["status"] == true) then
- scale = 3/1920*sx
- dxDrawText(textd["text"], sx/2, sy/2-(200/1080*sy), sx/2, sy/2-(500/1080*sy), tocolor(255, 255, 255, 200), scale, "default-bold", "center")
- end
- else
- -- SELECTION DRAW --
- -- IMAGES --
- local sx, sy = guiGetScreenSize()
- dxDrawImage(sx/2-(275/1600*sx), sy/2-(200/900*sy), 501/1600*sx, 103/900*sy, "data/img/selection_forest.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["forest"]))
- dxDrawImage(sx/2-(275/1600*sx), sy/2-(80/900*sy), 501/1600*sx, 103/900*sy, "data/img/selection_industry.jpg", 0, 0, 0, tocolor(255, 255, 255, alpha_selection["industry"]))
- -- TEXT --
- local scale = 0.5/1600*sx
- dxDrawText("CHOOSE A MAP", sx/2-(200/1600*sx), sy/2-(300/900*sy), sx/2, sy/2, tocolor(255, 255, 255), scale, slender_font)
- scale = 0.3/1600*sx
- dxDrawText("FOREST", sx/2-(270/1600*sx), sy/2-(125/900*sy), sx/2, sy/2, tocolor(255, 255, 255, alpha_selection["forest"]), scale, slender_font)
- dxDrawText("INDUSTRY", sx/2-(270/1600*sx), sy/2-(5/900*sy), sx/2, sy/2, tocolor(255, 255, 255, alpha_selection["forest"]), scale, slender_font)
- end
- end
- addEventHandler("onClientPreRender", getRootElement(), slender_render)
- -- SLENDER MSG --
- addEventHandler("doSlenderClientSendMessage", getLocalPlayer(), function(text, time)
- if(isTimer(textd["timer"])) then
- killTimer(textd["timer"])
- end
- if not(time) then time = 5000 end
- textd["text"] = text
- textd["status"] = true
- textd["timer"] = setTimer(function()
- textd["status"] = false
- textd["text"] = ""
- end, time, 1)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement