Tutorial for the release of the 2 new hooks on friday:
OnEntityEnter(Assembly-CSharp/TriggerBase triggerbase, Assembly-CSharp/BaseEntity ent)
OnEntityLeave(Assembly-CSharp/TriggerBase triggerbase, Assembly-CSharp/BaseEntity ent)
Called when you enter or leave a Zone:
- Radiation (global.TriggerRadiation._type)
- Temperature (global.TriggerTemperature._type)
- BuildingPrivilege (global.BuildPrivilegeTrigger._type)
- Hurt (like getting hurt by a fire) (global.TriggerHurt._type)
- Water (the sea) (global.WaterLevel._type)
Entity: can be a Player or an Animal
exemple usage:
This will show you all the owners of a tool cupboard when you get in range of it.
This will show some random message when you enter or leave a radiation zone:Code:function PLUGIN:OnEntityEnter(triggerbase,entity) if(triggerbase:GetComponent(global.BuildPrivilegeTrigger._type)) then if(entity:GetComponentInParent(global.BasePlayer._type)) then buildingprivilegetrigger = triggerbase:GetComponent(global.BuildPrivilegeTrigger._type) baseplayer = entity:GetComponentInParent(global.BasePlayer._type) toolCupboard = buildingprivilegetrigger.privlidgeEntity authPlayers = rust.UserIDsFromBuildingPrivilege( toolCupboard ) if(authPlayers.Length == 0) then rust.SendChatMessage(baseplayer,"You've entered an area owned by no one") return end rust.SendChatMessage(baseplayer,"SteamID of players owning this Area:") for i=0, authPlayers.Length - 1 do rust.SendChatMessage(player,authPlayers[i]) end end end end
Code:function PLUGIN:OnEntityEnter(triggerbase,entity) if(triggerbase:GetComponent(global.TriggerRadiation._type)) then if(entity:GetComponentInParent(global.BasePlayer._type)) then rust.SendChatMessage(entity,"WARNING: Get out of here or you will get radiated") end end end function PLUGIN:OnEntityLeave(triggerbase,entity) if(triggerbase:GetComponent(global.TriggerRadiation._type)) then if(entity:GetComponentInParent(global.BasePlayer._type)) then rust.SendChatMessage(entity,"You are now in a safe zone") end end end
OnEntityEnter OnEntityLeave
Discussion in 'Rust Development' started by Reneb, Dec 9, 2014.