Jump to content

Hydra .


CapY

Recommended Posts

Posted
function DisableHydraFire ( theVehicle ) 
    toggleControl ( "vehicle_secondary_fire", ~(getElementModel ( theVehicle ) == 520 ) ) ) 
end 
addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer(), DisableHydraFire ) 

Posted
function disableFireForHydra ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra 
        setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns 
  
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra ) 

Posted

Can it be available only for admins and moderators?

And btw , must i put it in play resource or freeroam resource ?

Posted
function disableFireForHydra ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra 
         if hasObjectPermissionTo (source, "function.banPlayer", false) then 
                setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns 
          end 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra ) 

Posted
function disableFireForHydra ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra 
         if hasObjectPermissionTo (source, "function.banPlayer", false) then 
                setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns 
          end 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra ) 

And where i must put it , in play or freeroam ?

Posted
function disableFireForHydra ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra 
         if not hasObjectPermissionTo (source, "function.banPlayer", false) then 
                setVehicleGunsEnabled ( theVehicle, false ) -- disable their guns 
          end 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra ) 

And add it anywhere, doesn't matter.

Posted

It's working, you are using it server side, that's why the functions works on all the players.

Here:

-- SERVER SIDE 
  
function disableFireForHydra ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra 
         if not hasObjectPermissionTo (source, "function.banPlayer", false) then 
                 -- disable their guns 
                triggerClientEvent(source, "disableHydraGuns", source, theVehicle) 
          end 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra ) 
  
-- CLIENT SIDE 
addEvent("disableHydraGuns", true) 
addEventHandler("disableHydraGuns", root, 
function(veh) 
setVehicleGunsEnabled(veh, false) 
end) 

Should work, notice that there is server and client sides.

Posted

Hmm, then it's another wiki mistake.

function disableFireForHydra ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra 
         if hasObjectPermissionTo (source, "function.banPlayer", false) then 
                setVehicleGunsEnabled ( theVehicle, true) 
          else 
                 setVehicleGunsEnabled ( theVehicle, false) 
          end 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra ) 

Posted

This is like :

Server :

function disableFireForHydra ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra 
         if hasObjectPermissionTo (source, "function.banPlayer", false) then 
                setVehicleGunsEnabled ( theVehicle, true) 
          else 
                 setVehicleGunsEnabled ( theVehicle, false) 
          end 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra ) 

Client:

-- CLIENT SIDE 
addEvent("disableHydraGuns", true) 
addEventHandler("disableHydraGuns", root, 
function(veh) 
setVehicleGunsEnabled(veh, false) 
end) 

Meta:


Mby . I was done something wrong.

Posted (edited)

There is no need for client then.

And setVehicleGunsEnabled doesn't exist then.

Edited by Guest
Posted
addEventHandler("onVehicleEnter", root, 
    function(player) 
        if getElementModel(source) == 520 then 
            if hasObjectPermissionTo(player, "function.banPlayer", false) then 
                toggleControl(player, "vehicle_fire", true) 
            else 
                toggleControl(player, "vehicle_fire", false) 
            end 
        end 
    end 
) 
  
addEventHandler("onVehicleExit", root, 
    function(player) 
        toggleControl(player, "vehicle_fire", true) 
    end 
) 

Server side, whole code.

Posted

What happens?, if you are admin you will be able to shoot, if you are not you won't, maybe you are admin that's why.

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