This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

TF2: Block sniper rifle and only allow huntsman


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Generic
New Member
Join Date: Aug 2009
Old 08-28-2009 , 20:33   TF2: Block sniper rifle and only allow huntsman
Reply With Quote #1

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
Generic is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 08-28-2009 , 20:59   Re: TF2: Block sniper rifle and only allow huntsman
Reply With Quote #2

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);
    }
}
retsam is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 08-28-2009 , 22:29   Re: TF2: Block sniper rifle and only allow huntsman
Reply With Quote #3

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.

Last edited by pheadxdll; 08-28-2009 at 22:39.
pheadxdll is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 08-28-2009 , 23:02   Re: TF2: Block sniper rifle and only allow huntsman
Reply With Quote #4

Oh really? So that sandman code would only work for removing sandman and equipping the normal bat, but not vise versa?
retsam is offline
Generic
New Member
Join Date: Aug 2009
Old 08-30-2009 , 21:33   Re: TF2: Block sniper rifle and only allow huntsman
Reply With Quote #5

Thanks, I'll try both of them and see what happens
Generic is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:58.


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