Jump to content

Marker Protection


iPrestege

Recommended Posts

Hello , I Have Problem Here On This Script I Do it With Marker But The Problem If Is Player In Vehicle And He Didn,t Hit The Marker He Will Be Spawned To The Fucking Position i Put ( = Note : Am Using It On Server Side On Meta Some Help To Fix It

local Marker = createMarker ( -2842.7297363281, -329.54904174805, 167.10781860352, "checkpoint", 20, 255, 255, 255, 255 ) 
local Marker1 = createMarker ( -2953.7856445313,-330.46145629883, 4.9000000953674, "checkpoint", 20, 255, 255, 255, 255 ) 
  
timers = {} 
  
function marker(player) 
    if (source == Marker or source == Marker1 and player and getElementType(player) == "player") then         
            outputChatBox ("You , Can,t Ger Vehicle Here!!", player, 255, 0, 0, false) 
                triggerClientEvent (player, "enableGodMode", player) 
                toggleControl (player, "fire", false ) 
                toggleControl (player, "aim_weapon", false) 
                toggleControl (player, "vehicle_fire", false)         
                timers[player] = setTimer (function (player) 
                if isElement(player) then 
                        local weaponType = getPedWeapon ( player ) 
                        if ( weaponType ) then 
                                takeAllWeapons ( player ) 
                        end 
                        if isPedInVehicle( player ) then 
                                if isTimer(timers[player]) then killTimer(timers[player]) timers[player] = nil end 
                                setTimer(onhit, 2000, 1, player) 
                        outputChatBox ("You , Can,t Ger Vehicle Here!!", player, 255, 0, 0, false) 
                        end 
                end         
        end, 1000, 0, player) 
    end 
end 
addEventHandler ("onMarkerHit",getRootElement(),marker) 
  
function onhit(plr) 
        if plr and isElement(plr) then 
                local veh = getPedOccupiedVehicle(plr) 
                setElementVelocity (veh, 0, 0, 0) 
                setElementPosition (veh, -3031.3862304688,-194.81304931641,5) 
                setVehicleRotation (veh, 0,0,270)         
        end         
end 
  
addEventHandler ("onMarkerLeave",getRootElement(),function(player) 
    if (source == Marker or source == Marker1 and getElementType(player) == "player" )then 
        if isTimer(timers[player]) then killTimer(timers[player]) timers[player] = nil end 
                        triggerClientEvent (player, "disableGodMode", player) 
                        toggleControl (player, "fire", true ) 
                        toggleControl (player, "aim_weapon", true) 
                        toggleControl (player, "vehicle_fire", true)                                 
    end 
end) 
  
addEventHandler("onPlayerQuit",root,function() 
if isTimer(timers[source]) then killTimer(timers[source]) timers[source] = nil end 
end ) 

Link to comment
Col = createColSphere (-2842.7297363281, -329.54904174805,167.10781860352, 20 ) 
Col1 = createColSphere (  -2953.7856445313,-330.46145629883,4.9000000953674, 20 ) 
  
addEventHandler( "onColShapeHit", root, 
    function (player) 
         if ( source == Col or source == Col1 and player and getElementType(player) == "player") then         
           outputChatBox ("You , Can,t Get Vehicle Here!!", player, 255, 0, 0, false) 
                triggerClientEvent (player, "enableGodMode", player) 
                toggleControl (player, "fire", false ) 
                toggleControl (player, "aim_weapon", false) 
                toggleControl (player, "vehicle_fire", false)         
                timers[player] = setTimer (function (player) 
                if isElement(player) then 
                        local weaponType = getPedWeapon ( player ) 
                        if ( weaponType ) then 
                                takeAllWeapons ( player ) 
                        end 
                        if isPedInVehicle( player ) then 
                                if isTimer(timers[player]) then killTimer(timers[player]) timers[player] = nil end 
                                setTimer(onhit, 2000, 1, player) 
                        outputChatBox ("You , Can,t Get Vehicle Here!!", player, 255, 0, 0, false) 
                        end 
                end         
        end, 1000, 0, player) 
    end 
end 
) 
  
function onhit(plr) 
        if plr and isElement(plr) then 
                local veh = getPedOccupiedVehicle(plr) 
                setElementVelocity (veh, 0, 0, 0) 
                setElementPosition (veh, -3031.3862304688,-194.81304931641,5) 
                setVehicleRotation (veh, 0,0,270)         
        end         
end 
  
addEventHandler ("onColShapeLeave", root, 
function(player) 
    if ( source == Col or source == Col1 and getElementType(player) == "player" )then 
        if isTimer(timers[player]) then killTimer(timers[player]) timers[player] = nil end 
                        triggerClientEvent (player, "disableGodMode", player) 
                        toggleControl (player, "fire", true ) 
                        toggleControl (player, "aim_weapon", true) 
                        toggleControl (player, "vehicle_fire", true)                                 
    end 
end 
) 
  
addEventHandler("onPlayerQuit",root, 
function() 
if isTimer(timers[source]) then killTimer(timers[source]) timers[source] = nil end 
end ) 
  

Link to comment
Col = createColSphere ( -2842.7297363281, -329.54904174805,10.10781860352, 20 ) 
Col1 = createColSphere (  -2953.7856445313,-330.46145629883,4.9000000953674, 20 ) 
timers = { } 
  
addEventHandler( "onColShapeHit", root, 
    function ( player ) 
        if ( source == Col or source == Col1 ) then 
            if ( player and getElementType ( player ) == "player" ) then         
                outputChatBox ( "You , Can,t Get Vehicle Here!!", player, 255, 0, 0, false ) 
                triggerClientEvent ( player, "enableGodMode", player ) 
                toggleControl ( player, "fire", false ) 
                toggleControl ( player, "aim_weapon", false ) 
                toggleControl ( player, "vehicle_fire", false )         
                timers[player] = setTimer ( 
                    function ( player ) 
                        if isElement ( player ) then 
                            local weaponType = getPedWeapon ( player ) 
                            if ( weaponType ) then 
                                takeAllWeapons ( player ) 
                            end 
                            if isPedInVehicle ( player ) then 
                                local shape = Col or Col1 
                                local veh = getPedOccupiedVehicle ( player ) 
                                if not isElementWithinColShape ( veh, shape ) then 
                                    if isTimer ( timers[player] ) then 
                                        killTimer ( timers[player] ) 
                                        timers[player] = nil 
                                    end                              
                                    return 
                                end 
                                outputChatBox ( "You , Can,t Get Vehicle Here!!", player, 255, 0, 0, false ) 
                                onhit ( player ) 
                            end 
                        end         
                    end 
                , 1000, 0, player ) 
            end 
        end 
    end 
) 
  
function onhit ( plr ) 
    if plr and isElement ( plr ) then 
        local veh = getPedOccupiedVehicle ( plr ) 
        if veh then 
            setElementVelocity ( veh, 0, 0, 0 ) 
            setElementPosition ( veh, -3031.3862304688, -194.81304931641, 5 ) 
            setVehicleRotation ( veh, 0,0,270 ) 
            timers[plr] = nil 
        end 
    end         
end 
  
addEventHandler ( "onColShapeLeave", root, 
    function ( player ) 
        if ( source == Col or source == Col1 ) then 
            if getElementType ( player ) == "player" then 
                if isTimer ( timers[player] ) then 
                    killTimer ( timers[player] ) 
                    timers[player] = nil 
                end 
                triggerClientEvent ( player, "disableGodMode", player ) 
                toggleControl ( player, "fire", true ) 
                toggleControl ( player, "aim_weapon", true ) 
                toggleControl ( player, "vehicle_fire", true )                                 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit",root, 
    function() 
        if isTimer ( timers[source] ) then 
            killTimer ( timers[source] )  
            timers[source] = nil 
        end 
    end  
) 

Link to comment
Col = createColSphere ( -2842.7297363281, -329.54904174805,10.10781860352, 20 ) 
Col1 = createColSphere (  -2953.7856445313,-330.46145629883,4.9000000953674, 20 ) 
timers = { } 
  
addEventHandler( "onColShapeHit", root, 
    function ( player ) 
        if ( source == Col or source == Col1 ) then 
            if ( player and getElementType ( player ) == "player" ) then         
                outputChatBox ( "You , Can,t Get Vehicle Here!!", player, 255, 0, 0, false ) 
                triggerClientEvent ( player, "enableGodMode", player ) 
                toggleControl ( player, "fire", false ) 
                toggleControl ( player, "aim_weapon", false ) 
                toggleControl ( player, "vehicle_fire", false )         
                timers[player] = setTimer ( 
                    function ( player ) 
                        if isElement ( player ) then 
                            local weaponType = getPedWeapon ( player ) 
                            if ( weaponType ) then 
                                takeAllWeapons ( player ) 
                            end 
                            if isPedInVehicle ( player ) then 
                                local shape = Col or Col1 
                                local veh = getPedOccupiedVehicle ( player ) 
                                if not isElementWithinColShape ( veh, shape ) then 
                                    if isTimer ( timers[player] ) then 
                                        killTimer ( timers[player] ) 
                                        timers[player] = nil 
                                    end                              
                                    return 
                                end 
                                outputChatBox ( "You , Can,t Get Vehicle Here!!", player, 255, 0, 0, false ) 
                                onhit ( player ) 
                            end 
                        end         
                    end 
                , 1000, 0, player ) 
            end 
        end 
    end 
) 
  
function onhit ( plr ) 
    if plr and isElement ( plr ) then 
        local veh = getPedOccupiedVehicle ( plr ) 
        if veh then 
            setElementVelocity ( veh, 0, 0, 0 ) 
            setElementPosition ( veh, -3031.3862304688, -194.81304931641, 5 ) 
            setVehicleRotation ( veh, 0,0,270 ) 
            timers[plr] = nil 
        end 
    end         
end 
  
addEventHandler ( "onColShapeLeave", root, 
    function ( player ) 
        if ( source == Col or source == Col1 ) then 
            if getElementType ( player ) == "player" then 
                if isTimer ( timers[player] ) then 
                    killTimer ( timers[player] ) 
                    timers[player] = nil 
                end 
                triggerClientEvent ( player, "disableGodMode", player ) 
                toggleControl ( player, "fire", true ) 
                toggleControl ( player, "aim_weapon", true ) 
                toggleControl ( player, "vehicle_fire", true )                                 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit",root, 
    function() 
        if isTimer ( timers[source] ) then 
            killTimer ( timers[source] )  
            timers[source] = nil 
        end 
    end  
) 

I'm going to try it i will give you the results wait please ... :) !

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...