Darwin Posted September 22, 2019 Share Posted September 22, 2019 Hola me gustaria que me ayudaran a arreglar un script que encontre en la comunidad de mta, quiero que al morir, el player aparezca en el hospital mas cercano "cuando muere aparece siempre en el hospital de ls ya he detenido el spawnmanager y el play pero sigue igual" hospital.Lua hosp_loc = { -- x, y, z, rot { 1173, -1323, 15, 270}, -- All Saints { 2038, -1411, 17, 130}, --Jefferson { 1242, 327, 19, 340}, -- Red County { 1609, 1816, 12, 360}, -- Las Venturas { -2655, 635, 14, 180}, -- San Fierro { -2200, -2311, 30, 320}, -- Angel Pine { -320, 1049, 20, 0 }, --Fort Carson - Bone County { -1514.5, 2524, 56, 0 } --Tierra Robada } fade = true --true enables fade, false disables fade wepsave = true--true gives weapons on respawn, false will not give weapons on respawn saveweps = {} FadeTimer = 5 --Time for camera to be black and show the wasted message (in seconds) --Let it be noted, your camera fades out half the time set above to black, text shows instantly. function getDistance(thePlayer) --IIYAMA basically made this, I came up with the idea and tweaked it -- get the player position local px,py,pz = getElementPosition( thePlayer ) --Player location -- prepare 2 variables, but do not give them a value yet. local closestDistance local closestPoint -- loop through the tables for i=1,#hosp_loc do --For all the locations in table local hx, hy, hz = hosp_loc[1], hosp_loc[2], hosp_loc[3] --Hospital locations local distance = getDistanceBetweenPoints3D (hx, hy, hz, px, py, pz) --Get the distance between player and hospitals if not closestDistance or distance < closestDistance then -- If the closestDistance is nil/(false) OR the distance is smaller than the closestDistance. closestDistance = distance -- save the distance in closestDistance, which is located outside of the loop. closestPoint = hosp_loc -- save the point in closestPoint, which is located outside of the loop. end end --x, y, z, rotation from hospital location table local x = (tostring(closestPoint[1])) --x local y = (tostring(closestPoint[2])) --y local z = (tostring(closestPoint[3])) --z local r = (tostring(closestPoint[4])) --rotation skin = getElementData(thePlayer, "respawn-skin" )--get skin --outputChatBox(""..skin, thePlayer) spawnPlayer ( thePlayer, x, y, z, r, skin ) --Spawn the player setElementModel (thePlayer, skin) if (fade == true) then --If fade is enabled fadeCamera(thePlayer,true,1.5) --Since we set camera to black screen below, we reset it here end --Load weapons if (wepsave == true) then local name = getPlayerName(thePlayer) -- Get his name if saveweps[name] and saveweps[name].weapons then -- Check if there is a saveweps if saveweps[name].weapons ~= false then -- Double check local weps = saveweps[name].weapons for i, node in ipairs(weps) do -- Loop the table local wepinfo = split(node, ".") -- Split the string local wepid = wepinfo[1] local wepammo = wepinfo[2] --setTimer(giveWeapon, i*1000, 1, thePlayer, wepid, wepammo ) -- Used for testing giveWeapon ( thePlayer, wepid, wepammo ) -- gives the weapon end end end end end function Respawn() if (fade == true) then --If fade is true fadeCamera(source,false,tonumber(FadeTimer)/2,0,0,0) --Fade camera to black triggerClientEvent(source, "WastedText", getRootElement(), FadeTimer) end if (wepsave == true) then --weapon save local name = getPlayerName(source) -- Get the name if isPedDead(source) then -- Checks if the player is dead. saveweps[name] = { weapons = false } -- Reset the saveweps local weaponsTable = {} -- Create a empty table for i=1, 12 do -- Loop the stuff if(getPedWeapon(source, i) ~= 0 and getPedTotalAmmo(source, i) > 0) then table.insert(weaponsTable, getPedWeapon(source, i) .. "." .. getPedTotalAmmo(source, i)) -- Insert into the empty table end end saveweps[name].weapons = weaponsTable -- Put the empty table in the saveweps. else saveweps[name] = { weapons = false } -- If not then just empty the saveweps end end --Get players skin local skinid = getElementModel(source) setElementData(source, "respawn-skin", skinid) setTimer(getDistance, tonumber(FadeTimer)*1000, 1, source) --Set a timer to spawn player end addEventHandler("onPlayerWasted", getRootElement(), Respawn ) --When player dies function is triggered hospital_c local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 150 / 2 ) function Wasted_Dx( ) local blip = createBlip(1173, -1323, 15, 22) local blip = createBlip(2038, -1411, 17, 22) local blip = createBlip(1242, 327, 19, 22) local blip = createBlip(1609, 1816, 12, 22) local blip = createBlip(-2655, 635, 14, 22) local blip = createBlip(-2200, -2311, 30, 22) local blip = createBlip(-320, 1049, 20, 22) local blip = createBlip(-1514.5, 2524, 56, 22) dxDrawText("Wasted", pX, pY, 670-10, 314-20, tocolor(0, 0, 0, 255), 3, "bankgothic", "center", "top", false, false, false, false, false) dxDrawText("Wasted", pX, pY, 670, 314, tocolor(255, 0, 0, 255), 3, "bankgothic", "center", "top", false, false, false, false, false) end function WastedTimer(FadeTimer) addEventHandler("onClientRender", root, Wasted_Dx) setTimer(StopText, FadeTimer*1000, 1, localPlayer) end addEvent("WastedText", true) addEventHandler("WastedText", getRootElement(), WastedTimer) function StopText() removeEventHandler("onClientRender", root, Wasted_Dx) end meta <meta> <info author="kieranb, IIYAMA" type="script" name="Hospital Respawn" version="1.0.3" description="A magical pony, just kidding, it's a respawn script..." /> <min_mta_version server="1.5.5" client="1.5.5" /> <script src="hospital.Lua" type="server"/> <script src="hospital_c.Lua" type="client"/> </meta> Link to comment
aka Blue Posted September 22, 2019 Share Posted September 22, 2019 (edited) @Darwin You can't ask for scripting help here. It's not the appropiate subforum. No deberías pedir ayuda sobre scripts en este subforo. Tenemos uno en español aquí: https://forum.multitheftauto.com/forum/166-spanish-español/ Edited September 22, 2019 by aka Blue Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now