GetWeaponName

From SA-MP Wiki

Jump to: navigation, search


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
Navigation
Toolbox