Jump to content

help with blocking weapons/vehicles


5150

Recommended Posts

hi, i have an issue and i wanna see if the people of the internet can help.... i was wondering if someone could make me a script that blocks:

minigun

rocket launcher

rocket launcher (HS)

desert eagle

grenade combat shotgun

country rifle

tec9

mp5

ak47

i am new to scripting still, and it would e really awesome having someone help. also, please tell me where i place the script after its made.

is it the same process for vehicles too? ive looked in lots of places and its hard to find a simple answer

Link to comment
go go go
toggleControl 
onClientPlayerWeaponSwitch 

Instead of being a "know-it-all" why don't you help him, give him an example of how to do what he requested when your "Scripting skill is 92%"?

hi, i have an issue and i wanna see if the people of the internet can help.... i was wondering if someone could make me a script that blocks:

minigun

rocket launcher

rocket launcher (HS)

desert eagle

grenade combat shotgun

country rifle

tec9

mp5

ak47

i am new to scripting still, and it would e really awesome having someone help. also, please tell me where i place the script after its made.

is it the same process for vehicles too? ive looked in lots of places and its hard to find a simple answer

Anyway here, this should block all of the weapons you requested (Taken from the Wiki, i just added some more IDs)

WeaponID = { 
    [38] = true,    --Minigun 
    [35] = true,    --Rocket Launcher 
    [36] = true,    --HS Rocker Launcher 
    [24] = true,    --Deagle 
    [16] = true,    --Grenade 
    [27] = true,    --Combat Shotgun 
    [33] = true,    --Country Rifle 
    [29] = true,    --MP5 
    [32] = true,    --Tec9 
    [30] = true,    --AK-47 
} 
  
function blockWeaponsOnSwitch (previousWeaponID, currentWeaponID) 
    if WeaponID[currentWeaponID] then 
        toggleControl(source, "aim_weapon", false) 
        toggleControl(source, "fire", false) 
    else 
        toggleControl(source, "aim_weapon", true) 
        toggleControl(source, "fire", true) 
    end 
end 
addEventHandler("onPlayerWeaponSwitch", root, blockWeaponsOnSwitch) 

Make sure to place this script in a SERVER-SIDE script/file

I could not find a way to block vehicles, do you want to block vehicles from being spawned, or block them from being entered?

Link to comment
go go go
toggleControl 
onClientPlayerWeaponSwitch 

Instead of being a "know-it-all" why don't you help him, give him an example of how to do what he requested when your "Scripting skill is 92%"?

hi, i have an issue and i wanna see if the people of the internet can help.... i was wondering if someone could make me a script that blocks:

minigun

rocket launcher

rocket launcher (HS)

desert eagle

grenade combat shotgun

country rifle

tec9

mp5

ak47

i am new to scripting still, and it would e really awesome having someone help. also, please tell me where i place the script after its made.

is it the same process for vehicles too? ive looked in lots of places and its hard to find a simple answer

Anyway here, this should block all of the weapons you requested (Taken from the Wiki, i just added some more IDs)

WeaponID = { 
    [38] = true,    --Minigun 
    [35] = true,    --Rocket Launcher 
    [36] = true,    --HS Rocker Launcher 
    [24] = true,    --Deagle 
    [16] = true,    --Grenade 
    [27] = true,    --Combat Shotgun 
    [33] = true,    --Country Rifle 
    [29] = true,    --MP5 
    [32] = true,    --Tec9 
    [30] = true,    --AK-47 
} 
  
function blockWeaponsOnSwitch (previousWeaponID, currentWeaponID) 
    if WeaponID[currentWeaponID] then 
        toggleControl(source, "aim_weapon", false) 
        toggleControl(source, "fire", false) 
    else 
        toggleControl(source, "aim_weapon", true) 
        toggleControl(source, "fire", true) 
    end 
end 
addEventHandler("onPlayerWeaponSwitch", root, blockWeaponsOnSwitch) 

Make sure to place this script in a SERVER-SIDE script/file

I could not find a way to block vehicles, do you want to block vehicles from being spawned, or block them from being entered?

i want then to only be spawned by admins. i want them enterable if they are spawned though. so basically i want a block on spawning them. and by the way thanks for the script. i add it in like any other resource right? server/mods/deathmatch/resources?

Link to comment
go go go
toggleControl 
onClientPlayerWeaponSwitch 

Instead of being a "know-it-all" why don't you help him, give him an example of how to do what he requested when your "Scripting skill is 92%"?

hi, i have an issue and i wanna see if the people of the internet can help.... i was wondering if someone could make me a script that blocks:

minigun

rocket launcher

rocket launcher (HS)

desert eagle

grenade combat shotgun

country rifle

tec9

mp5

ak47

i am new to scripting still, and it would e really awesome having someone help. also, please tell me where i place the script after its made.

is it the same process for vehicles too? ive looked in lots of places and its hard to find a simple answer

Anyway here, this should block all of the weapons you requested (Taken from the Wiki, i just added some more IDs)

WeaponID = { 
    [38] = true,    --Minigun 
    [35] = true,    --Rocket Launcher 
    [36] = true,    --HS Rocker Launcher 
    [24] = true,    --Deagle 
    [16] = true,    --Grenade 
    [27] = true,    --Combat Shotgun 
    [33] = true,    --Country Rifle 
    [29] = true,    --MP5 
    [32] = true,    --Tec9 
    [30] = true,    --AK-47 
} 
  
function blockWeaponsOnSwitch (previousWeaponID, currentWeaponID) 
    if WeaponID[currentWeaponID] then 
        toggleControl(source, "aim_weapon", false) 
        toggleControl(source, "fire", false) 
    else 
        toggleControl(source, "aim_weapon", true) 
        toggleControl(source, "fire", true) 
    end 
end 
addEventHandler("onPlayerWeaponSwitch", root, blockWeaponsOnSwitch) 

Make sure to place this script in a SERVER-SIDE script/file

I could not find a way to block vehicles, do you want to block vehicles from being spawned, or block them from being entered?

i want then to only be spawned by admins. i want them enterable if they are spawned though. so basically i want a block on spawning them. and by the way thanks for the script. i add it in like any other resource right? server/mods/deathmatch/resources?

Yes, but make sure that resource is Server-Sided in the meta.xml file

EDIT: This should do the trick for you

function restrictVehicleSpawn (player, command, id) 
    local accountName = getAccountName(getPlayerAccount(player)) 
    if not isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) then 
        outputChatBox("This feature is restricted to Admins only", player, 255, 0, 0) 
    else 
        if not id or not tonumber(id) then 
            outputChatBox("Usage: /createveh ") 
            return false 
        end 
     
        local id = math.floor(tonumber(id)) 
        --Yet these 2 IDs do not exist, i just used them so that you can spawn the vehicle ID: 400 and 611 
        if id and id > 399 and id < 612 then 
            local x, y, z = getElementPosition(player) 
            local _, _, rz = getElementRotation(player) 
            vehicle = createVehicle(id, x, y, z, _, _, rz) 
            setVehicleColor(vehicle, 255, 255, 255) 
            warpPedIntoVehicle(player, vehicle) 
            outputChatBox("You have created a "..getVehicleNameFromModel(id).." (ID: "..id..")", player, 0, 255, 0) 
        else 
            outputChatBox("Invalid ID Entered, use IDs from 400 to 611", player, 255, 0, 0) 
        end 
    end 
end 
addCommandHandler("createveh", restrictVehicleSpawn) 
  
function restrictVehicleEntering (player) 
    local accountName = getAccountName(getPlayerAccount(player)) 
    if not isElement(vehicle) then return end 
    if not isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) then 
        outputChatBox("You cannot enter this vehicle", player, 255, 0, 0) 
        cancelEvent() 
    end 
end 
addEventHandler("onVehicleStartEnter", root, restrictVehicleEntering) 

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