[Release] Hospital: pay for healing 2.2

Hi, i’ve made a script a few weeks ago and today i want to share it.

With this script, players can pay to get heals at the hospital, the player must stay on the marker if he want to be heal.

That’s a simple script, but i think will surely help a few people.

  • Needs
  • ESSENTIAL MODE
  • How to install
  • Dowload on Github

  • Place hospital in your resources/[folder]

  • Add - hospital to your AutoStartResources in citmp-server.yml

  • Restart your server

  • For devs
-- Add hospital location ( or change )

local blips = {
  {name="Hospital", id=80, x= 338.85, y= -1394.56, z= 31.51, color= 1},
  {name="Hospital", id=80, x= -449.67, y= -340.83, z= 33.50, color= 1},
}
-- Modify price in hospital_sv.lua

RegisterServerEvent('hospital:price')
AddEventHandler('hospital:price', function()
  	local price = 500
 	TriggerEvent('es:getPlayerFromId', source, function(user)
   	user:removeMoney((price))
  	end)
end)
-- Change time to be heal at line 65

if treatment == true then
   Citizen.Wait(15000)
   timer = true
end
-- Change language at line 109 ( "FR" or "EN" )

AddEventHandler("playerSpawned", function()
    local lang = "EN"
    ConfigLang(lang)
end)
  • Changelog

1.0

  • First release
  • Player can heal themselves at one hospital

2.0

  • Fix bugs
  • Devs can add more than one hospital

2.1

  • Add french language

2.2

  • Add a doctor ped instead of a marker
  • To do
  • ?
  • Credits
  • configLang function from Plysken_Rayder
  • Other

Sorry for my english, i hope you understand me.

Have a good day.

8 Likes

why

require "resources/essentialmode/lib/MySQL"
MySQL:open("127.0.0.1", "gta5_gamemode_essential", "root", "")

there are no sql request only a “user:removemoney” lol

I did test and I forget to delete this line

2.0

  • Fix bugs
  • Devs can add more than one hospital

2.1

  • Add french language

why

we can get user from identifier with essential 3.0 too and remove money, i dont understand

2.2

  • Add a doctor ped instead of a marker
1 Like

So this still seesm to work however the money portion isnt being subtracted from bank account… Anyone be able to help with that? or point me to a script that does this and subtracts money

how do i add ped to the locales i added the blue aura?

i have to create more of it:


      local hospitalped =  CreatePed(4, 0xd47303ac, 338.85, -1394.56, 31.51, 49.404, false, true)
      SetEntityHeading(hospitalped, 49.404)
      FreezeEntityPosition(hospitalped, true)
      SetEntityInvincible(hospitalped, true)
      SetBlockingOfNonTemporaryEvents(hospitalped, true)

vRP edit
__resource.lua

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

dependency "vrp"

client_scripts {
  'hospital_cl.lua'
  
}

server_scripts {
  '@vrp/lib/utils.lua',
  'hospital_sv.lua'

}

svr

local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")

vRP = Proxy.getInterface("vRP")
vRPclient = Tunnel.getInterface("vRP", "vRP_heal")

RegisterServerEvent("hospital:price")
AddEventHandler("hospital:price", function()
    local user_id = vRP.getUserId({source})
    local player = vRP.getUserSource({user_id})
	if vRP.tryFullPayment({user_id, 1000}) then

    else
        vRPclient.notify(player, {"~r~BradXY Care Approved -$0."})
    end
end)

cl

---------- VARIABLES ----------


local treatment = false


local timer = false


local blips = {
  {name="Hospital", id=80, x= 338.85, y= -1394.56, z= 31.51, color= 1},
  {name="Hospital", id=80, x= -449.67, y= -340.83, z= 33.50, color= 1},
  
    {name="Hospital", id=80, x= 298.40, y= -584.15, z= 42.26, color= 1},
  {name="Hospital", id=80, x= 1827.97, y= 3692.58, z= 33.22, color= 1},
  
    {name="Hospital", id=80, x= -239.89, y= 6323.59, z= 31.42, color= 1},

}


---------- FONCTIONS ----------


function Notify(text)
  SetNotificationTextEntry('STRING')
  AddTextComponentString(text)
  DrawNotification(false, false)
end


function ShowInfo(text, state)
  SetTextComponentFormat("STRING")
  AddTextComponentString(text)DisplayHelpTextFromStringLabel(0, state, 0, -1)
end


function ConfigLang(lang)
  local lang = lang
  if lang == "FR" then
    lang_string = {
      text1 = "Appuyer sur ~INPUT_VEH_HORN~ pour être soigné ~r~(~h~~g~500$~r~)",
      text2 = "Le ~h~~g~docteur ~s~va te ~h~~r~soigner~s~, ~h~~b~soit patient~s~.",
      text3 = "Tu n'as pas besoin d'être ~h~~r~soigner~s~.",
      text4 = "Tu as été ~h~~r~soigné~s~.",
      text5 = "Tu as ~h~~r~bougé~s~, le ~h~~g~docteur~s~ n'as pas pu te ~h~~r~soigner~s~ !",
  }

  elseif lang == "EN" then
    lang_string = {
      text1 = "Press ~INPUT_VEH_FLY_VERTICAL_FLIGHT_MODE~ to be healed ~r~(~h~~g~$1,000~r~)",
      text2 = "The ~h~~g~doctor ~s~is ~h~~r~healing~s~ you, ~h~~b~please wait~s~.",
      text3 = "You don't need ~h~~r~healing~s~.",
      text4 = "~h~~r~All~s~ ~h~~g~Healed",
      text5 = "~h~You have ~h~~r~moved away~s~, the ~h~~g~doctor~s~ could not ~h~~r~heal~s~ you !",
  }
  end
end


---------- CITIZEN ----------

Citizen.CreateThread(function()
  for _, item in pairs(blips) do
    item.blip = AddBlipForCoord(item.x, item.y, item.z)
    SetBlipSprite(item.blip, item.id)
    SetBlipColour(item.blip, item.color)
    SetBlipAsShortRange(item.blip, true)
    BeginTextCommandSetBlipName("STRING")
    AddTextComponentString(item.name)
    EndTextCommandSetBlipName(item.blip)
  end
end)


Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    for _, item in pairs(blips) do
	  if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), item.x, item.y, item.z, true) <= 20 then
        DrawMarker(0, item.x, item.y, item.z, 0, 0, 0, 0, 0, 0, 2.001, 2.0001, 0.5001, 0, 155, 255, 200, 0, 0, 0, 0)
        if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), item.x,item.y,item.z, true) <= 2 then
          ShowInfo(lang_string.text1, 0)
          if (IsControlJustPressed(1,119)) and (GetEntityHealth(GetPlayerPed(-1)) < 200) and (GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), item.x, item.y, item.z, true) <= 2) then
            Notify(lang_string.text2)
            treatment = true
          end
        end
      end
      if (IsControlJustPressed(1,119)) and (GetEntityHealth(GetPlayerPed(-1)) == 200) and (GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), item.x, item.y, item.z, true) <= 2) then
        Notify(lang_string.text3)
      end
      if treatment == true then
	    Citizen.Wait(5000)
        timer = true
	  end
      if treatment == true and timer == true and (GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), item.x, item.y, item.z, true) <= 2) then
        TriggerServerEvent('hospital:price')
        SetEntityHealth(GetPlayerPed(-1), 200)
        Notify(lang_string.text4)
        treatment = false
        timer = false
      end
      if treatment == true and timer == true and (GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), item.x, item.y, item.z, true) > 2) then
        Notify(lang_string.text5)
        treatment = false
        timer = false            
      end
    end 
  end       
end)

Citizen.CreateThread(function()
    
    RequestModel(GetHashKey("s_m_m_doctor_01"))
    while not HasModelLoaded(GetHashKey("s_m_m_doctor_01")) do
      Wait(1)
    end

      local hospitalped =  CreatePed(4, 0xd47303ac, 338.85, -1394.56, 31.51, 49.404, false, true)
      SetEntityHeading(hospitalped, 49.404)
      FreezeEntityPosition(hospitalped, true)
      SetEntityInvincible(hospitalped, true)
      SetBlockingOfNonTemporaryEvents(hospitalped, true)
end)


AddEventHandler("playerSpawned", function()
    local lang = "EN"
    ConfigLang(lang)
end)

2 Likes

Any update why not taking money?

Hello i come here because you have an error when you pay for the heal, when your are healed and the doctor take the money nothing happened.
And u have this in the console : http://prntscr.com/jdoo4n

Yeah thats what i get the same

can you help or u still trying to figure out…lol

I will try, i’m testing a update and if it work i will give it in the post !

1 Like

Well i tried but, it don’t work, i don’t know how to make it work again, maybe a pro can did it but i can’t :confused:

1 Like

so ridiculousness, hate it when theirs only 1 wrong click puts wrong symbol in, stops it from doing what its meant… i could scream…

change :
user:removeMoney((price))

with .
user.removeMoney((price))

and will work… pulls hair out…lol

1 Like

I cannot get the doctor ped to show up. I just get the aura. How do I fix this?

Did you set the peds to the came coords

Thanks. I see that now. Also, to add additional locations for the ped, do I copy the first line and change the coordinates?

Just add another thread

Citizen.CreateThread(function()


** RequestModel(GetHashKey(“s_m_m_doctor_01”))**
** while not HasModelLoaded(GetHashKey(“s_m_m_doctor_01”)) do**
** Wait(1)**
** end**

** local hospitalped = CreatePed(4, 0xd47303ac, 307.1, -596.32, 42.29, 28.94, false, true)**
** SetEntityHeading(hospitalped, 28.94)**
** FreezeEntityPosition(hospitalped, true)**
** SetEntityInvincible(hospitalped, true)**
** SetBlockingOfNonTemporaryEvents(hospitalped, true)**
end)

1 Like