So im having little problem with hooks. I just can't figure out how to place these hooks correctly.
private void OnEnterZone(string ItemCollectingZone, BasePlayer player)
{
if (player.inventory.GetAmount(-542577259) >= maxamount)
{
player.ChatMessage("You Have Maxium Amount Of This Item");
}
else
{
Timer t = null;
t = timer.Repeat(1f, 120, () =>
{
if (player.inventory.GetAmount(-542577259) >= maxamount)
{
t.Destroy();
player.ChatMessage("You Have Maxium Amount Of This Item");
}
ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), "givekit ", player.UserIDString, " item");
if (player.inventory.GetAmount(-542577259) == maxamount) {
t.Destroy();
player.ChatMessage("You Have Maxium Amount Of This Item");
}
});
}
}Right now when you enter the zone it starts the timer and keeps giving you kit until it have reached certain amount and it will destroy the timer but i also want to add OnExitZone hook so when you exit the zone it will also destroy the timer. Right now it just keeps going till it have reached maxamount even when you leave the zone.
//Example
void OnExitZone(string ZoneID, BasePlayer player)
{
t.Destroy();
player.ChatMessage("You Have Left The Zone");
}Thanks for helping me out :)