codeluaeveryday Posted October 6, 2011 Share Posted October 6, 2011 (edited) 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 October 6, 2011 by Guest Link to comment
JR10 Posted October 6, 2011 Share Posted October 6, 2011 local engine = getVehicleEngineState (carname) Is a server side function. Remove it, and remove it's dxDrawText. Link to comment
codeluaeveryday Posted October 6, 2011 Author Share Posted October 6, 2011 local engine = getVehicleEngineState (carname) Is a server side function. Remove it, and remove it's dxDrawText. Ehh, i also tried that, did'nt work, i also attempted to remove lights, it helped, not by much. It made one thing appear state. Please what is wrong with this D:. Link to comment
Castillo Posted October 6, 2011 Share Posted October 6, 2011 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
codeluaeveryday Posted October 6, 2011 Author Share Posted October 6, 2011 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now