Jump to content

[HELP] Why not working this script?


Tokio

Recommended Posts

function onClientClick(button, state)
	if button == "left" and state == "down" then
		for k, v in ipairs(fegyverek) do
			if isInBox(screenW * 0.5703, screenH * 0.2700+(elem * 49.5), screenW * 0.0656, screenH * 0.0269) then
				fegyver = k
			end
		end
		if isInBox(screenW * 0.5703, screenH * 0.2700+(elem * 49.5), screenW * 0.0656, screenH * 0.0269) then
			if fegyver == 3 then
				outputChatBox("asd")
			end
		end
	end
end
addEventHandler("onClientClick", root, onClientClick)

function isInBox(xS,yS,wS,hS)
	if(isCursorShowing()) then
		local cursorX, cursorY = getCursorPosition()
		cursorX, cursorY = cursorX*sX, cursorY*sY
		if(cursorX >= xS and cursorX <= xS+wS and cursorY >= yS and cursorY <= yS+hS) then
			return true
		else
			return false
		end
	end	
end

What wrong in this? No error/warning in debugscript.. 

Edited by Nerve
Link to comment

Try this

[client-side]

function onClientClick(button, state)
	if button == "left" and state == "down" then
		for k, v in ipairs(fegyverek) do
			if isInBox(screenW * 0.5703, screenH * 0.2700+(elem * 49.5), screenW * 0.0656, screenH * 0.0269) then
				fegyver = k
			end
		end
		if isInBox(screenW * 0.5703, screenH * 0.2700+(elem * 49.5), screenW * 0.0656, screenH * 0.0269) then
			if fegyver == 3 then
				outputChatBox("asd")
			end
		end
	end
end
addEventHandler("onClientClick", root, onClientClick)

function isInBox(xS,yS,wS,hS)
    local sx,sy = getCursorPosition ()
    local fx,fy = guiGetScreenSize()
    
    cursorx,cursory = sx*fx,sy*fy

    if cursorx > xS and cursorx < xS + wS and cursory > yS and cursory < yS + hS then
        return true
    else
        return false
    end
end

EDIT: Not tested

  • Like 1
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...