• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Help with Custom Weapon Names
#3
There are multiple ways to do it. Personally, I would use an array holding all the desired weapon names, something like this:



Code:
enum

{

    TEAM_CIVILIAN = 1,

    TEAM_LEO, //Law Enforcment Officer (Police, army, FBI etc..)

    TEAM_GANG, //Grove street, Ballas etc

    TEAM_MISC

};



//Respecting weapon IDs, you should have an entry for every possible weapon for the script to prevent array out of bound errors.

new const weaponName[][][] =

{

    //{WEAPON_ID,           WEAPONNAME_TEAM1, WEAPONNAME_TEAM2, WEAPONNAME_TEAM3, WEAPONNAME_TEAM4},

    {0,                        "Fists", "Fists", "Fists", "Fists"},

    {WEAPON_BRASSKNUCKLE,    "Brass knuckles", "Brass knuckles", "Brass knuckles", "Brass knuckles"},

    {WEAPON_GOLFCLUB,       "Golf club", "Golf club", "Golf club", "Golf club"},

    {WEAPON_NITESTICK,      "Nightstick", "Nightstick", "Nightstick", "Nightstick"},

    {WEAPON_KNIFE,          "Kitchen knife", "Combat knife", "Stiletto", "Knife"},

    {WEAPON_BAT,            "Baseball bat", "Bat", "Bat", "Bat"},

    {WEAPON_SHOVEL,         "Shovel", "Shovel", "Digging tool", "Bat"},

    {WEAPON_POOLSTICK,      "Pool cue", "Pool cue", "Pool cue", "Pool cue"},

    {WEAPON_KATANA,         "Ninja weapon", "Katana", "Sword", "Katana"},

    {WEAPON_CHAINSAW,       "Chainsaw", "Chainsaw", "Chainsaw", "Chainsaw"}

    //etc

};



To print the name of a weapon:

Code:
weaponName[weaponid][teamid]

For example, to print "Combat knife":

Code:
weaponName[WEAPON_KNIFE][TEAM_LEO]



I find that more convenient than using switches. But go with whatever you like best, especially since some weapons may not even need custom/different names. When using this script like this you need to define names for all possible weapons and all possible teams, otherwise you will have either compile errors or runtime errors because arrays might go out of bounds.

If you would remove WEAPON_BAT in this example, using WEAPON_CHAINSAW would cause out of bounds error and WEAPON_SHOVEL to WEAPON_KATANA would print the wrong name.
  Reply


Messages In This Thread
Help with Custom Weapon Names - by RoBy41 - 2020-10-23, 02:08 PM
RE: Help with Custom Weapon Names - by Awide - 2020-10-24, 08:22 AM
RE: Help with Custom Weapon Names - by Kwarde - 2020-10-24, 09:28 AM
RE: Help with Custom Weapon Names - by RoBy41 - 2020-10-24, 10:28 AM
RE: Help with Custom Weapon Names - by Expert* - 2020-10-24, 10:55 AM
RE: Help with Custom Weapon Names - by RoBy41 - 2020-10-24, 11:03 AM

Forum Jump: