Jump to content

Help at Vehicles


K4stic

Recommended Posts

-- Disabled the seasparrow weapons for player not in staff or military forces team 
addEventHandler("onClientVehicleStartEnter", root, 
    function(thePlayer, seat) 
        if ( thePlayer == localPlayer ) then 
            if ( getElementModel ( source ) == 447 ) or ( getElementModel ( source ) == 425 ) or ( getElementModel ( source ) == 520 ) then 
                if (getTeamName(getPlayerTeam(thePlayer)) == "Staff") or (getTeamName(getPlayerTeam(thePlayer)) == "Armed Forces") then 
                    toggleControl ( "vehicle_fire", true ) 
                    toggleControl ( "vehicle_secondary_fire", true ) 
                else 
                    toggleControl ( "vehicle_fire", false ) 
                    toggleControl ( "vehicle_secondary_fire", false ) 
                end 
            end 
        end 
    end 
) 
  
-- Enable the weapons again when the player leaves the vehicle 
addEventHandler("OnClientVehicleStartExit", root, 
    function(thePlayer, seat) 
        if thePlayer == localPlayer then 
            if ( getElementModel ( source ) == 447 ) or ( getElementModel ( source ) == 425 ) or ( getElementModel ( source ) == 520 ) then 
                if not (getTeamName(getPlayerTeam(thePlayer)) == "Staff") or not (getTeamName(getPlayerTeam(thePlayer)) == "Armed Forces") then 
                    toggleControl ( "vehicle_fire", true ) 
                    toggleControl ( "vehicle_secondary_fire", true ) 
                end 
            end 
        end 
    end 
) 

it no disable the weapon for other teams

i wonna to player can shoot with that vehicles only if he Staff or Armed Forces but it no disable it :/

Link to comment
local vehicles = 
    { 
        [ 447 ] = true, 
        [ 425 ] = true, 
        [ 520 ] = true 
    } 
  
local teams = 
    { 
        [ "Staff" ] = true, 
        [ "Armed Forces" ] = true 
    } 
  
-- Disabled the seasparrow weapons for player not in staff or military forces team 
addEventHandler ( "onClientVehicleStartEnter", root, 
    function ( thePlayer, seat ) 
        if ( thePlayer == localPlayer ) then 
            if ( vehicles [ getElementModel ( source ) ] ) then 
                local team = getPlayerTeam ( thePlayer ) 
                if ( team and teams [ getTeamName ( team ) ] ) then 
                    toggleControl ( "vehicle_fire", true ) 
                    toggleControl ( "vehicle_secondary_fire", true ) 
                else 
                    toggleControl ( "vehicle_fire", false ) 
                    toggleControl ( "vehicle_secondary_fire", false ) 
                end 
            end 
        end 
    end 
) 
  
-- Enable the weapons again when the player leaves the vehicle 
addEventHandler ( "onClientVehicleStartExit", root, 
    function ( thePlayer, seat ) 
        if ( thePlayer == localPlayer ) then 
            if ( vehicles [ getElementModel ( source ) ] ) then 
                local team = getPlayerTeam ( thePlayer ) 
                if ( not team or not teams [ getTeamName ( team ) ] ) then 
                    toggleControl ( "vehicle_fire", true ) 
                    toggleControl ( "vehicle_secondary_fire", true ) 
                end 
            end 
        end 
    end 
) 

Try that.

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