Jump to content

Alguém deixa esse cod menor e mais otimizado pra mim por favor


Recommended Posts

function tpbloods(playerSource)
	if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup("Staff")) then
		if getElementData(playerSource, "Expediente-STAFF") == "Sim" then
			if not Flying[playerSource] then
				Flying[playerSource] = true
				setElementAlpha(playerSource, 0)
				triggerClientEvent(playerSource, "onClientFlyToggle", playerSource)
			end
			setElementPosition(playerSource, 2219.984, -1143.273, 25.797)
			setElementRotation(playerSource, 0, 0, 353.328)
			showInfobox(playerSource, "Você teleportou na base Bloods", "success")
		else
			atendimento(playerSource)
		end
	end
end
addCommandHandler("tpbloods", tpbloods)

function tpgrove(playerSource)
	if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup("Staff")) then
		if getElementData(playerSource, "Expediente-STAFF") == "Sim" then
			if not Flying[playerSource] then
				Flying[playerSource] = true
				setElementAlpha(playerSource, 0)
				triggerClientEvent(playerSource, "onClientFlyToggle", playerSource)
			end
			setElementPosition(playerSource, 2463.633, -1659.423, 13.311)
			setElementRotation(playerSource, 0, 0, 88.373)
			showInfobox(playerSource, "Você teleportou na base da Grove", "success")
		else
			atendimento(playerSource)
		end
	end
end
addCommandHandler("tpgrove", tpgrove)

function tpcrips(playerSource)
	if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup("Staff")) then
		if getElementData(playerSource, "Expediente-STAFF") == "Sim" then
			if not Flying[playerSource] then
				Flying[playerSource] = true
				setElementAlpha(playerSource, 0)
				triggerClientEvent(playerSource, "onClientFlyToggle", playerSource)
			end
			setElementPosition(playerSource, 2183.58, -1761.268, 13.375)
			setElementRotation(playerSource, 0, 0, 359.602)
			showInfobox(playerSource, "Você teleportou na base Crips", "success")
		else
			atendimento(playerSource)
		end
	end
end
addCommandHandler("tpcrips", tpcrips)

function tpsiliciana(playerSource)
	if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(playerSource)), aclGetGroup("Staff")) then
		if getElementData(playerSource, "Expediente-STAFF") == "Sim" then
			if not Flying[playerSource] then
				Flying[playerSource] = true
				setElementAlpha(playerSource, 0)
				triggerClientEvent(playerSource, "onClientFlyToggle", playerSource)
			end
			setElementPosition(playerSource, 2418.157, -2009.204, 13.396)
			setElementRotation(playerSource, 0, 0, 90.592)
			showInfobox(playerSource, "Você teleportou na base Siliciana", "success")
		else
			atendimento(playerSource)
		end
	end
end
addCommandHandler("tpsiliciana", tpsiliciana)
----------------------------------------------------------------------------------------------------------------------------
function showInfobox(element, message, tipo)
	exports["[HYPE]NOTIFY"]:addNotification(element, message, tipo)
end

atendimento = function (element)
	return triggerClientEvent(element, "HypeNotify", element, "Você não está em modo atendimento use /pro", "error")
end

Basicamente são vários comandos que executam basicamente a mesma função eu gostaria que fosse menor tipo executar o comando e o nome da base ai ele puxar a posição da base e teleportar pequeno exemplo abaixo

bases = {{yakuza, 2418.157, -2009.204, 13.396 }, {bloods, 1234.09, -2029.24, 13.396 }}

Link to comment
  • Other Languages Moderators
local bases = { -- ["comando"] = {x, y, z, r, "nome"},
    ["tpbloods"] = {2219.984, -1143.273, 25.797, 353.328, "Bloods"},
    ["tpgrove"] = {2463.633, -1659.423, 13.311, 88.373, "Grove"},
    ["tpcrips"] = {2183.58, -1761.268, 13.375, 359.602, "Crips"},
    ["tpsiliciana"] = {2418.157, -2009.204, 13.396, 90.592, "Siliciana"},
}

function teleBases(cmd, thePlayer)
    if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Staff")) then
        if getElementData(thePlayer, "Expediente-STAFF") == "Sim" then
            if not Flying[thePlayer] then
                Flying[thePlayer] = true
                setElementAlpha(thePlayer, 0)
                triggerClientEvent(thePlayer, "onClientFlyToggle", thePlayer)
            end
            local x, y, z, r, nome = unpack(bases[cmd])
            setElementPosition(thePlayer, x, y, z)
            setElementRotation(thePlayer, 0, 0, r)
            showInfobox(thePlayer, "Você teleportou para a base "..nome, "success")
        else
            atendimento(thePlayer)
        end
    end
end

for cmd,item in pairs(bases) do
    addCommandHandler(cmd, teleBases)
end

----------------------------------------------------------------------------------------------------------------------------
function showInfobox(element, message, tipo)
    exports["[HYPE]NOTIFY"]:addNotification(element, message, tipo)
end

atendimento = function (element)
    return triggerClientEvent(element, "HypeNotify", element, "Você não está em modo atendimento use /pro", "error")
end

 

Fiz de cabeça, não testado.

  • Thanks 1
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...