Jump to content

Kikar Jogador da COL


Recommended Posts

Posted (edited)

Boa Noite,

 

Preciso de uma ajuda no sistema de expulsar o jogador selecionado do Base (COL) so que to com problema nisso e precisava de uma ajuda segue a baixo o sistema

OBS: EU PEGUEI ESSA ULTIMA FUNÇÃO DO SERVER.LUA COMO EXEMPLO DA OUTRA QUE TEM QUANDO KIKA TODOS OS JOGADORES DA BASE (COL), AI QUERO FAZER PARA O JOGADOR SELECIONADO.

 

--- Client.lua

----------------------------------------------------------------
--- PAINEL

BasePaneltab1 = guiCreateTab("Jogadores", BasePaneltabpanel)
BasePanelGridliste2 = guiCreateGridList(40, 15, 490, 200, false, BasePaneltab1)
BasePanelColumn2 = guiGridListAddColumn(BasePanelGridliste2, "Jogador:", 0.9)
KikarPlayerBase = guiCreateButton(40, 230, 250, 50,"Kikar Jogador\nSelecionado",false,BasePaneltab1)
ClearBase = guiCreateButton(310, 230, 220, 50,"Expulsar todos da Base",false,BasePaneltab1)


----------------------------------------------------
-- Quando clica na Grilist

addEventHandler("onClientGUIClick",BasePanelGridliste2,function(thePlayers)
    playerName = guiGridListGetItemText ( BasePanelGridliste2, guiGridListGetSelectedItem ( BasePanelGridliste2 ), BasePanelColumn2 )
	outputChatBox(playerName)
	if playerName ~= "" then
	    triggerServerEvent("KikaJorgadorBase",getLocalPlayer(),playerName)
	end
    elseif source == BaseManangerButton then
		triggerServerEvent("KikaJorgadorBase",getLocalPlayer())
	    triggerServerEvent("refreshGatess",getLocalPlayer())
		guiSetEnabled(ClearBase,false)
        guiSetVisible(BaseManagementGUI2,false)
		triggerServerEvent("refreshPlayerss",getLocalPlayer())
		setTimer(function()
		    guiSetEnabled(ClearBase,true)
		end,10000,1)
end)

------------------------------------------------------
--- RECEBE DO SERVER.LUA OS JOGADORES

addEvent("refreshPlayers11",true)
addEventHandler("refreshPlayers11",getRootElement(),function(thePlayers)
	row1s,column1s = guiGridListGetSelectedItem(BasePanelGridliste2)
	guiGridListClear(BasePanelGridliste2)
	for i, thePlar in ipairs(thePlayers) do
		local Players = guiGridListAddRow(BasePanelGridliste2)
		guiGridListSetItemText(BasePanelGridliste2,Players,BasePanelColumn2,tostring(thePlar[1]),false,false)
		outputChatBox("Jogador "..tostring(thePlar[1]),255,0,0,true)
    end
	if row1s and column1s then
		guiGridListSetSelectedItem(BasePanelGridliste2,row1s,column1s)
	end
end)

 

 

 

-- Server.lua

--------------------------------------------------------------------
--- RECONHECE OS JOGADORES QUE ESTA NA BASE!

addEvent("refreshPlayerss",true)
addEventHandler("refreshPlayerss",getRootElement(), function()
    local thePlayers = {}
    local ownerAccount = getAccountName(getPlayerAccount(source))
    local baseName = getBaseNameFromOwnerAccount(ownerAccount)
    local colshape = getBaseColshape(baseName)
    if colshape and isElement(colshape) then
        local players = getElementsWithinColShape(colshape,"player")
        for i, player in pairs(players) do
        local nameCheck = getPlayerName(player)
		local PlayerP = removeHexCheck(nameCheck, 6)
            table.insert(thePlayers,{PlayerP})
        end
    end
    triggerClientEvent(source,"refreshPlayers11",source,thePlayers)
end)

---------------------------------------------------------------------
--- PARA KIKAR O JOGADOR DA COL VINDO DA GRILIST

--OBS: EU PEGUEI ESSA FUNÇÃO COMO EXEMPLO DA OUTRA QUE TEM QUANDO KIKA TODOS OS JOGADORES DA BASE (COL), AI QUERO FAZER PARA O JOGADOR SELECIONADO


addEvent("KikaJorgadorBase",true)
addEventHandler("KikaJorgadorBase",getRootElement(),function(playerName,player)
	outputChatBox("TRUE"..playerName,player)
	local ownerAccount = getAccountName(getPlayerAccount(source))
	local baseName = getBaseNameFromOwnerAccount(ownerAccount)
	local colshape = getBaseColshape(baseName)
	tpx,tpy,tpz = getElementData(colshape,"tpLoc1"),getElementData(colshape,"tpLoc2"),getElementData(colshape,"tpLoc3")
	if isElement(colshape) then
		for i,element in pairs(getElementsWithinColShape(colshape))do
			if getElementType(element) == "vehicle" then
				for i,player in pairs(getVehicleOccupants(element))do
					if playerName ~= player then
						removePedFromVehicle(player)
						setVehicleEngineState(element,false)
						setElementPosition(player,tpx,tpy,tpz)
					end
				end
			elseif getElementType(element) == "player" then
				if playerName ~= player then
					setElementPosition(element,tpx,tpy,tpz)
				end
			end
		end
		alert("Base limpa!",source)
	else
		alert("Colshape not added. Please tell the Admin!",source)
	end
end)

 

OBS: EU PEGUEI ESSA ULTIMA FUNÇÃO DO SERVER.LUA COMO EXEMPLO DA OUTRA QUE TEM QUANDO KIKA TODOS OS JOGADORES DA BASE (COL), AI QUERO FAZER PARA O JOGADOR SELECIONADO

Edited by felipebaidoloko
  • Moderators
Posted

Pelo que eu entendi, ele quer que o dono da base tenha o poder de selecionar um jogador (a partir de uma lista com os players que estão dentro do collider) e kická-lo do servidor. Na lista só aparecem os nomes dos players que estiverem dentro do collider.

Ele não quer kickar direto ao colidir, quer kickar ao selecionar o player da lista.

Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanksspacer.png

Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile
Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment
Discord Oficial do MTA: https://mtasa.com/discord
Blacklist e Whitelist de Scripters: Planilha

Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.

Posted

ta um pouco "confuso" de entender esse código mas tentei fazer no olho:
 

addEvent("KikaJorgadorBase",true)
addEventHandler("KikaJorgadorBase",getRootElement(),function(playerName)
    local gPlayerKicked = getPlayerFromName(playerName)
    local ownerAccount = getAccountName(getPlayerAccount(source))
    local baseName = getBaseNameFromOwnerAccount(ownerAccount)
    local colshape = getBaseColshape(baseName)
    local tpx,tpy,tpz = getElementData(colshape,"tpLoc1"),getElementData(colshape,"tpLoc2"),getElementData(colshape,"tpLoc3")
    
    if gPlayerKicked then
        if isElement(colshape) then
            if isElementWithinColShape(gPlayerKicked, colshape) then
                
                if gPlayerKicked == source then 
                    alert("Você não pode expulsar você mesmo.",source)
                    return
                end

                if getPedOccupiedVehicle(gPlayerKicked) then
                    removePedFromVehicle(gPlayerKicked)
                    setVehicleEngineState(gPlayerKicked)
                    setElementPosition(gPlayerKicked, tpx. tpy, tpz)
                else
                    setElementPosition(gPlayerKicked, tpx, tpy, tpz)
                end

                alert("Você expusou o jogador "..getPlayerName(gPlayerKicked).."#ffffff da sua base.",source)
            end
        end
    end
end)

EDIT 1: Não testei

EDIT 2: Não foi possível testar por falta de função: getBaseNameFromOwnerAccount()getBaseColshape()

  • Like 1

? DID I HELP YOU? 

Tsd6e1t.png

________________________________________________________________________

ム MY STEAM

76561198321211115.png

________________________________________________________________________

? MY SITE

cGejgxz.png

www.tommy.br.com

Posted
9 hours ago, Tommy. said:

ta um pouco "confuso" de entender esse código mas tentei fazer no olho:
 


addEvent("KikaJorgadorBase",true)
addEventHandler("KikaJorgadorBase",getRootElement(),function(playerName)
    local gPlayerKicked = getPlayerFromName(playerName)
    local ownerAccount = getAccountName(getPlayerAccount(source))
    local baseName = getBaseNameFromOwnerAccount(ownerAccount)
    local colshape = getBaseColshape(baseName)
    local tpx,tpy,tpz = getElementData(colshape,"tpLoc1"),getElementData(colshape,"tpLoc2"),getElementData(colshape,"tpLoc3")
    
    if gPlayerKicked then
        if isElement(colshape) then
            if isElementWithinColShape(gPlayerKicked, colshape) then
                
                if gPlayerKicked == source then 
                    alert("Você não pode expulsar você mesmo.",source)
                    return
                end

                if getPedOccupiedVehicle(gPlayerKicked) then
                    removePedFromVehicle(gPlayerKicked)
                    setVehicleEngineState(gPlayerKicked)
                    setElementPosition(gPlayerKicked, tpx. tpy, tpz)
                else
                    setElementPosition(gPlayerKicked, tpx, tpy, tpz)
                end

                alert("Você expusou o jogador "..getPlayerName(gPlayerKicked).."#ffffff da sua base.",source)
            end
        end
    end
end)

EDIT 1: Não testei

EDIT 2: Não foi possível testar por falta de função: getBaseNameFromOwnerAccount()getBaseColshape()

e muito simples , tu não entendeu porque o cara que ta com a tal ' duvida ' pego um codigo pronto mais quer modificar ele e não tem ideia de como então ele vem aqui, pedir para as pessoas fazer isso para ele 

 

e assim o amiguinho não sabe oque ta lendo no codigo e vai postando colocando no topico e nois tem q se virar para entender, eu não ajudo gente assim

Posted (edited)
3 minutes ago, brunob22 said:

e muito simples , tu não entendeu porque o cara que ta com a tal ' duvida ' pego um codigo pronto mais quer modificar ele e não tem ideia de como então ele vem aqui, pedir para as pessoas fazer isso para ele 

 

e assim o amiguinho não sabe oque ta lendo no codigo e vai postando colocando no topico e nois tem q se virar para entender, eu não ajudo gente assim

Discordo, verifiquei o perfil dele antes de postar o código pronto e ele tem esses códigos desde 2017.

Edited by Tommy.

? DID I HELP YOU? 

Tsd6e1t.png

________________________________________________________________________

ム MY STEAM

76561198321211115.png

________________________________________________________________________

? MY SITE

cGejgxz.png

www.tommy.br.com

Posted

o codigo nao é pronto ele era meu, eu e meu primo que fez mas to com problema nessa parte de kikar o jogador selecionado pq, já tem a opção de kikar o jogador so que a opção kika todos que estão dentro da col (base)

 

Para explicar mas sobre a função server.lua 

 

 

*local ownerAccount = getAccountName(getPlayerAccount(source))

= ele tem uma função que procura o dono da base cadastrado no XML

*local baseName = getBaseNameFromOwnerAccount(ownerAccount)

= verifica se a base é do dono da base

*local colshape = getBaseColshape(baseName)

= é a colshope da base, nela tem a proteção da base (alarme) e a função que fiz para ver os jogadores que estão dentro da base

* tpx,tpy,tpz = getElementData(colshape,"tpLoc1"),getElementData(colshape,"tpLoc2"),getElementData(colshape,"tpLoc3")

= é a posição x,y,z que faz o jogador ser kikado da base que tem no xml a posição para ver teleportado 

 

 

18 hours ago, Tommy. said:

ta um pouco "confuso" de entender esse código mas tentei fazer no olho:
 


addEvent("KikaJorgadorBase",true)
addEventHandler("KikaJorgadorBase",getRootElement(),function(playerName)
    local gPlayerKicked = getPlayerFromName(playerName)
    local ownerAccount = getAccountName(getPlayerAccount(source))
    local baseName = getBaseNameFromOwnerAccount(ownerAccount)
    local colshape = getBaseColshape(baseName)
    local tpx,tpy,tpz = getElementData(colshape,"tpLoc1"),getElementData(colshape,"tpLoc2"),getElementData(colshape,"tpLoc3")
    
    if gPlayerKicked then
        if isElement(colshape) then
            if isElementWithinColShape(gPlayerKicked, colshape) then
                
                if gPlayerKicked == source then 
                    alert("Você não pode expulsar você mesmo.",source)
                    return
                end

                if getPedOccupiedVehicle(gPlayerKicked) then
                    removePedFromVehicle(gPlayerKicked)
                    setVehicleEngineState(gPlayerKicked)
                    setElementPosition(gPlayerKicked, tpx. tpy, tpz)
                else
                    setElementPosition(gPlayerKicked, tpx, tpy, tpz)
                end

                alert("Você expusou o jogador "..getPlayerName(gPlayerKicked).."#ffffff da sua base.",source)
            end
        end
    end
end)

EDIT 1: Não testei

EDIT 2: Não foi possível testar por falta de função: getBaseNameFromOwnerAccount()getBaseColshape()

EU VOU TESTAR AQUI

9 hours ago, brunob22 said:

e muito simples , tu não entendeu porque o cara que ta com a tal ' duvida ' pego um codigo pronto mais quer modificar ele e não tem ideia de como então ele vem aqui, pedir para as pessoas fazer isso para ele 

 

e assim o amiguinho não sabe oque ta lendo no codigo e vai postando colocando no topico e nois tem q se virar para entender, eu não ajudo gente assim

O B2 menos ne cara se fosse assim eu colocava ja no titulo que peguei um script  e to querendo entender a função antes de pedir ajuda, veja meu perfil sempre peço ajuda para ver a onde eu estou errando e corrigir o erro. nao pedindo a função pronta

Posted
12 minutes ago, felipebaidoloko said:

EU VOU TESTAR AQUI

Caso de algum problema só relatar aqui no tópico.

? DID I HELP YOU? 

Tsd6e1t.png

________________________________________________________________________

ム MY STEAM

76561198321211115.png

________________________________________________________________________

? MY SITE

cGejgxz.png

www.tommy.br.com

Posted

Bom nao deu ce

13 minutes ago, Tommy. said:

Caso de algum problema só relatar aqui no tópico.

nao deu certo aqui parece que essa função nao executou

 

local gPlayerKicked = getPlayerFromName(playerName)

 

tipo o playerName pego meu nome na grilist mas no server.lua nao foi

Posted
1 minute ago, felipebaidoloko said:

Bom nao deu ce

nao deu certo aqui parece que essa função nao executou

 

local gPlayerKicked = getPlayerFromName(playerName)

 

tipo o playerName pego meu nome na grilist mas no server.lua nao foi

Creio que isso aconteceu pq você tirou o código de cor do nickname quando adicionou na gridlist

? DID I HELP YOU? 

Tsd6e1t.png

________________________________________________________________________

ム MY STEAM

76561198321211115.png

________________________________________________________________________

? MY SITE

cGejgxz.png

www.tommy.br.com

Posted

Altere o getPlayerFromName pelo Useful Function 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

 

2 minutes ago, felipebaidoloko said:

TIREI A COR DO MEU NICK AI RECONHECEU MAS NESSA FUNÇÃO ELE NAO EXECUTO 

 

if isElementWithinColShape(gPlayerKicked, colshape) then

Estranho, sabe me dizer se a variável colshape está retornando o ColShape ?

? DID I HELP YOU? 

Tsd6e1t.png

________________________________________________________________________

ム MY STEAM

76561198321211115.png

________________________________________________________________________

? MY SITE

cGejgxz.png

www.tommy.br.com

Posted
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

addEvent("KikaJorgadorBase",true)
addEventHandler("KikaJorgadorBase",getRootElement(),function(playerName)
    --alert("ok.",source)
	local gPlayerKicked = getPlayerFromPartialName(playerName)
    local baseName = getBaseNameFromOwnerAccount(ownerAccount)
	local baseExpired,day,month,year,daysRemaining,maxautos,maxaircrafts = isBaseExpired(baseName)
	colshape = getBaseColshape(baseName)
	tpx,tpy,tpz = getElementData(colshape,"tpLoc1"),getElementData(colshape,"tpLoc2"),getElementData(colshape,"tpLoc3")
    if gPlayerKicked then
    
        if isElement(colshape) then
            --if isElementWithinColShape(gPlayerKicked, colshape) then
                --[[if gPlayerKicked == source then 
                    alert("Você não pode expulsar você mesmo.",source)
                    return
                end--]]
				alert("TRUEE",source)
                if getPedOccupiedVehicle(gPlayerKicked) then
                    removePedFromVehicle(gPlayerKicked)
                    setVehicleEngineState(gPlayerKicked)
                    setElementPosition(gPlayerKicked, tpx. tpy, tpz)
                else
				    alert("Kik",source)
                    setElementPosition(gPlayerKicked, tpx, tpy, tpz)
                end
				
                alert("Você expusou o jogador "..getPlayerName(gPlayerKicked).."#ffffff da sua base.",source)
            --end
        end
    end
end)

 

eu ocultei a linha e deu AVISO DA setElementPosition(gPlayerKicked, tpx, tpy, tpz)

 

 

TEM OUTRA FUNÇÃO DO MEU SISTEMA QUE KIKA O JOGADOR QUE NAO TA NO CLA 

 

setTimer(function()
	local xml = xmlLoadFile("Bases.xml")
	for i,node in pairs(xmlNodeGetChildren(xml)) do
	local baseName = xmlNodeGetName(node)
	local baseCol = getBaseColshape(baseName)
	local TPLoc1,TPLoc2,TPLoc3 = getElementData(baseCol,"tpLoc1"),getElementData(baseCol,"tpLoc2"),getElementData(baseCol,"tpLoc3")
		for i,player in pairs(getElementsByType("player"))do
			if isElementWithinColShape(player,baseCol)then
				if not ((exports.GroupSystem:checkPlayerPermission(player,"A08") and getElementData(player,"Group") == getGroupNameFromBaseName(baseName)) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))) then
					if getPedOccupiedVehicle(player) then
						removePedFromVehicle(player)
						setVehicleEngineState(player,false)
					else
						setElementPosition(player,TPLoc1,TPLoc2,TPLoc3+1)
					end
					exports.GroupSystem:alert("Você não tem mais acesso a esta base!",player)
				end
			end
		end
	end
	xmlUnloadFile(xml)
end,5000,0)

 AQUI USA O if isElementWithinColShape(player,baseCol)then

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