Jump to content

duvida em um script de desmanche


Recommended Posts

Estou com duvida em um script, achei um sistema de desmanche na internet, só que quando terminava de desmanchar o carro eu recebia dinheiro ao invés de dinheiro sujo, porque não vinha dinheiro sujo junto com o mod, então eu tentei colocar no lugar do givePlayerMoney um executeCommandHandler para executar o comando: executeCommandHandler( dar, player, math.random(1000, 50000), Dinheiro Sujo), mas n funcionou, alguém por favor me ajuda? to começando com os scripts lua.

obs> ele funcionava antes de eu tentar mudar!

Script sem nenhuma modificação:

local zones = {
     {3030.7453613281, -155.14810180664, 21.885005950928},
}

local zone      = {}
local myZone    = {}
local elements  = {}
local zonetime  = {}
local tableZone = {}

addEventHandler('onResourceStart', resourceRoot,
function()
     for i=1, #zones do
         zone = createColSphere(zones[1], zones[2], zones[3], 10)
         addEventHandler('onColShapeHit', zone, enterZone)
         addEventHandler('onColShapeLeave', zone, exitZone)
     end
end)

local function checkZone (zone)
     for i = 1, #zonetime do
         if zonetime == zone then
             return false
         end
     end
     return true
end

local function getPosZone (zone) 
     for i = 1, #zonetime do
         if zonetime == zone then
             return i
         end
     end
end

setTimer(function()
     for i = 1, #zonetime do
         if tableZone and not tableZone[zonetime] then tableZone[zonetime] = {['Ocupada'] = true, ['Horas'] = 0, ['Minutos'] = 0, ['Segundos'] = 0} attWithinZone(zonetime) end
             if tableZone[zonetime]['Segundos'] <= 0 then
                 tableZone[zonetime]['Segundos'] = 59
                 tableZone[zonetime]['Minutos'] = tableZone[zonetime]['Minutos'] - 1
                 if tableZone[zonetime]['Minutos'] <= 0 then
                     tableZone[zonetime]['Minutos'] = 59
                     if tableZone[zonetime]['Horas'] > 0 then
                         tableZone[zonetime]['Horas'] = tableZone[zonetime]['Horas'] - 1
                     end
                 end
             end
             tableZone[zonetime]['Segundos'] = tableZone[zonetime]['Segundos'] - 1
             if tableZone[zonetime]['Segundos'] <= 0 and tableZone[zonetime]['Horas'] == 0 then
                 table.remove(zonetime, getPosZone (zonetime))
                 tableZone[zonetime] = nil
             end
         end
     end,
1000, 0)

function attWithinZone (zone)
     if tableZone[zone] then
     local player = nil
         for i=1, #getElementsWithinColShape(zone, "player" ) do
             player = getElementsWithinColShape(zone, "player" )
             triggerClientEvent(player, 'rzk:load:timezone', resourceRoot, zone, true, tableZone[zone]['Horas'], tableZone[zone]['Minutos'], tableZone[zone]['Segundos'])
         end
     end
end

addEvent('rzk:ocupezone', true)
addEventHandler('rzk:ocupezone', resourceRoot,
function (player, zone, vehicle)
     if isElement(zone) then
         if checkZone (zone) then
             if not tableZone[zone] then
                 table.insert(zonetime, zone)
                 setElementData(vehicle, 'vehicle:desmanche', true)
                 setElementData(player, 'player:vehicle', vehicle)
             else
                 triggerClientEvent(player, 'cancel:service', resourceRoot)
             end
         else
             triggerClientEvent(player, 'cancel:service', resourceRoot)
           end
     end
end)

function exitZone (element)
     if getElementType (element) == "player" then
         triggerClientEvent(element, 'rzk:load:timezone', resourceRoot, source, false)
         local vehicle = getPedOccupiedVehicle (element)
         if vehicle then
             removeEventHandler ( "onVehicleExit", vehicle, exitVehicle)
             myZone[element] = nil
         end
     end
end

function enterZone (element)
     if getElementType (element) == "player" then
         if tableZone[source] then
             triggerClientEvent(element, 'rzk:load:timezone', resourceRoot, source, true, tableZone[source]['Horas'], tableZone[source]['Minutos'], tableZone[source]['Segundos'])
         else
             triggerClientEvent(element, 'rzk:load:timezone', resourceRoot, source, true)
         end
         local vehicle = getPedOccupiedVehicle (element)
         if vehicle then
             addEventHandler ( "onVehicleExit", vehicle, exitVehicle)
         end
         myZone[element] = source
     end
end

local blackListVehicle = {
     [401]=true,
}

function exitVehicle (player, seat)
     if isElement(source) then
         if not tableZone[myZone[player]] then
             if not blackListVehicle[getElementModel(source)] then
                 if seat == 0 then
                     removeEventHandler ( "onVehicleExit", source, exitVehicle)
                        triggerClientEvent(player, 'rzk:startprogress', resourceRoot, source, myZone[player])
                 else
                     removeEventHandler ( "onVehicleExit", source, exitVehicle)
                 end
             else
                 exports.Mat_Infos:serverNotification(player, "info", "Esse veiculo não pode ser desmanchado.", 10, 25)
                 removeEventHandler ( "onVehicleExit", source, exitVehicle)
             end
         else
             exports.Mat_Infos:serverNotification(player, "info", "Aguarde "..tableZone[myZone[player]]['Horas'].." Horas e "..tableZone[myZone[player]]['Minutos'].." Minutos para realizar outro desmanche.", 10, 25)
         end
     end
     myZone[player] = nil
end

addEventHandler ( "onVehicleStartEnter", getRootElement(),
function ( player, seat, jacked )
     if (getElementData(source, 'vehicle:desmanche')) then --if the vehicle is one of 4 police cars, and the skin is not a police skin
         cancelEvent()
         exports.Mat_Infos:serverNotification(player, "info", "Esse veiculo está sendo desmanchado.", 10, 25)
     end
end)

addEvent('rzk:action:vehicle', true)
addEventHandler('rzk:action:vehicle', resourceRoot,
function (vehicle, door, action)
     if isElement(vehicle) then
         local door = tonumber(door)
         setVehicleDoorOpenRatio (vehicle, door, action, 2000)
     end
end)

addEvent('rzk:remove:component', true)
addEventHandler('rzk:remove:component', resourceRoot,
function (vehicle, component)
     if isElement(vehicle) then
         local players = getElementsByType("player")
         local player = nil
         for i = 1, #players do
             player = players
             triggerClientEvent(player, 'remove:component', resourceRoot, vehicle, component)
         end
     end
end)

addEvent('rzk:setAnimation', true)
addEventHandler('rzk:setAnimation', resourceRoot,
function (player, anim_1, anim_2)
     if isElement(player) then
         if anim_1 then
             setElementFrozen(player, true)
             setPedAnimation(player, anim_1, anim_2)
         else
             setPedAnimation(player)
             setElementFrozen(player, false)
         end
     end
end)

addEvent('rzk:destroyVehicle', true)
addEventHandler('rzk:destroyVehicle', resourceRoot,
function (player, vehicle)
     if isElement(vehicle) then
         setElementData(vehicle, 'vehicle:desmanche', nil)
         setElementData(player, 'player:vehicle', nil)
         destroyElement(vehicle)
         givePlayerMoney(player, math.random(1000, 50000))
         exports.Mat_Infos:serverNotification(player, "info", "Veiculo desmanchado com sucesso.", 10, 25)
     end
end)

addEventHandler ( "onPlayerQuit", root,
function ()
     if getElementData(source, 'player:vehicle') then
         local vehicle = getElementData(source, 'player:vehicle')
         setElementData(vehicle, 'vehicle:desmanche', nil)
         local players = getElementsByType("player")
         local player = nil
         for i = 1, #players do
             player = players
             triggerClientEvent(player, 'reset:remove:component', resourceRoot, vehicle)
         end
         setElementData(source, 'player:vehicle', nil)
     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...