Jump to content

[Ajuda] setElementData por ID


Recommended Posts

Fiz um comando para setar um elementData por id so que em vez de setar pro player esta setando para mim, mesma coisa ao tentar remover o elementData

function adicionarCorp(thePlayer, id)
	local player = getPlayerID(tonumber(id))
	if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then
	setElementData(player, "INT:BTS", tonumber(id))
	outputChatBox("[INT]: #ffffffVocê colocou o jogador [ID]:"..id.." na corporação!", thePlayer,255,255,255, true)
	end
end
addCommandHandler("corp", adicionarCorp)

function removeCorp(thePlayer, id)
	local player = getPlayerID(tonumber(id))
	if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then
	removeElementData(player, "INT:BTS", tonumber(id))
	outputChatBox("[INT]: #ffffffVocê removeu o jogador [ID]:"..id.." da corporação!", thePlayer,255,255,255, true)
	end
end
addCommandHandler("rcorp", removeCorp)

 

 

Link to comment

Tente:

function adicionarCorp(thePlayer, _, id)
    if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then
        if (setElementData(getPlayerID(tonumber(id)), "INT:BTS", true)) then
            outputChatBox("[INT]: #ffffffVocê colocou o jogador [ID]:"..id.." na corporação!", thePlayer,255,255,255, true)
        end
    end
end
addCommandHandler("corp", adicionarCorp)

function removeCorp(thePlayer, _, id)
    if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then
        if (removeElementData(getPlayerID(tonumber(id)), "INT:BTS")) then
            outputChatBox("[INT]: #ffffffVocê removeu o jogador [ID]:"..id.." da corporação!", thePlayer,255,255,255, true)
        end
    end
end
addCommandHandler("rcorp", removeCorp)

Obs: getPlayerID não é uma função nativa do MTA, espero que esteja importando/incluindo no seu código.

  • Thanks 1
Link to comment
1 hour ago, [M]ister said:

Tente:


function adicionarCorp(thePlayer, _, id)
    if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then
        if (setElementData(getPlayerID(tonumber(id)), "INT:BTS", true)) then
            outputChatBox("[INT]: #ffffffVocê colocou o jogador [ID]:"..id.." na corporação!", thePlayer,255,255,255, true)
        end
    end
end
addCommandHandler("corp", adicionarCorp)

function removeCorp(thePlayer, _, id)
    if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin"))) then
        if (removeElementData(getPlayerID(tonumber(id)), "INT:BTS")) then
            outputChatBox("[INT]: #ffffffVocê removeu o jogador [ID]:"..id.." da corporação!", thePlayer,255,255,255, true)
        end
    end
end
addCommandHandler("rcorp", removeCorp)

Obs: getPlayerID não é uma função nativa do MTA, espero que esteja importando/incluindo no seu código.

Funcionou perfeitamente sim o código está incluido.

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