yes
how do i fix
Its must be the trigger event or command. I will take a look into it and will hopefully fix it as soon as possible.
any fix on this yet
Might being lazy but at the same time im not that expert, is there a way to force them to stay on the bed with the animation ?
Great script! Love it!
is there any way i can force people to be in the hospital bed using this?
wondering this too…
Could anyone make this with jobcheck, instead of password?
I tried this and it was very buggy. I have the open interior for that exact hospital. But it try’s to also teleport me to the prison as well. I do believe this is because it is interfering with the jailer script.
I know the post says no support, but is there anybody that can possibly help me with this?
Hello, I sincerely apologize I have been very busy recently hence why I placed no support but I can give you some help on the reasons this is happening. Well to start with, it is a major fuck up from my side cause changing the code I forgot to replace the most basic thing which is the trigger event, therefore if you have both of them it will teleport you to both of them. Now I’m going to assume you don’t know what I’m talking about so I have fixed it myself, so downloading it again should have the new triggers and just in case I’m going to leave the code here. All you have to do is replace the code below into the marked files or redownload the files
clientHospital.lua
--Coded by Albo1125.
-- /////// I take no credits for this, this was 100% coded by Albo1125./////
--Modified by Kevin.
local cH = false
local eHE = false
RegisterNetEvent("HP")
AddEventHandler("HP", function(hT)
if cH == true then
return
end
local pP = GetPlayerPed(-1)
if DoesEntityExist(pP) then
Citizen.CreateThread(function()
local playerOldLoc = GetEntityCoords(pP, true)
SetEntityCoords(pP, 360.28, -591.07, 43.31)
cH = true
eHE = false
while hT > 0 and not eHE do
pP = GetPlayerPed(-1)
RemoveAllPedWeapons(pP, true)
SetEntityInvincible(pP, true)
if IsPedInAnyVehicle(pP, false) then
ClearPedTasksImmediately(pP)
end
if hT % 30 == 0 then
TriggerEvent('chatMessage', 'SYSTEM', { 0, 0, 0 }, hT .." more seconds until release.")
end
Citizen.Wait(500)
local pL = GetEntityCoords(pP, true)
local D = Vdist(360.28, -591.07, 43.31, pL['x'], pL['y'], pL['z'])
if D > 90 then
SetEntityCoords(pP, 360.28, -591.07, 43.31)
if D > 100 then
hT = hT + 60
if hT > 1500 then
hT = 1500
end
TriggerEvent('chatMessage', 'DOCTOR', { 0, 0, 0 }, "Your hospital stay time was extended for an injury made during an escape attempt.")
end
end
hT = hT - 0.5
end
TriggerServerEvent('chatMessageEntered', "SYSTEM", { 0, 0, 0 }, GetPlayerName(PlayerId()) .." was released from the hospital.")
SetEntityCoords(pP, 298.22, -593.91, 43.26)
cJ = false
SetEntityInvincible(pP, false)
end)
end
end)
RegisterNetEvent("UnHP")
AddEventHandler("UnHP", function()
eHE = true
end)
--Coded by Albo1125
--Modified by Kevin.
serverHospital.lua
--Coded by Albo1125.
--Modified by Kevin
local hospitalPassword = "ems" --change this password to your liking and don't share it with the patients ;-)
local defaultsecs = 180
local maxsecs = 1000
-----------------------------
AddEventHandler('chatMessage', function(source, n, message)
cm = stringsplit(message, " ")
if(cm[1] == "/hospitalme") then
CancelEvent()
local hT = defaultsecs
if cm[2] ~= nil then
hT = tonumber(cm[2])
end
if hT > maxsecs then
hT = maxsecs
end
print("Hospitalizing ".. GetPlayerName(source) .. " for ".. hT .." secs")
TriggerClientEvent("HP", source, hT)
TriggerClientEvent('chatMessage', -1, 'DOCTOR', { 0, 0, 0 }, GetPlayerName(source) ..' hospitalized for '.. hT ..' secs')
elseif cm[1] == "/unhospital" then
CancelEvent()
if cm[2] == hospitalPassword then
local tPID = tonumber(cm[3])
if GetPlayerName(tPID) ~= nil then
print("Unhospital ".. GetPlayerName(tPID).. " - cm entered by ".. GetPlayerName(source))
TriggerClientEvent("UnJP", tPID)
end
else
print("Incorrect hospitalPassword entered by ".. GetPlayerName(source))
end
elseif cm[1] == "/hospital" then
CancelEvent()
if tablelength(cm) > 2 then
if cm[2] == hospitalPassword then
local tPID = tonumber(cm[3])
local hT = defaultsecs
if tablelength(cm) > 3 then
if cm[4] ~= nil then
hT = tonumber(cm[4])
end
end
if hT > maxsecs then
hT = maxsecs
end
if GetPlayerName(tPID) ~= nil then
print("Hospitalizing ".. GetPlayerName(tPID).. " for ".. hT .." secs - cm entered by ".. GetPlayerName(source))
TriggerClientEvent("HP", tPID, hT)
TriggerClientEvent('chatMessage', -1, 'DOCTOR', { 0, 0, 0 }, GetPlayerName(tPID) ..' hospitalized for '.. hT ..' secs')
end
else
print("Incorrect hospitalPassword entered by ".. GetPlayerName(source))
end
end
end
end)
print('RG Hospitalizer by Kevin.')
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
--Coded by Albo1125
--Modified by Kevin.
Ha, yea. I’m not too advanced with all of this FiveM Coding stuff, but I know a few things. Didn’t quite know how to fix it myself because when I tried it just made it worse, lol. But thank you so much for this fix, much appreciated! Keep up the amazing work!
I do have one quick question. Is is possible to change the location to another custom interior that I have in my server that I planned on using? If so, please get back to me… Thanks in advance!
Absolutely, all you need to do is modify the coords into the custom ones. \
Change these
Citizen.Wait(500)
local pL = GetEntityCoords(pP, true)
local D = Vdist(360.28, -591.07, 43.31, pL['x'], pL['y'], pL['z'])
if D > 90 then
SetEntityCoords(pP, 360.28, -591.07, 43.31)
if D > 100 then
hT = hT + 60
if hT > 1500 then
hT = 1500
end
TriggerEvent('chatMessage', 'DOCTOR', { 0, 0, 0 }, "Your hospital stay time was extended for an injury made during an escape attempt.")
end
end
hT = hT - 0.5
end
TriggerServerEvent('chatMessageEntered', "SYSTEM", { 0, 0, 0 }, GetPlayerName(PlayerId()) .." was released from the hospital.")
SetEntityCoords(pP, 298.22, -593.91, 43.26)
cJ = false
SetEntityInvincible(pP, false)
end)
end
end)
Replace the XYZ coords.
Thank you so much!
Sorry for the super late delay on this… Just got to trying to fix it. I replaced the script with the updated scripts you sent me and I get this:
I have the custom hospital map installed. So I’m not too sure what’s going on here…
EDIT: Also, when stopping the script in the command prompt, I still end up at the prison.
Thanks in advance for any help!
It seams like its still interfering with the jail script, do me a favor and delete all the file for the script and download it again and try that. If that doesn’t work then I think I might have forgotten to change a trigger.
Sorry for the late reply. Would you like me to delete both the jailer and hospital script? Just want to make sure before I go ahead and do so.
Just the hospital.
I’m not too good at coding, is there a way to remove the password and add a reason?
hello, great script I have accompanied him with some healing beds and it works very well, it is a great script, my respects.
But I have a problem, the script only works the first time I put /hospitalme, then I do all the process, I leave the hospital healthy, I die again and when I write /hospitalme, I see in console the first line of the script that says XXX seconds and it does not work, I do not see more lines in the console, I do not teleport, I thought about a cooling time but I have not seen anything in the script.
What could be the problem?
THANKS for this great script
Thanks for your great review .
I might have an idea, please go ahead and answer the following questions:
- Do you have the Albo1125 Jailer script?
- Open your serverHospital.lua and tell me the time that is set in default SECS, if you dont know what im talking about, just make sure that it looks like this
serverHospital.lua
--Coded by Albo1125.
--Modified by Kevin
local hospitalPassword = "ems" --change this password to your liking and don't share it with the patients ;-)
local defaultsecs = 180
local maxsecs = 1000
-----------------------------
AddEventHandler('chatMessage', function(source, n, message)
cm = stringsplit(message, " ")
if(cm[1] == "/hospitalme") then
CancelEvent()
local hT = defaultsecs
if cm[2] ~= nil then
hT = tonumber(cm[2])
end
if hT > maxsecs then
hT = maxsecs
end
print("Hospitalizing ".. GetPlayerName(source) .. " for ".. hT .." secs")
TriggerClientEvent("HP", source, hT)
TriggerClientEvent('chatMessage', -1, 'DOCTOR', { 0, 0, 0 }, GetPlayerName(source) ..' hospitalized for '.. hT ..' secs')
elseif cm[1] == "/unhospital" then
CancelEvent()
if cm[2] == hospitalPassword then
local tPID = tonumber(cm[3])
if GetPlayerName(tPID) ~= nil then
print("Unhospital ".. GetPlayerName(tPID).. " - cm entered by ".. GetPlayerName(source))
TriggerClientEvent("UnJP", tPID)
end
else
print("Incorrect hospitalPassword entered by ".. GetPlayerName(source))
end
elseif cm[1] == "/hospital" then
CancelEvent()
if tablelength(cm) > 2 then
if cm[2] == hospitalPassword then
local tPID = tonumber(cm[3])
local hT = defaultsecs
if tablelength(cm) > 3 then
if cm[4] ~= nil then
hT = tonumber(cm[4])
end
end
if hT > maxsecs then
hT = maxsecs
end
if GetPlayerName(tPID) ~= nil then
print("Hospitalizing ".. GetPlayerName(tPID).. " for ".. hT .." secs - cm entered by ".. GetPlayerName(source))
TriggerClientEvent("HP", tPID, hT)
TriggerClientEvent('chatMessage', -1, 'DOCTOR', { 0, 0, 0 }, GetPlayerName(tPID) ..' hospitalized for '.. hT ..' secs')
end
else
print("Incorrect hospitalPassword entered by ".. GetPlayerName(source))
end
end
end
end)
print('RG Hospitalizer by Kevin.')
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
--Coded by Albo1125
--Modified by Kevin.