GetWeaponName

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 19:51, 19 July 2016
ZiGGi (Talk | contribs)
(update example, remove GetWeaponNameEx and old note)
← Previous diff
Current revision
OstGot (Talk | contribs)

Line 8: Line 8:
{{Param|len|The maximum length of the weapon name to store. Should be sizeof(name).}} {{Param|len|The maximum length of the weapon name to store. Should be sizeof(name).}}
-{{ReturnsSuccess||The weapon specified does not exist.}}+{{ReturnsSuccess||The weapon specified does not exist.
 +* The weapon's name is stored in the specified array.}}
{{Example}} {{Example}}

Current revision



Description:

Get the name of a weapon.


Parameters:
(weaponid, const weapon[], len)
weaponidThe ID of the weapon to get the name of.
const weapon[]An array to store the weapon's name in, passed by reference.
lenThe maximum length of the weapon name to store. Should be sizeof(name).


Return Values:

  • 1: The function executed successfully.
  • 0: The function failed to execute. The weapon specified does not exist.
  • The weapon's name is stored in the specified array.


Example Usage:

public OnPlayerDeath(playerid, killerid, reason)
{
    new gunname[32], string[64], playername[MAX_PLAYER_NAME + 1], killername[MAX_PLAYER_NAME + 1];
    GetWeaponName(reason, gunname, sizeof(gunname));
    GetPlayerName(playerid, playername, sizeof(playername));
    GetPlayerName(killerid, killername, sizeof(killername));
    format(string, sizeof(string), "%s has wasted %s using a %s.", killername, playername, gunname);
    SendClientMessageToAll(0xFFFFFFAA, string);
    return 1;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

Personal tools