Jump to content

Client getElementData


iLimix

Recommended Posts

Posted

Hey guys,
i don't know what it can be

function KDShow(player)
  	dxDrawText(getElementData ( localPlayer, "deaths" ), 86, 367, 193, 388, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
end



Expected string at argument 1, got boolean

i hope u can help me.

Posted

try this :

 

function KDShow(player)
      dxDrawText(getElementData ( localPlayer, "deaths" ) and tostring ( getElementData ( localPlayer, "deaths" ) ) or "N/A", 86, 367, 193, 388, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
end

 

Posted

The problem is that the there is no data for "deaths" on the player so it is returning a boolean( a true/false value ) which would be false in your case.

function KDShow(player)
	local deaths = getElementData ( localPlayer, "deaths" )
  	dxDrawText(deaths or 0, 86, 367, 193, 388, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
end

What I've done is made a simple check to see if deaths == false.

If deaths == false it will use the or operator and return 0.

If deaths == a number or anything, it will show that value of "deaths" instead.

local deaths = (getElementData ( localPlayer, "deaths" ) or 0)

 

Posted
12 minutes ago, Mr.Loki said:

The problem is that the there is no data for "deaths" on the player so it is returning a boolean( a true/false value ) which would be false in your case.


function KDShow(player)
	local deaths = getElementData ( localPlayer, "deaths" )
  	dxDrawText(deaths or 0, 86, 367, 193, 388, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
end

What I've done is made a simple check to see if deaths == false.

If deaths == false it will use the or operator and return 0.

If deaths == a number or anything, it will show that value of "deaths" instead.


local deaths = (getElementData ( localPlayer, "deaths" ) or 0)

 

He show me now "0" but in Database show me 45

Posted

Database is not your elementdata, whenever you log in, you have to set the player's elementdata to the one which he has in the database.

Posted
							setElementData ( player, "deaths", tonumber ( dsatz["Tode"] ) )
							setElementData ( player, "kills", tonumber ( dsatz["Kills"] ) )

this is in Register / Login script

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