Player::getNearbyPeds: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
No edit summary
 
Line 1: Line 1:
sizeAndPeds - is a pointer to an array. The array is filled with peds found nearby the ped supplied to the first argument.<br>ignore - ped type to ignore<br><br>Return value is the number of peds found and added to the array passed.<br><br>-----------------------------------<br><br>To make this work in most menu bases at least in C++ do it like so,<br><br> Formatted Example: pastebin.com/D8an9wwp<br><br>-----------------------------------<br><br>Example: gtaforums.com/topic/789788-function-args-to-pedget-ped-nearby-peds/?p=1067386687
{{ClientsideJsFunction}}
{{JSContainer|
 
===Required Params===
*'''numPeds:''' {{RageType|number}} — Maximum number of peds to return.
*'''ignoreType:''' {{RageType|number}} — Ped type to ignore.
 
===Return value===
*'''{{RageType|Array<number>|null}}''' — Array of ped handles or null if none found.
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">player.getNearbyPeds(sizeAndPeds, ignore);</syntaxhighlight>
<syntaxhighlight lang="javascript">
=== Required Arguments ===
player.getNearbyPeds(number numPeds, number ignoreType)
*'''sizeAndPeds:''' int
</syntaxhighlight>
*'''ignore:''' int
 
===Return value===
*'''int'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
const peds = mp.players.local.getNearbyPeds(5, 0);
 
if (peds) {
    peds.forEach(handle => {
        mp.gui.chat.push(`Nearby ped handle: ${handle}`);
    });
}
</syntaxhighlight>
</syntaxhighlight>
}}
==See also==
==See also==
{{Player_function_c}}
{{Player_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:Player]]

Latest revision as of 22:18, 26 December 2025

Client-Side
Function

 JavaScript



JavaScript Syntax


Required Params

  • numPeds: number — Maximum number of peds to return.
  • ignoreType: number — Ped type to ignore.

Return value

  • 'Array<number>' — Array of ped handles or null if none found.

Syntax

player.getNearbyPeds(number numPeds, number ignoreType)

Example

const peds = mp.players.local.getNearbyPeds(5, 0);

if (peds) {
    peds.forEach(handle => {
        mp.gui.chat.push(`Nearby ped handle: ${handle}`);
    });
}


See also