Script Change

Okay, so I recently found a script, that when you typed /destroy it destroyed the weapon you were holding. That script is:


hook.Add( "PlayerSay", "WeaponRemove", function( ply, text ) 
     if ( string.sub( text, 1, 8 ) == "/destroy" ) then 
     ply:StripWeapon( ply:GetActiveWeapon():GetClass() ) 
end
end)

Now this works fine, and I like it a lot but I have a handcuff mod https://scriptfodder.com/scripts/view/910/cuffs-handcuffs-and-hand-ties

and when your handcuffed, you can destroy it. any help?

Check if the active weapon is the handcuff, if not then run the rest.

Both the handcuff and being handcuffed is active and can be both deleted

Not sure if it’s considered leaking, it’s such a minor thing, but if so then I can’t really help you. Can you post the name of the weapon and/or entities. It should be weapon_handcuff or something. It would be in a /weapons/ or /entities/ folder inside of the addon. Do not post the code, only the name of the file.

weapon_cuff_police and weapon_cuff_elastic and weapon_leash_elastic all three I use, thanks so much!

Try this, I’m not home so I can’t really test it, but this might work. I don’t really like spoonfeeding, but I’m not good at explaining things.


local weaponremove_blacklist = {
    ["weapon_cuff_police"] = true,
    ["weapon_cuff_elastic"] = true,
    ["weapon_leash_elastic"] = true
}

hook.Add("PlayerSay", "WeaponRemove", function(ply, text) 
     if string.sub(text, 1, 8) == "/destroy" and not weaponremove_blacklist[ply:GetActiveWeapon():GetClass()] then 
        ply:StripWeapon(ply:GetActiveWeapon():GetClass()) 
    end
end)

Edit: Changed weaponremove_whitelist to weaponremove_blacklist to avoid confusion, should have made it that in the first place.

Also, using sub to find command names is worse than just checking equality since /destroywhatever will work

Nearly, but you’ll want to reverse your second check, this will allow every weapon except those in the whitelist to be removed with /destroy.

Isn’t that what he wants? He doesn’t want the person to be able to remove the handcuffs.

Yep that works thanks!

Shit no, it didn’t work don’t knwo why :confused:

Can you give some context of how it is not working? Going to guess if the player is arrested he can still do it? If so, then I can not really help you, I have not purchased the addon. You would have to go into the code and see how it is doing the arresting. I do not know the content creator personally but you can try to contact them, they might help you out, unlikely though.