Sign in to follow this  
FoxyPT

[AJUDA] Como Colocar Scripts fechado para so uma class/team

Recommended Posts

Boas queria deixa meu script fechado so para uma team alguem sabe me dizer como faço?

Share this post


Link to post
Boas queria deixa meu script fechado so para uma team alguem sabe me dizer como faço?

cole aqui, a parte do código que deseja colocar esta função.

Share this post


Link to post
Boas queria deixa meu script fechado so para uma team alguem sabe me dizer como faço?

optionsTable = {}

optionsTable[1] = {x=1583.68408, y=1450.32666, z=9.83114} -- LV

optionsTable[2] = {x=348.91159, y=2539.05054, z=15.74509} -- VM

optionsTable[3] = {x=-1460.63989, y=-152.66759, z=13.14844} -- SF

optionsTable[4] = {x=1562.28149, y=-2414.01587, z=12.55469} -- LS

lastTarget = false

deliveryPrice = false

deliveryMarker = false

deliveryBlip = false

function onPlaneEnter()

local daVehicle = getPedOccupiedVehicle(localPlayer)

if daVehicle and getVehicleType(daVehicle) == "Plane" then

if isElement(deliveryMarker) then destroyElement(deliveryMarker) deliveryMarker = false end

if isElement(deliveryBlip) then destroyElement(deliveryBlip) deliveryBlip = false end

local optionsNew = deepcopy(optionsTable)

if lastTarget then table.remove(optionsNew, lastTarget) end

local randomNumber = math.random(1,#optionsNew)

lastTarget = randomNumber

local x = optionsNew[randomNumber]['x']

local y = optionsNew[randomNumber]['y']

local z = optionsNew[randomNumber]['z']

exports.saptcommands:sendClientMessage("*Pilot Delivery* Your load is ready to be delivered. ", 0, 255, 0)

deliveryMarker = createMarker(x,y,z,"cylinder",5)

local px, py = getElementPosition(localPlayer)

deliveryPrice = getDistanceBetweenPoints2D(x, y, px, py) * 5

deliveryBlip = createBlipAttachedTo(deliveryMarker,5)

addEventHandler("onClientMarkerHit",deliveryMarker,onDeliveryHit)

addEventHandler("onClientVehicleExit",daVehicle ,onPlaneExit)

addEventHandler("onClientVehicleExplode",daVehicle ,onPlaneExit)

addEventHandler("onPlayerWasted", localPlayer, deleteMission)

end

end

addEventHandler("onClientPlayerVehicleEnter",localPlayer,function() onPlaneEnter() end)

function onDeliveryHit(hitPlayer, matchingDimension)

if hitPlayer == localPlayer then

if getPedOccupiedVehicle(hitPlayer) and matchingDimension and isVehicleOnGround(getPedOccupiedVehicle(hitPlayer)) and getVehicleType(getPedOccupiedVehicle(hitPlayer)) == "Plane" then

exports.saptcommands:sendClientMessage("*Pilot Delivery* You've delivered it successfully, great job!", 50, 255, 50)

exports.saptcommands:giveMoney(localPlayer, deliveryPrice)

destroyElement(deliveryMarker)

destroyElement(deliveryBlip)

deliveryMarker = false

deliveryBlip = false

deliveryPrice = false

onPlaneEnter()

end

end

end

function onPlaneExit()

removeEventHandler("onClientVehicleExit",source,onPlaneExit)

deleteMission()

end

function deleteMission()

if deliveryMarker then

exports.saptcommands:sendClientMessage("Pilot Delivery* The delivery failed. Keep going, you were going great!", 0, 255, 0)

destroyElement(deliveryMarker)

destroyElement(deliveryBlip)

deliveryMarker = false

deliveryBlip = false

deliveryPrice = false

end

end

addEventHandler("onClientPlayerSpawn", localPlayer, deleteMission)

function deepcopy(object)

local lookup_table = {}

local function _copy(object)

if type(object) ~= "table" then

return object

elseif lookup_table[object] then

return lookup_table[object]

end

local new_table = {}

lookup_table[object] = new_table

for index, value in pairs(object) do

new_table[_copy(index)] = _copy(value)

end

return setmetatable(new_table, getmetatable(object))

end

return _copy(object)

end

Share this post


Link to post

olha cara, acho que vai funcionar. (não tenho certeza) :|

server.lua

function teamName ( source ) 
    if getPlayerTeam(source) and getTeamName(getPlayerTeam(source)) == "Nome_do_time" then 
        setElementData ( source, "Team", true ) 
    else 
        setElementData ( source, "Team", false ) 
    end 
end 
addEventHandler("onPlayerVehicleEnter", getRootElement(),teamName) 

client.lua

optionsTable = {} 
optionsTable[1] = {x=1583.68408, y=1450.32666, z=9.83114} -- LV 
optionsTable[2] = {x=348.91159, y=2539.05054, z=15.74509} -- VM 
optionsTable[3] = {x=-1460.63989, y=-152.66759, z=13.14844} -- SF 
optionsTable[4] = {x=1562.28149, y=-2414.01587, z=12.55469} -- LS 
lastTarget = false 
deliveryPrice = false 
  
deliveryMarker = false 
deliveryBlip = false 
  
function onPlaneEnter() 
local daVehicle = getPedOccupiedVehicle(localPlayer) 
    if getElementData ( getLocalPlayer(), "Team" ) -- verifica se o jogador é do time 
        if daVehicle and getVehicleType(daVehicle) == "Plane" then 
            if isElement(deliveryMarker) then   destroyElement(deliveryMarker) deliveryMarker = false end 
                if isElement(deliveryBlip) then destroyElement(deliveryBlip) deliveryBlip = false end 
                    local optionsNew = deepcopy(optionsTable) 
                    if lastTarget then table.remove(optionsNew, lastTarget) end 
                        local randomNumber = math.random(1,#optionsNew) 
                        lastTarget = randomNumber 
                        local x = optionsNew[randomNumber]['x'] 
                        local y = optionsNew[randomNumber]['y'] 
                        local z = optionsNew[randomNumber]['z'] 
                        exports.saptcommands:sendClientMessage("*Pilot Delivery* Your load is ready to be delivered. ", 0, 255, 0) 
                        deliveryMarker = createMarker(x,y,z,"cylinder",5) 
                        local px, py = getElementPosition(localPlayer) 
                        deliveryPrice = getDistanceBetweenPoints2D(x, y, px, py) * 5 
                        deliveryBlip = createBlipAttachedTo(deliveryMarker,5) 
                        addEventHandler("onClientMarkerHit",deliveryMarker,onDeliveryHit) 
                        addEventHandler("onClientVehicleExit",daVehicle ,onPlaneExit) 
                        addEventHandler("onClientVehicleExplode",daVehicle ,onPlaneExit) 
                        addEventHandler("onPlayerWasted", localPlayer, deleteMission) 
        end 
    end -- fecha a verificação 
end 
addEventHandler("onClientPlayerVehicleEnter",localPlayer,function() onPlaneEnter() end) 
  
function onDeliveryHit(hitPlayer, matchingDimension) 
        if hitPlayer == localPlayer then 
            if getPedOccupiedVehicle(hitPlayer) and matchingDimension and isVehicleOnGround(getPedOccupiedVehicle(hitPlayer)) and getVehicleType(getPedOccupiedVehicle(hitPlayer)) == "Plane" then 
                exports.saptcommands:sendClientMessage("*Pilot Delivery* You've delivered it successfully, great job!", 50, 255, 50) 
                exports.saptcommands:giveMoney(localPlayer, deliveryPrice) 
                destroyElement(deliveryMarker) 
                destroyElement(deliveryBlip) 
                deliveryMarker = false 
                deliveryBlip = false 
                deliveryPrice = false 
                onPlaneEnter() 
            end 
        end 
end 
  
function onPlaneExit() 
    removeEventHandler("onClientVehicleExit",source,onPlaneExit) 
    deleteMission() 
end 
  
  
function deleteMission() 
        if deliveryMarker then 
            exports.saptcommands:sendClientMessage("Pilot Delivery* The delivery failed. Keep going, you were going great!", 0, 255, 0) 
            destroyElement(deliveryMarker) 
            destroyElement(deliveryBlip) 
            deliveryMarker = false 
            deliveryBlip = false 
            deliveryPrice = false 
        end 
end 
addEventHandler("onClientPlayerSpawn", localPlayer, deleteMission) 
  
function deepcopy(object) 
        local lookup_table = {} 
        local function _copy(object) 
            if type(object) ~= "table" then 
                return object 
                elseif lookup_table[object] then 
                return lookup_table[object] 
            end 
            local new_table = {} 
            lookup_table[object] = new_table 
                for index, value in pairs(object) do 
                    new_table[_copy(index)] = _copy(value) 
                end 
                    return setmetatable(new_table, getmetatable(object)) 
                end 
                return _copy(object) 
end 

Share this post


Link to post

Se você deseja a função para apenas um grupo específico, então aqui está:

-- CLIENT-SIDE 
optionsTable = {} 
optionsTable[1] = {x=1583.68408, y=1450.32666, z=9.83114} -- LV 
optionsTable[2] = {x=348.91159, y=2539.05054, z=15.74509} -- VM 
optionsTable[3] = {x=-1460.63989, y=-152.66759, z=13.14844} -- SF 
optionsTable[4] = {x=1562.28149, y=-2414.01587, z=12.55469} -- LS 
lastTarget = false 
deliveryPrice = false 
  
deliveryMarker = false 
deliveryBlip = false 
team = "Police" 
  
  
function onPlaneEnter() 
local daVehicle = getPedOccupiedVehicle(localPlayer) 
    if getTeamName(getPlayerTeam(localPlayer)) == team then 
        if daVehicle and getVehicleType(daVehicle) == "Plane" then 
            if isElement(deliveryMarker) then   destroyElement(deliveryMarker) deliveryMarker = false end 
                if isElement(deliveryBlip) then destroyElement(deliveryBlip) deliveryBlip = false end 
                    local optionsNew = deepcopy(optionsTable) 
                    if lastTarget then table.remove(optionsNew, lastTarget) end 
                        local randomNumber = math.random(1,#optionsNew) 
                        lastTarget = randomNumber 
                        local x = optionsNew[randomNumber]['x'] 
                        local y = optionsNew[randomNumber]['y'] 
                        local z = optionsNew[randomNumber]['z'] 
                        exports.saptcommands:sendClientMessage("*Pilot Delivery* Your load is ready to be delivered. ", 0, 255, 0) 
                        deliveryMarker = createMarker(x,y,z,"cylinder",5) 
                        local px, py = getElementPosition(localPlayer) 
                        deliveryPrice = getDistanceBetweenPoints2D(x, y, px, py) * 5 
                        deliveryBlip = createBlipAttachedTo(deliveryMarker,5) 
                        addEventHandler("onClientMarkerHit",deliveryMarker,onDeliveryHit) 
                        addEventHandler("onClientVehicleExit",daVehicle ,onPlaneExit) 
                        addEventHandler("onClientVehicleExplode",daVehicle ,onPlaneExit) 
                        addEventHandler("onPlayerWasted", localPlayer, deleteMission) 
        end 
    end 
end 
addEventHandler("onClientPlayerVehicleEnter",localPlayer,onPlaneEnter) 
  
function onDeliveryHit(hitPlayer, matchingDimension) 
    if hitPlayer == localPlayer then 
        if getPedOccupiedVehicle(hitPlayer) and matchingDimension and isVehicleOnGround(getPedOccupiedVehicle(hitPlayer)) and getVehicleType(getPedOccupiedVehicle(hitPlayer)) == "Plane" then 
            exports.saptcommands:sendClientMessage("*Pilot Delivery* You've delivered it successfully, great job!", 50, 255, 50) 
            exports.saptcommands:giveMoney(localPlayer, deliveryPrice) 
            destroyElement(deliveryMarker) 
            destroyElement(deliveryBlip) 
            deliveryMarker = false 
            deliveryBlip = false 
            deliveryPrice = false 
            onPlaneEnter() 
        end 
    end 
end 
  
function onPlaneExit() 
    removeEventHandler("onClientVehicleExit",localPlayer,onPlaneExit) 
    deleteMission() 
end 
  
  
function deleteMission() 
    if deliveryMarker then 
        exports.saptcommands:sendClientMessage("Pilot Delivery* The delivery failed. Keep going, you were going great!", 0, 255, 0) 
        destroyElement(deliveryMarker) 
        destroyElement(deliveryBlip) 
        deliveryMarker = false 
        deliveryBlip = false 
        deliveryPrice = false 
    end 
end 
addEventHandler("onClientPlayerSpawn", localPlayer, deleteMission) 
  
function deepcopy(object) 
    local lookup_table = {} 
    local function _copy(object) 
    if type(object) ~= "table" then 
        return object 
        elseif lookup_table[object] then 
        return lookup_table[object] 
    end 
    local new_table = {} 
    lookup_table[object] = new_table 
    for index, value in pairs(object) do 
        new_table[_copy(index)] = _copy(value) 
    end 
        return setmetatable(new_table, getmetatable(object)) 
    end 
    return _copy(object) 
end 

A mágica está em:

team = "Police" -- Nome do grupo 
   
function onPlaneEnter() 
    if getTeamName(getPlayerTeam(localPlayer)) == team then 
        -- código 
    end 
end 
addEventHandler("onClientPlayerVehicleEnter",localPlayer,onPlaneEnter) 

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.