Jump to content

Criar uma painel simples com algumas funções


Recommended Posts

Funções, eventos e resource's que você vai necessitar para fazer esse script:

  • Server-Side ( lado servidor)
  1. addCommandHandler
  2. getPlayerByID ou getPlayerFromPartialNick (as duas são funções úteis, mandarei logo abaixo.)
  3. givePlayerMoney
  4. addEvent
  5. addEventHandler
  • Client-Side (lado cliente)
  1. guiEditor (resource útil, só clicar para ser redirecionado a community.)
  2. cursorPosition (função útil, mandarei logo abaixo.)
  3. triggerServerEvent
  4. onClientClick

getPlayerByID:

function getPlayerByID(id)
	v = false
	for i, player in ipairs (getElementsByType("player")) do
		if getElementData(player, "ID") == id then
			v = player
			break
		end
	end
	return v
end

getPlayerFromPartialName:

function getPlayerFromPartialName (name)
	local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
	if name then
		for _, player in ipairs(getElementsByType("player")) do
			local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
			if name_:find(name, 1, true) then
				return player
			end
		end
	end
end

cursorPosition:

function cursorPosition(x, y, w, h)
	if (not isCursorShowing()) then
		return false
	end
	local mx, my = getCursorPosition()
	local fullx, fully = guiGetScreenSize()
	cursorx, cursory = mx*fullx, my*fully
	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
		return true
	else
		return false
	end
end	

 

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