Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- ENT.Type = "anim"
- ENT.Base = "base_gmodentity"
- ENT.PrintName = "Armoire Médicale"
- ENT.Author = "Caldryk"
- ENT.Spawnable = true
- ENT.AdminOnly = false
- ENT.Category = "Custom Entities"
- -- Liste des entités disponibles dans l'armoire
- ENT.AllowedItems = {
- ["kira_scanner_full"] = "Scanner avancé",
- ["kira_bandage"] = "Bandage",
- ["kira_bloodbag"] = "Poche de sang O-",
- ["kira_burn_ointment"] = "Baume pour brûlure",
- ["kira_splint"] = "Attelle",
- ["kira_surgery_kit"] = "Kit de suture",
- ["kira_syringe"] = "Morphine"
- }
- ENT.CooldownTime = 5
- function ENT:Initialize()
- self:SetModel("models/props_c17/FurnitureCupboard001a.mdl")
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- local phys = self:GetPhysicsObject()
- if IsValid(phys) then phys:Wake() end
- self.LastUse = {}
- end
- function ENT:Use(_, ply)
- if not IsValid(ply) or not ply:IsPlayer() then return end
- if ply:Team() ~= TEAM_MED then
- ply:ChatPrint("Seuls les médecins peuvent utiliser cette armoire.")
- return
- end
- net.Start("OpenMedicalCabinetMenu")
- net.WriteEntity(self)
- net.Send(ply)
- end
- -- Réseau
- util.AddNetworkString("OpenMedicalCabinetMenu")
- util.AddNetworkString("RequestMedicalItem")
- net.Receive("RequestMedicalItem", function(_, ply)
- local itemID = net.ReadString()
- local cabinet = net.ReadEntity()
- local itemToEntity = {
- ["kira_bandage"] = "rapd_inventory_item_bandage",
- ["kira_syringe"] = "rapd_inventory_item_syringe",
- ["kira_bloodbag"] = "rapd_inventory_item_bloodbag",
- ["kira_burn_ointment"] = "rapd_inventory_item_burn_ointment",
- ["kira_surgery_kit"] = "rapd_inventory_item_surgery_kit",
- ["kira_scanner_full"] = "rapd_inventory_item_scanner_full",
- ["kira_splint"] = "rapd_inventory_item_splint",
- }
- if not IsValid(ply) or not IsValid(cabinet) then return end
- if ply:Team() ~= TEAM_MED then return end
- if not cabinet.AllowedItems[itemID] then return end
- if cabinet.LastUse[ply] and CurTime() < cabinet.LastUse[ply] then
- ply:ChatPrint("Veuillez patienter avant de prendre un autre objet.")
- return
- end
- local sourceItem = RaPD_Items[itemID]
- if not sourceItem then
- ply:ChatPrint("Erreur : L’objet médical n’existe pas.")
- print("[ARMOIRE] Erreur : " .. itemID .. " introuvable dans RaPD_Items.")
- return
- end
- local clone = table.Copy(sourceItem)
- clone.owner = ply
- -- Patch temporaire si les dimensions ne sont pas définies
- if not clone.width then clone.width = 1 end
- if not clone.height then clone.height = 1 end
- print("[ARMOIRE DEBUG] Tentative d’ajout de l’item : " .. itemID)
- PrintTable(clone)
- if ply:RaPD_AddToInventory(clone) then
- ply:EmitSound("items/ammo_pickup.wav")
- ply:ChatPrint("✅ '" .. (clone.name or "Objet") .. "' a été ajouté à votre inventaire médical.")
- cabinet.LastUse[ply] = CurTime() + cabinet.CooldownTime
- else
- ply:ChatPrint("❌ Échec : inventaire plein ou objet mal formé.")
- print("[ARMOIRE DEBUG] Échec d’ajout de l’objet : " .. itemID)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement