Jump to content

[Solved] Dx drawing stats


Recommended Posts

Hey guys, i have attemped a stats system but, it won't work, all i see is the Vehical Rectangle, i have rarely worked with dx drawing's.

Could someone please explain to me, and help me, i have not done many client sided scripts, and few know there my weeknesses.

local root = getRootElement(source) 
addEventHandler("onClientRender",root, 
    function() 
    local name = getPlayerName(getLocalPlayer()) 
    local ping = getPlayerPing(getLocalPlayer()) 
    local serial = getPlayerSerial() 
    local money = getPlayerMoney(getLocalPlayer()) 
    local weapon = getPedWeapon (getLocalPlayer()) 
    local ammo = getPedTotalAmmo (getLocalPlayer()) 
    local carname = getPedOccupiedVehicle (getLocalPlayer()) 
    local carhealth = getElementHealth (carname) 
    local engine = getVehicleEngineState (carname) 
    local lights = getVehicleLightState ( carname, 0 ) 
    local armor = getPedArmor ( getLocalPlayer() ) 
    local team = getPlayerTeam ( getLocalPlayer() )   
    local weaponslot = getPedWeaponSlot ( getLocalPlayer() ) 
    local health = getElementHealth ( getLocalPlayer() ) 
     
        dxDrawRectangle(778.0,521.0,246.0,94.0,tocolor(200,0,0,80),false) 
        dxDrawText("Lights: "..lights,794.0,592.0,930.0,597.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Engine: "..engine,794.0,578.0,930.0,592.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        if isVehicleLocked ( playervehicle ) then 
        dxDrawText("State: Locked",794.0,563.0,930.0,578.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
  
        dxDrawText("State: Unlocked",794.0,563.0,930.0,578.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        end 
        dxDrawText("Health: "..carhealth,794.0,547.0,930.0,563.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawRectangle(778.0,422.0,246.0,65.0,tocolor(200,0,0,80),false) 
        dxDrawText("Vehicle Name: "..carname,794.0,531.0,930.0,547.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawRectangle(778.0,287.0,246.0,106.0,tocolor(200,0,0,80),false) 
        dxDrawRectangle(778.0,257.0,246.0,30.0,tocolor(50,0,0,200),false) 
        dxDrawRectangle(778.0,393.0,246.0,34.0,tocolor(50,0,0,200),false) 
        dxDrawRectangle(778.0,487.0,246.0,34.0,tocolor(50,0,0,200),false) 
        dxDrawText("Vehicle Stats: ",836.0,487.0,982.0,517.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
        dxDrawText("Ammo: ",794.0,461.0,930.0,477.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Slot ID: "..weaponslot,794.0,447.0,930.0,461.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Weapon Name: "..weapon,794.0,432.0,930.0,447.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Weapon Stats",836.0,393.0,982.0,422.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
        dxDrawText("Ping: "..ping,794.0,368.0,884.0,383.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Team: "..team,794.0,352.0,884.0,368.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Armor: "..armor,794.0,336.0,884.0,352.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Health: "..health,794.0,321.0,884.0,336.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Money: "..money,794.0,307.0,884.0,321.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Name: "..name,794.0,292.0,884.0,307.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("My Stats",854.0,258.0,947.0,287.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
    end 
) 

Edited by Guest
Link to comment

Well, your script had many errors, you we're trying to use the vehicle element as the vehicle name, trying to get vehicle data when he was not in one, that was causing the script not to work.

addEventHandler("onClientRender",root, 
    function() 
    local name = getPlayerName(getLocalPlayer()) 
    local ping = getPlayerPing(getLocalPlayer()) 
    local serial = getPlayerSerial() 
    local money = getPlayerMoney(getLocalPlayer()) 
    local weapon = getPedWeapon (getLocalPlayer()) 
    local ammo = getPedTotalAmmo (getLocalPlayer()) 
    local carname = getPedOccupiedVehicle (getLocalPlayer()) 
    if carname then 
        state = isVehicleLocked ( carname ) 
        if state then locked = "Locked" else locked = "Unlocked" end 
        carhealth = math.floor(getElementHealth (carname)) 
        lights = getVehicleLightState ( carname, 0 ) 
        vehicleName = getVehicleName(carname) 
    else 
        carhealth = "Not in a vehicle." 
        lights = "Not in a vehicle." 
        locked = "Not in a vehicle." 
        vehicleName = "Not in a vehicle." 
    end 
    local armor = getPedArmor ( getLocalPlayer() ) 
    team = getPlayerTeam ( getLocalPlayer() )   
    if team then 
        teamName = getTeamName(team) 
    else 
        teamName = "None" 
    end 
    local weaponslot = getPedWeaponSlot ( getLocalPlayer() ) 
    local health = getElementHealth ( getLocalPlayer() ) 
    
        dxDrawRectangle(778.0,521.0,246.0,94.0,tocolor(200,0,0,80),false) 
        dxDrawText("Lights: "..lights,794.0,592.0,930.0,597.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false)         
        dxDrawText("State: "..locked,794.0,563.0,930.0,578.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Health: "..carhealth,794.0,547.0,930.0,563.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawRectangle(778.0,422.0,246.0,65.0,tocolor(200,0,0,80),false) 
        dxDrawText("Vehicle Name: "..vehicleName,794.0,531.0,930.0,547.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawRectangle(778.0,287.0,246.0,106.0,tocolor(200,0,0,80),false) 
        dxDrawRectangle(778.0,257.0,246.0,30.0,tocolor(50,0,0,200),false) 
        dxDrawRectangle(778.0,393.0,246.0,34.0,tocolor(50,0,0,200),false) 
        dxDrawRectangle(778.0,487.0,246.0,34.0,tocolor(50,0,0,200),false) 
        dxDrawText("Vehicle Stats: ",836.0,487.0,982.0,517.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
        dxDrawText("Ammo: ",794.0,461.0,930.0,477.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Slot ID: "..weaponslot,794.0,447.0,930.0,461.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Weapon Name: "..weapon,794.0,432.0,930.0,447.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Weapon Stats",836.0,393.0,982.0,422.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
        dxDrawText("Ping: "..ping,794.0,368.0,884.0,383.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Team: "..teamName,794.0,352.0,884.0,368.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Armor: "..armor,794.0,336.0,884.0,352.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Health: "..health,794.0,321.0,884.0,336.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Money: "..money,794.0,307.0,884.0,321.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Name: "..name,794.0,292.0,884.0,307.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("My Stats",854.0,258.0,947.0,287.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
    end 
) 

Link to comment
Well, your script had many errors, you we're trying to use the vehicle element as the vehicle name, trying to get vehicle data when he was not in one, that was causing the script not to work.
addEventHandler("onClientRender",root, 
    function() 
    local name = getPlayerName(getLocalPlayer()) 
    local ping = getPlayerPing(getLocalPlayer()) 
    local serial = getPlayerSerial() 
    local money = getPlayerMoney(getLocalPlayer()) 
    local weapon = getPedWeapon (getLocalPlayer()) 
    local ammo = getPedTotalAmmo (getLocalPlayer()) 
    local carname = getPedOccupiedVehicle (getLocalPlayer()) 
    if carname then 
        state = isVehicleLocked ( carname ) 
        if state then locked = "Locked" else locked = "Unlocked" end 
        carhealth = math.floor(getElementHealth (carname)) 
        lights = getVehicleLightState ( carname, 0 ) 
        vehicleName = getVehicleName(carname) 
    else 
        carhealth = "Not in a vehicle." 
        lights = "Not in a vehicle." 
        locked = "Not in a vehicle." 
        vehicleName = "Not in a vehicle." 
    end 
    local armor = getPedArmor ( getLocalPlayer() ) 
    team = getPlayerTeam ( getLocalPlayer() )   
    if team then 
        teamName = getTeamName(team) 
    else 
        teamName = "None" 
    end 
    local weaponslot = getPedWeaponSlot ( getLocalPlayer() ) 
    local health = getElementHealth ( getLocalPlayer() ) 
    
        dxDrawRectangle(778.0,521.0,246.0,94.0,tocolor(200,0,0,80),false) 
        dxDrawText("Lights: "..lights,794.0,592.0,930.0,597.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false)         
        dxDrawText("State: "..locked,794.0,563.0,930.0,578.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Health: "..carhealth,794.0,547.0,930.0,563.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawRectangle(778.0,422.0,246.0,65.0,tocolor(200,0,0,80),false) 
        dxDrawText("Vehicle Name: "..vehicleName,794.0,531.0,930.0,547.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawRectangle(778.0,287.0,246.0,106.0,tocolor(200,0,0,80),false) 
        dxDrawRectangle(778.0,257.0,246.0,30.0,tocolor(50,0,0,200),false) 
        dxDrawRectangle(778.0,393.0,246.0,34.0,tocolor(50,0,0,200),false) 
        dxDrawRectangle(778.0,487.0,246.0,34.0,tocolor(50,0,0,200),false) 
        dxDrawText("Vehicle Stats: ",836.0,487.0,982.0,517.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
        dxDrawText("Ammo: ",794.0,461.0,930.0,477.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Slot ID: "..weaponslot,794.0,447.0,930.0,461.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Weapon Name: "..weapon,794.0,432.0,930.0,447.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Weapon Stats",836.0,393.0,982.0,422.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
        dxDrawText("Ping: "..ping,794.0,368.0,884.0,383.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Team: "..teamName,794.0,352.0,884.0,368.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Armor: "..armor,794.0,336.0,884.0,352.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Health: "..health,794.0,321.0,884.0,336.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Money: "..money,794.0,307.0,884.0,321.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("Name: "..name,794.0,292.0,884.0,307.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) 
        dxDrawText("My Stats",854.0,258.0,947.0,287.0,tocolor(255,255,255,255),1.8,"default","left","top",false,false,false) 
    end 
) 

Castillo FTW, THANK YOU THANK YOU. You have helped me alot so far, now your in the credits lol, thank you.

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...