Jump to content

Script help pls


mamo

Recommended Posts

Hey all can someone help me 'City tour'

I can't spawn when all vehicules are rdy PLS HELP

----------------------------------------------------------------------- 
 
-----------------------------------------------------------------------
-- MovePlayerAway - Super hack - Fixes the spec cam problem
-----------------------------------------------------------------------
MovePlayerAway = {}
MovePlayerAway.timer = Timer:create()
MovePlayerAway.posX = 0
MovePlayerAway.posY = 0
MovePlayerAway.posZ = 0
MovePlayerAway.rotZ = 0
MovePlayerAway.health = 0
 
function MovePlayerAway.start()
    local element = g_Vehicle or getPedOccupiedVehicle(g_Me) or g_Me
    MovePlayerAway.posX, MovePlayerAway.posY, MovePlayerAway.posZ = getElementPosition(element)
    MovePlayerAway.posZ = 34567 + math.random(0,4000)
    MovePlayerAway.rotZ = 0
    MovePlayerAway.health = math.max(1,getElementHealth(element))
    MovePlayerAway.update(true)
    MovePlayerAway.timer:setTimer(MovePlayerAway.update,500,0)
    triggerServerEvent("onRequestMoveAwayBegin", g_Me)
end
 
 
function MovePlayerAway.update(nozcheck)
    -- Move our player far away
    local camTarget = getCameraTarget()
    if not getPedOccupiedVehicle(g_Me) then
        setElementPosition( g_Me, MovePlayerAway.posX-10, MovePlayerAway.posY-10, MovePlayerAway.posZ )
    end
    if getPedOccupiedVehicle(g_Me) then
        if not nozcheck then
            if camTarget then
                MovePlayerAway.posX, MovePlayerAway.posY = getElementPosition(camTarget)
                if getElementType(camTarget) ~= "vehicle" then
                    outputDebug( 'SPECTATE', 'camera target type:' .. getElementType(camTarget) )
                end
                if getElementType(camTarget) == 'ped' then
                    MovePlayerAway.rotZ = getPedRotation(camTarget)
                else
                    _,_, MovePlayerAway.rotZ = getElementRotation(camTarget)
                end
            end  
        end
        local vehicle = g_Vehicle
        if vehicle then
            fixVehicle( vehicle )
            setElementFrozen ( vehicle, true )
            setElementPosition( vehicle, MovePlayerAway.posX, MovePlayerAway.posY, MovePlayerAway.posZ )
            setElementVelocity( vehicle, 0,0,0 )
            setVehicleTurnVelocity( vehicle, 0,0,0 )
            setElementRotation ( vehicle, 0,0,MovePlayerAway.rotZ )
        end
    end
 
    if camTarget and camTarget ~= getCameraTarget() then
        setCameraTarget(camTarget)
    end
end
 
function MovePlayerAway.stop()
    triggerServerEvent("onRequestMoveAwayEnd", g_Me)
    if MovePlayerAway.timer:isActive() then
        MovePlayerAway.timer:killTimer()
        local vehicle = g_Vehicle
        if vehicle then
            setElementVelocity( vehicle, 0,0,0 )
            setVehicleTurnVelocity( vehicle, 0,0,0 )
            setElementFrozen ( vehicle, false )
            setVehicleDamageProof ( vehicle, false )
        end
        setElementVelocity( g_Me, 0,0,0 )
    end
end
 
-----------------------------------------------------------------------
-- Camera transition for our player's respawn
----------------------------------------------- ------------------------
function remoteStopSpectateAndBlack()
    Spectate.stop('auto')
--  fadeCamera(false,0.0, 0,0,0)            -- Instant black
end
 
function remoteSoonFadeIn( bNoCameraMove )
    setTimer(fadeCamera,250+500,1,true,1.0)     -- And up
    if not bNoCameraMove then
        setTimer( function() setCameraBehindVehicle( g_Vehicle ) end ,250+500-150,1 )
    end
    setTimer(checkVehicleIsHelicopter,250+500,1)
end
-----------------------------------------------------------------------
 
function raceTimeout()
    removeEventHandler('onClientRender', g_Root, updateTime)
    if g_CurrentCheckpoint then
        destroyCheckpoint(g_CurrentCheckpoint)
        destroyCheckpoint(g_CurrentCheckpoint + 1)
    end
    guiSetText(g_GUI.timeleft, msToTimeStr(0))
    if g_GUI.hurry then
        Animation.createAndPlay(g_GUI.hurry, Animation.presets.guiFadeOut(500), destroyElement)
        g_GUI.hurry = nil
    end
    triggerEvent("onClientPlayerOutOfTime", g_Me)
    toggleAllControls(false, true, false)
end
 
function unloadAll()
    triggerEvent('onClientMapStopping', g_Me)
    for i=1,#g_Checkpoints do
        destroyCheckpoint(i)
    end
    g_Checkpoints = {}
    g_CurrentCheckpoint = nil
   
    for colshape,pickup in pairs(g_Pickups) do
        destroyElement(colshape)
        if pickup.object then
            destroyElement(pickup.object)
        end
        if pickup.label then
            pickup.label:destroy()
        end
    end
    g_Pickups = {}
    g_VisiblePickups = {}
   
    table.each(g_Objects, destroyElement)
    g_Objects = {}
   
    setElementData(g_Me, 'race.checkpoint', nil)
   
    g_Vehicle = nil
    removeEventHandler('onClientRender', g_Root, updateTime)
   
    toggleAllControls(true)
   
    if g_GUI then
        hideGUIComponents( 'checkpoint')
        if g_GUI.hurry then
            Animation.createAndPlay(g_GUI.hurry, Animation.presets.guiFadeOut(500), destroyElement)
            g_GUI.hurry = nil
        end
    end
    TimerManager.destroyTimersFor("map")
    g_StartTick = nil
    g_HurryDuration = nil
    if Spectate.active then
        Spectate.stop('auto')
    end
end
 
function createCheckpoint(i)
    local checkpoint = g_Checkpoints[i]
    if checkpoint.marker then
        return
    end
    local pos = checkpoint.position
    local color = checkpoint.color or { 0, 0, 255 }
    checkpoint.marker = createMarker(pos[1], pos[2], pos[3], checkpoint.type or 'checkpoint', checkpoint.size, color[1], color[2], color[3])
    if (not checkpoint.type or checkpoint.type == 'checkpoint') and i == #g_Checkpoints then
        setMarkerIcon(checkpoint.marker, 'finish')
    end
    if checkpoint.type == 'ring' and i < #g_Checkpoints then
        setMarkerTarget(checkpoint.marker, unpack(g_Checkpoints[i+1].position))
    end
    checkpoint.blip = createBlip(pos[1], pos[2], pos[3], 0, isCurrent and 2 or 1, color[1], color[2], color[3])
    setBlipOrdering(checkpoint.blip, 1)
    return checkpoint.marker
end
 
function makeCheckpointCurrent(i,bOtherPlayer)
    local checkpoint = g_Checkpoints[i]
    local pos = checkpoint.position
    local color = checkpoint.color or { 255, 0, 0 }
    if not checkpoint.blip then
        checkpoint.blip = createBlip(pos[1], pos[2], pos[3], 0, 2, color[1], color[2], color[3])
        setBlipOrdering(checkpoint.blip, 1)
    else
        setBlipSize(checkpoint.blip, 2)
    end
   
    if not checkpoint.type or checkpoint.type == 'checkpoint' then
        checkpoint.colshape = createColCircle(pos[1], pos[2], checkpoint.size + 4)
    else
        checkpoint.colshape = createColSphere(pos[1], pos[2], pos[3], checkpoint.size + 4)
    end
    if getElementData(getLocalPlayer(), 'cop') == true then return end
    if not bOtherPlayer then
        addEventHandler('onClientColShapeHit', checkpoint.colshape, checkpointReached)
    end
end
 
function destroyCheckpoint(i)
    local checkpoint = g_Checkpoints[i]
    if checkpoint and checkpoint.marker then
        destroyElement(checkpoint.marker)
        checkpoint.marker = nil
        destroyElement(checkpoint.blip)
        checkpoint.blip = nil
        if checkpoint.colshape then
            destroyElement(checkpoint.colshape)
            checkpoint.colshape = nil
        end
    end
end
 
function setCurrentCheckpoint(i, bOtherPlayer)
    destroyCheckpoint(g_CurrentCheckpoint)
    destroyCheckpoint(g_CurrentCheckpoint + 1)
    createCheckpoint(i)
    g_CurrentCheckpoint = i - 1
    showNextCheckpoint(bOtherPlayer)
end
 
function isPlayerRaceDead(player)
    return not getElementHealth(player) or getElementHealth(player) < 1e-45 or isPlayerDead(player)
end
 
function isPlayerFinished(player)
    return getElementData(player, 'race.finished')
end
 
function isPlayerSpectating(player)
    return getElementData(player, 'race.spectating')
end
 
addEventHandler('onClientPlayerJoin', g_Root,
    function()
        table.insertUnique(g_Players, source)
    end
)
 
addEventHandler('onClientPlayerSpawn', g_Root,
    function()
        Spectate.blockAsTarget( source, 2000 )  -- No spectate at this player for 2 seconds
    end
)
 
addEventHandler('onClientPlayerWasted', g_Root,
    function()
        if not g_StartTick then
            return
        end
        local player = source
        local vehicle = getPedOccupiedVehicle(player)
        if player == g_Me then
            if #g_Players > 1 and (g_MapOptions.respawn == 'none' or g_MapOptions.respawntime >= 10000) then
                if Spectate.blockManualTimer and isTimer(Spectate.blockManualTimer) then
                   
Edited by Guest
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...