OnPlayerInteractPlayer
The player pressed the use key on another player whose prompt they see.
Fires when a player within 3.5 m, facing target, presses the use key while the prompt over
target shows on their screen (everyone’s, or their own from SetPlayerPromptFor) - a hidden prompt counts too, so a
mode can pick the action itself when the key is pressed. What the prompt offered - a talk, a search, a trade, an arrest - is
the mode’s to do here. The game’s own use key on a player goes first: while target
lies knocked out or is carried (the carry), and while the player crouches (the pickpocket), no prompt shows and this
does not fire.
Syntax
Section titled “Syntax”function OnPlayerInteractPlayer(pid, target) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player who pressed the key |
target |
number | the player it was pressed on |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnPlayerInteractPlayer(pid, target) if GetPlayerPromptFor(pid, target) == "Arrest" then arrest(target, pid) else ShowPlayerDialogue(pid, 1, GetPlayerName(target), "Good day to you.", {"Good day."}) endendSee also
Section titled “See also”SetPlayerPrompt · SetPlayerPromptFor · OnPlayerInteractActor · the Players group of the index
