Jump to content

[HELP]Pls help me to fix this error


Recommended Posts

I get this error in debug.Kill/Script.lua:12: attempt to call a number value

Client:

function dieHandler(p)
        addEventHandler ("onClientRender", getRootElement(), dieDx)
        setTimer(function() removeEventHandler("onClientRender",getRootElement(),dieDx) end,7000,1)
    end
    addEvent ("onType", true)
    addEventHandler ("onType", root, dieHandler)
    sWidth,sHeight = guiGetScreenSize()

function dieDx ()
      timer = setTimer(function() end, 7000, 1)
      remaining = getTimerDetails(timer)
         dxDrawText("You will be killed in #FFFFFF"..( math.floor(remaining/1000))" #640000seconds", sWidth(310/1024), sHeight(250/768), sWidth(1221/1280), sHeight(92/720), tocolor(100, 0, 0, 255), 1.5, "pricedown", "left", "top", false, false, true, true, false)
    end

Server:

addCommandHandler('killme',
    function(p)
	wlevel = getPlayerWantedLevel ( p )
		if (wlevel == 0) then
        setTimer(killPed, 7000, 1, p)
        toggleAllControls ( p, false )
		triggerClientEvent (p, "onType", p)
		setTimer ( toggleAllControls, 7000, 1, p, true )
	end
	end
)

 

Link to comment
sWidth(310/1024), sHeight(250/768), sWidth(1221/1280), sHeight(92/720)

Lua interprets this as if you were trying to call functions named sWidth, sHeight. You should add a multiplication operator between these:

sWidth*(310/1024), sHeight*(250/768), sWidth*(1221/1280), sHeight*(92/720)

 

Link to comment

Your script at math.floor is wrong.

         dxDrawText("You will be killed in #FFFFFF"..( math.floor(remaining/1000))" #640000seconds", sWidth(310/1024), sHeight(250/768), sWidth(1221/1280), sHeight(92/720), tocolor(100, 0, 0, 255), 1.5, "pricedown", "left", "top", false, false, true, true, false)

Math.floor should be like this:

         dxDrawText("You will be killed in #FFFFFF"..math.floor(remaining/1000).." #640000seconds", 84, 218, 917, 366, tocolor(100, 0, 0, 255), 1.5, "pricedown", "left", "top", false, false, true, true, false)-- I change place of drawing.

The problem that line 11 is clearing when you do that command much that 2 times.

Link to comment

Can confirm it's an issue of concatenation. Lua interprets math.floor(remaining/1000) into a number, and then it thinks you're using a short hand function calling notation without brackets ( e.g. print"hello world!"; ). This means Lua interprets the result of math.floor and then uses that as if it was a function but it's a number value. You should use the concatenation operator (..) between math.floor and the string " #640000seconds" as Mohamed Nightmare pointed out above.

Edited by MrTasty
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...