FetchNativeFromPlayer

From GT-MP
Jump to: navigation, search
FetchNativeFromPlayer
Server-Side Function
Utilities-terminal.png Server-Side Csharp.png C#

This function returns data from a Native call.

Icon-warning.png WARNING: This function is synchronous and could take a long time to return. Do not use this if your resource is not multithreaded.

If you know what you're doing and want to use this function anyway, consider reading meta.xml for more information about multithreaded resources.


Icon-info.png
Timeout value for this function is 10 seconds. If you want a longer/custom timeout value, see fetchNativeFromPlayerWithTimeout.

Syntax

API.fetchNativeFromPlayer<T>(Client player, ulong longHash, params object[] args);
API.fetchNativeFromPlayer<T>(Client player, Hash native, params object[] args);

Required Arguments

  • T: the type to return. This can be any of these: int, uint, string, float, double, bool.
  • player: parameter input should be in Client type.
  • longHash/native: parameter input should be in ulong/Hash type.
  • args: parameter input should be in object type.

NOTE: This function returns the native data. Return value will be default(T) if the operation times out.

Usage example

int ammoCount = API.fetchNativeFromPlayer<int>(sender, Hash.GET_AMMO_IN_PED_WEAPON, sender.handle, WeaponHash.SMG);

References

http://www.dev-c.com/nativedb/