Jump to content

set another name


Recommended Posts

How can I make certain ids have defined another name?

function hud ( ) 
    local x, y = guiGetScreenSize() 
    ammo = getPedTotalAmmo ( getLocalPlayer() ) 
    clip = getPedAmmoInClip ( getLocalPlayer() ) 
    weaponID = getPedWeapon(getLocalPlayer()) 
    weapName = getWeaponNameFromID(weaponID) 
    dxDrawText("#11A737"..weapName.." | "..clip.."/"..ammo,x-(x/2.9), y/33, x, y,tocolor(0,255,255,255),1.5,"clear","left","top",false,false,false,true) 
    if isPedInVehicle (localPlayer) == false then return end 
    Vname = getVehicleName(getPedOccupiedVehicle(localPlayer)) 
    health = getElementHealth (getPedOccupiedVehicle(localPlayer)) 
    sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
    kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) 
    dxDrawText("#FFFFFFVeiculo: "..Vname,20.0,348.0,296.0,364.0,tocolor(0,255,255,255),0.5,"bankgothic","left","top",false,false,false,true) 
    dxDrawText("#FFFFFFSaude do Veiculo: "..tostring(math.floor(health*0.1)).." %",20.0,368.0,296.0,384.0,tocolor(0,255,255,255),0.5,"bankgothic","left","top",false,false,false,true) 
    dxDrawText("#FFFFFFVelocidade: "..tostring(kmhs).." Km/h",20.0,388.0,296.0,404.0,tocolor(0,255,255,255),0.5,"bankgothic","left","top",false,false,false,true) 
end 
addEventHandler("onClientRender",getRootElement(),hud) 
addEventHandler("onClientPlayerSpawn",getRootElement(),hud) 

so for example:

  
weapName = 
if weaponID = 33 --the name will be: Lee Enfield 
but do not know how to do it 
  

Link to comment

Ok, try this:

  
local weaponNames = { 
    ["brassknuckle"] = "brassknuckle", 
    ["golfclub"] = "golfclub", 
    ["nightstick"] = "nightstick", 
    ["knife"] = "knife", 
    ["bat"] = "bat", 
    ["shovel"] = "shovel", 
    ["poolstick"] = "poolstick", 
    ["katana"] = "katana", 
    ["chainsaw"] = "chainsaw", 
    ["dildo"] = "dildo", 
    ["vibrator"] = "vibrator", 
    ["flower"] = "flower", 
    ["cane"] = "cane", 
    ["grenade"] = "grenade", 
    ["teargas"] = "teargas", 
    ["molotov"] = "molotov", 
    ["colt 45"] = "colt 45", 
    ["silenced"] = "silenced", 
    ["deagle"] = "deagle", 
    ["shotgun"] = "shotgun", 
    ["sawed-off"] = "sawed-off", 
    ["combat shotgun"] = "combat shotgun", 
    ["uzi"] = "uzi", 
    ["mp5"] = "mp5", 
    ["ak-47"] = "ak-47", 
    ["m4"] = "m4", 
    ["tec-9"] = "tec-9", 
    ["rifle"] = "Lee Enfield", -- Custom weapon name 
    ["sniper"] = "sniper", 
    ["rocket launcher"] = "rocket launcher", 
    ["rocket launcher hs"] = "rocket launcher hs", 
    ["flamethrower"] = "flamethrower", 
    ["minigun"] = "minigun", 
    ["satchel"] = "satchel", 
    ["bomb"] = "bomb", 
    ["spraycan"] = "spraycan", 
    ["fire extinguisher"] = "fire extinguisher", 
    ["camera"] = "camera", 
    ["nightvision"] = "nightvision", 
    ["infrared"] = "infrared", 
} 
  
local _getWeaponNameFromID = getWeaponNameFromID 
function getWeaponNameFromID(weaponID) 
    if weaponID then 
        return weaponNames[_getWeaponNameFromID(weaponID)] 
    else 
        return false 
    end 
end 
  
function hud ( ) 
    local x, y = guiGetScreenSize() 
    ammo = getPedTotalAmmo ( getLocalPlayer() ) 
    clip = getPedAmmoInClip ( getLocalPlayer() ) 
    weaponID = getPedWeapon(getLocalPlayer()) 
    weapName = getWeaponNameFromID(weaponID) 
    dxDrawText("#11A737"..weapName.." | "..clip.."/"..ammo,x-(x/2.9), y/33, x, y,tocolor(0,255,255,255),1.5,"clear","left","top",false,false,false,true) 
    if isPedInVehicle (localPlayer) == false then return end 
    Vname = getVehicleName(getPedOccupiedVehicle(localPlayer)) 
    health = getElementHealth (getPedOccupiedVehicle(localPlayer)) 
    sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
    kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) 
    dxDrawText("#FFFFFFVeiculo: "..Vname,20.0,348.0,296.0,364.0,tocolor(0,255,255,255),0.5,"bankgothic","left","top",false,false,false,true) 
    dxDrawText("#FFFFFFSaude do Veiculo: "..tostring(math.floor(health*0.1)).." %",20.0,368.0,296.0,384.0,tocolor(0,255,255,255),0.5,"bankgothic","left","top",false,false,false,true) 
    dxDrawText("#FFFFFFVelocidade: "..tostring(kmhs).." Km/h",20.0,388.0,296.0,404.0,tocolor(0,255,255,255),0.5,"bankgothic","left","top",false,false,false,true) 
end 
addEventHandler("onClientRender",getRootElement(),hud) 
addEventHandler("onClientPlayerSpawn",getRootElement(),hud) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...