Skip to content

OnPlayerPickHerb

A player picked herbs or mushrooms - return false to refuse, or a number to give that many of the item.

Called when a player’s game picked herbs from the ground, after the server’s own checks (the player is alive and within reach, the kind is not switched off there, nobody picked that spot already, and not quicker than the game’s gathering can), and when a player picks a herb of the mode’s (CreateHerb).

Return false and the pick is refused: the plants grow back at once in the picker’s world and the item the game gave them is taken back. Return a number and the player ends up with that many of the item instead of the game’s amount (0 gives nothing - the plants are still picked). Anything else accepts the pick as the game made it.

herb is a table: kind (the item name, "herb_chamomile"), class (its class GUID), x, y, z (the middle of the circle, metres), radius (metres; 0 for a herb of the mode’s), count (how many plants the game took), amount (what the game gives for them) and key (the picked spot’s key, for ResetHerb).

function OnPlayerPickHerb(pid, herb)
-- ...
end
Parameter Type
pid number the player
herb table {kind, class, x, y, z, radius, count, amount, key}

false refuses the pick; a number gives that many of the item; anything else accepts it

-- the herbalists' guild (team 3) picks twice as much; nobody picks in the abbey's garden
function OnPlayerPickHerb(pid, herb)
if math.abs(herb.x - 512) < 30 and math.abs(herb.y - 1840) < 30 then
SendClientMessage(pid, COLOR_RED, "The abbey's garden is not yours to pick.")
return false
end
if GetPlayerTeam(pid) == 3 then return herb.amount * 2 end
end

SetHerbsEnabled · GetHerbsNear · ResetHerb · the Herbs and mushrooms group of the index