AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Make weapons not dropable (https://forums.alliedmods.net/showthread.php?t=310463)

Porcellian 09-04-2018 15:05

Make weapons not dropable
 
Hello,

I am running a gamemode that doesn't really allow weapons to be dropped. When a player dies, it's supposed to drop like usually. But how can I make it impossible to press "g" to drop a weapon?

Porcellian 09-04-2018 15:13

Re: Make weapons not dropable
 
+ Hide the one who is talking in voice chat, the voice chat should work, but you shouldn't be able to see the one talking.

Ilusion9 09-04-2018 15:38

Re: Make weapons not dropable
 
PHP Code:


    SDKHook
(clientSDKHook_WeaponDropOnWeaponDrop);

    public 
Action OnWeaponDrop(int clientint weapon)
    {
        return 
Plugin_Stop;
    } 


Porcellian 09-04-2018 17:19

Re: Make weapons not dropable
 
I got it working, but two problems.

First, I want the weapon to be dropped on death. But not if pressing to drop it, with e.g "g".

Also, it's strange but the gun started acting weird after I tried my script.

Quote:

#include <sdkhooks>
#include <sourcemod>

public OnPluginStart()
{
for (new i= 1; i<= MaxClients; i++)
{
if (IsClientInGame(i))
{
SDKHook(i, SDKHook_WeaponDrop, OnWeaponDrop);
}
}
}

public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponDrop, OnWeaponDrop);
}

public Action OnWeaponDrop(int client, int weapon)
{
return Plugin_Stop;
}

Neuro Toxin 09-04-2018 18:56

Re: Make weapons not dropable
 
Check IsPlayerAlive in the weapon drop callback.

If that doesnt work. Hook weapon drop on spawn and unhook on death via the takedamagealive foward.

Porcellian 09-05-2018 03:36

Re: Make weapons not dropable
 
Oh yea, stupid me. That should work.

However, when I try to drop the weapon with my script, it starts acting weird. The animations of the gun stops showing up. I can still shoot and reload, but it looks weird. Why is that?

Neuro Toxin 09-05-2018 04:47

Re: Make weapons not dropable
 
Probably prediction errors.

Try on drop. Wait one frame. Equip the weapon again.

Ilusion9 09-05-2018 09:53

Re: Make weapons not dropable
 
PHP Code:


mp_death_drop_gun 0 

Hook player_hurt, if hp < 1 then loop through client weapons and drop them.

Porcellian 09-05-2018 12:56

Re: Make weapons not dropable
 
Sorry, I don't know how to do all this. I am new to this. Can someone help me a bit with the piece of code?

Powerlord 09-05-2018 18:30

Re: Make weapons not dropable
 
Quote:

Originally Posted by Porcellian (Post 2613715)
Hello,

I am running a gamemode that doesn't really allow weapons to be dropped. When a player dies, it's supposed to drop like usually. But how can I make it impossible to press "g" to drop a weapon?

Please don't make us search your post history to figure out which game you're talking about, because it actually does make a difference in this case.


All times are GMT -4. The time now is 17:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.