Jump to content

Question: ElementData


zezim

Recommended Posts

Hey guys,

Who can help me? I need to export a function to another code but I can't.

I need export it: 

setElementData(player, "Suspiro.Algemado", false)
I need to send it here:
addEvent('Pedro.onPlayerPreso', true)
addEventHandler('Pedro.onPlayerPreso', root, 
    function(player, tempo, id, motivo)
        if tonumber(tempo) and tonumber(id) and motivo then 
            if tonumber(tempo) <= config.TempoMax then 
                local receiver = getPlayerFromID(id)
                if isElement(receiver) then 
                    local posP = {getElementPosition(player)}
                    local posR = {getElementPosition(receiver)}
                    if getDistanceBetweenPoints3D(posP[1], posP[2], posP[3], posR[1], posR[2], posR[3]) <= 3 then 
                        triggerClientEvent(player, 'Pedro.printPrisao', player)
                        message(player, 'Player was arrested.', 'info')
						getElementData(receiver, "Suspiro.Algemado", false)
Please see the last line of the code and tell me if it's right.
Link to comment
  On 29/07/2022 at 23:46, zezim said:

Hey guys,

Who can help me? I need to export a function to another code but I can't.

I need export it: 

setElementData(player, "Suspiro.Algemado", false)
I need to send it here:
addEvent('Pedro.onPlayerPreso', true)
addEventHandler('Pedro.onPlayerPreso', root, 
    function(player, tempo, id, motivo)
        if tonumber(tempo) and tonumber(id) and motivo then 
            if tonumber(tempo) <= config.TempoMax then 
                local receiver = getPlayerFromID(id)
                if isElement(receiver) then 
                    local posP = {getElementPosition(player)}
                    local posR = {getElementPosition(receiver)}
                    if getDistanceBetweenPoints3D(posP[1], posP[2], posP[3], posR[1], posR[2], posR[3]) <= 3 then 
                        triggerClientEvent(player, 'Pedro.printPrisao', player)
                        message(player, 'Player was arrested.', 'info')
						getElementData(receiver, "Suspiro.Algemado", false)
Please see the last line of the code and tell me if it's right.
Expand  

I can't understand exactly what you want to do, but there are 2 alternatives for what you showed.

1 - Set a value for elementData:

setElementData(receivier, 'Suspiro.Algemado', false)

2 - Check with if statement:

if not getElementData(receivier, 'Suspiro.Algemado') then
    -- Code that will execute after verification (if elementData value 'Suspiro.Algemado' is not true)
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...