AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   TF2: Block sniper rifle and only allow huntsman (https://forums.alliedmods.net/showthread.php?t=101948)

Generic 08-28-2009 20:33

TF2: Block sniper rifle and only allow huntsman
 
Hi,

I recently started a server with the idea of only allowing people to use the sniper's huntsman. I've been able to use class restriction's to only allow people to go sniper, but I can't figure out how to only let the sniper choose the huntsman.

If there's already a way to do this apologize. I tried searching extensively and have come up with nothing so far.

Anyone have any ideas?

Thanks

retsam 08-28-2009 20:59

Re: TF2: Block sniper rifle and only allow huntsman
 
something like this...but youd have to edit this. This is for sandman removal...

Code:

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
new Handle:gameConf;
new Handle:giveNamedItem;
new Handle:weaponEquip;
new Handle:g_hEnabled = INVALID_HANDLE;
new bool:g_bEnabled = true;
public OnPluginStart() {
    gameConf = LoadGameConfigFile("sandman.games");
    StartPrepSDKCall(SDKCall_Player);
    PrepSDKCall_SetFromConf(gameConf, SDKConf_Virtual, "GiveNamedItem");
    PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
    PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Plain);
    giveNamedItem = EndPrepSDKCall();
    StartPrepSDKCall(SDKCall_Player);
    PrepSDKCall_SetFromConf(gameConf, SDKConf_Virtual, "WeaponEquip");
    PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
    weaponEquip = EndPrepSDKCall();
    g_hEnabled = CreateConVar("sm_nosandman", "1", "Enable no sandman", FCVAR_PLUGIN|FCVAR_NOTIFY);
    HookConVarChange(g_hEnabled, Cvar_enabled);
}
public OnMapStart() {
    CreateTimer(5.0, WpnCheck);
}
public OnConfigsEiecuted() {
    g_bEnabled = GetConVarBool(g_hEnabled);
}
public Cvar_enabled(Handle:convar, const String:oldValue[], const String:newValue[]) {
    g_bEnabled = GetConVarBool(g_hEnabled);
    if(g_bEnabled) {
        WpnCheck(INVALID_HANDLE);
    }
}
public Action:WpnCheck(Handle:timer) {
    new ent;
    decl String:wpn[64];
    for(new i=1;i<=MaxClients;i++) {
        if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i)) {
            if((ent = GetPlayerWeaponSlot(i, 2))!=-1) {
                GetEdictClassname(ent, wpn, sizeof(wpn));
                if(StrEqual(wpn, "tf_weapon_bat_wood")) {
                    TF2_RemoveWeaponSlot(i, 2);
                    new entity = SDKCall(giveNamedItem, i, "tf_weapon_bat", 0, 0);
                    SDKCall(weaponEquip, i, entity);
                    PrintToChat(i, "Your sandman has been removed.");
                }
            }
        }
    }
    if(g_bEnabled) {
        CreateTimer(5.0, WpnCheck);
    }
}


pheadxdll 08-28-2009 22:29

Re: TF2: Block sniper rifle and only allow huntsman
 
Take a look at the crabmod: http://forums.alliedmods.net/showthread.php?p=873392 . You can't force a player to put on an unlockable weapon. What that mod does is look at the player slot and check to see if its a huntsman. If its not, it disables that slot. You'd have to put a message up and tell the user to switch to huntsman.

retsam 08-28-2009 23:02

Re: TF2: Block sniper rifle and only allow huntsman
 
Oh really? So that sandman code would only work for removing sandman and equipping the normal bat, but not vise versa?

Generic 08-30-2009 21:33

Re: TF2: Block sniper rifle and only allow huntsman
 
Thanks, I'll try both of them and see what happens


All times are GMT -4. The time now is 03:55.

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