Jump to content

Help with hospital respawn


darhal

Recommended Posts

Hi all I have this Hospital respawn script and My prmoblem was when I respawn I I need to get the guns that i have how to added it plz Need ur help

server side

local hospitalTable = {} 
local hospitals = { 
    -- mx, my, mz, tarx, tary, tarz, x, y, z, rot, name 
    [1] = {1218, -1322, 15, 1217, -1322, 15, 1173, -1323, 15, 270, "All Saints Hospital"}, -- All Saints 
    [2] = {2033, -1439, 19, 2033, -1438, 18, 2038, -1411, 17, 130, "Jefferson Hospital."}, --Jefferson 
    [3] = {1254, 352, 21, 1254, 351, 21, 1242, 327, 19, 340, "Red County Hospital."}, -- Red County 
    [4] = {1590, 1862, 12, 1590, 1861, 12, 1609, 1816, 12, 360, "Las Venturas Hospital."}, -- Las Venturas 
    [5] = {-2660, 580, 16, -2660, 581, 16, -2655, 635, 14, 180, "San Fierro Hospital."}, -- San Fierro 
    [6] = {-2181, -2289, 32, -2181, -2290, 32, -2200, -2311, 30, 320, "Angel Pine Hospital."} -- Angel Pine 
} 
  
function viewTheHospital() 
    local table = findHospital(source) 
    local theMessage = "You have died and been taken to "..table[11] 
    triggerClientEvent(source, "hospital.addHospitalText", source, theMessage) 
    setCameraMatrix(source, table[1], table[2], table[3], table[4], table[5], table[6])  
    showPlayerHudComponent(source, "all", false) 
    setTimer(finsihHospitalIntro, 4500, 1, source, getElementModel(source), table[7], table[8], table[9], table[10]) 
end 
addEventHandler("onPlayerWasted", root, viewTheHospital) 
  
function finsihHospitalIntro(player, model, x, y, z, rotation) 
    if (isElement(player)) then 
        fadeCamera(player, false, 0) 
        setTimer(fadeCamera, 1000, 1, player, true) 
        setCameraTarget(player, player) 
        showPlayerHudComponent(player, "all", true) 
        spawnPlayer(player, x, y, z, rotation, model, 0, 0) 
        hospitalTable[player] = nil 
    end 
end 
  
function findHospital(plr) 
    if (isElement(plr)) then 
        local theHospital = nil 
        local miniumDistance = 2000 
        for index, pos in pairs(hospitals) do 
            local px, py, pz = getElementPosition(plr) 
            local x, y = pos[7], pos[8] 
            local distance = getDistanceBetweenPoints2D(px, py, x, y) 
            if (distance < miniumDistance) then 
                theHospital = pos 
                miniumDistance = distance 
            end 
        end 
        hospitalTable[plr] = theHospital 
        return hospitalTable[plr] 
    end 
end 

Client

local screenWidth, screenHeight = guiGetScreenSize() 
rectangleAlpha = 170 
textAlpha = 255 
  
function addHospitalText(msg) 
    message = msg 
    fadeTimer = setTimer(fadeTheText, 500, 0) 
    addEventHandler("onClientRender", root, drawHospitalText) 
end 
addEvent("hospital.addHospitalText", true) 
addEventHandler("hospital.addHospitalText", root, addHospitalText) 
  
function fadeTheText() 
    textAlpha = textAlpha - 8.5 
    rectangleAlpha = rectangleAlpha - 8.5 
    if (rectangleAlpha <= 0) then 
        killTimer(fadeTimer) 
        removeEventHandler("onClientRender", root, drawHospitalText) 
    end 
end 
  
function drawHospitalText() 
    dxDrawRectangle((screenWidth / 1920) * 426.0, (screenHeight / 1080) * 810.0, (screenWidth / 1920) * 1086.0, (screenHeight / 1080) * 45.0, tocolor(0, 0, 0, rectangleAlpha), false) 
    dxDrawText(message, (screenWidth / 1920) * 380.0, (screenHeight / 1080) * 819.0, (screenWidth / 1920) * 1554.0, (screenHeight / 1080) * 869.0, tocolor(0, 0, 0, textAlpha), (screenHeight / 1920) * 1.5, "bankgothic", "center", "top", false, false, false) 
    dxDrawText(message, (screenWidth / 1920) * 380.0, (screenHeight / 1080) * 819.0, (screenWidth / 1920) * 1554.0, (screenHeight / 1080) * 865.0, tocolor(255, 255, 255, textAlpha), (screenHeight / 1920) * 1.5, "bankgothic", "center", "top", false, false, false) 
end 

Link to comment

I made this but it doesn't work

local hospitalTable = {} 
local hospitals = { 
    -- mx, my, mz, tarx, tary, tarz, x, y, z, rot, name 
    [1] = {1218, -1322, 15, 1217, -1322, 15, 1173, -1323, 15, 270, "All Saints Hospital"}, -- All Saints 
    [2] = {2033, -1439, 19, 2033, -1438, 18, 2038, -1411, 17, 130, "Jefferson Hospital."}, --Jefferson 
    [3] = {1254, 352, 21, 1254, 351, 21, 1242, 327, 19, 340, "Red County Hospital."}, -- Red County 
    [4] = {1590, 1862, 12, 1590, 1861, 12, 1609, 1816, 12, 360, "Las Venturas Hospital."}, -- Las Venturas 
    [5] = {-2660, 580, 16, -2660, 581, 16, -2655, 635, 14, 180, "San Fierro Hospital."}, -- San Fierro 
    [6] = {-2181, -2289, 32, -2181, -2290, 32, -2200, -2311, 30, 320, "Angel Pine Hospital."} -- Angel Pine 
} 
  
local playerWeapons = { } 
  
addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        if ( not playerWeapons [ source ] ) then 
            playerWeapons [ source ] = { } 
        end 
        for slot = 0, 12 do 
            local weapon = getPedWeapon ( source, slot ) 
            if ( weapon > 0 ) then 
                local ammo = getPedTotalAmmo ( source, slot ) 
                if ( ammo > 0 ) then 
                    playerWeapons [ source ] [ weapon ] = ammo 
                end 
            end 
        end 
    end 
) 
  
function viewTheHospital() 
    local table = findHospital(source) 
    local theMessage = "You have died and been taken to "..table[11] 
    triggerClientEvent(source, "UIPhospital.addHospitalText", source, theMessage) 
    setCameraMatrix(source, table[1], table[2], table[3], table[4], table[5], table[6]) 
    showPlayerHudComponent(source, "all", false) 
    setTimer(finsihHospitalIntro, 4500, 1, source, getElementModel(source), table[7], table[8], table[9], table[10]) 
end 
addEventHandler("onPlayerWasted", root, viewTheHospital) 
  
  
  
  
function finsihHospitalIntro(player, model, x, y, z, rotation) 
    if (isElement(player)) then 
        fadeCamera(player, false, 0) 
        setTimer(fadeCamera, 1000, 1, player, true) 
        setCameraTarget(player, player) 
        showPlayerHudComponent(player, "all", true) 
        spawnPlayer(player, x, y, z, rotation, model, 0, 0) 
        hospitalTable[player] = nil 
    end 
end 
  
addEventHandler ( "onSpawnPlayer", root, 
    function ( ) 
        if ( playerWeapons [ source ] ) then 
            for weapon, ammo in pairs ( playerWeapons [ source ] ) do 
                giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) 
            end 
        end 
  
        playerWeapons [ source ] = nil 
    end 
) 
  
function findHospital(plr) 
    if (isElement(plr)) then 
        local theHospital = nil 
        local miniumDistance = 2000 
        for index, pos in pairs(hospitals) do 
            local px, py, pz = getElementPosition(plr) 
            local x, y = pos[7], pos[8] 
            local distance = getDistanceBetweenPoints2D(px, py, x, y) 
            if (distance < miniumDistance) then 
                theHospital = pos 
                miniumDistance = distance 
            end 
        end 
        hospitalTable[plr] = theHospital 
        return hospitalTable[plr] 
    end 
end 
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...