Raised This Month: $51 Target: $400
 12% 

[REQ][TF2] Limit Sentries to Level 1


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Reconunit415
Junior Member
Join Date: Jul 2008
Old 11-03-2010 , 00:32   [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #1

Recreation of the thread I posted earlier last week. Couldn't change the title appropriately.

Is there a script to, or could someone create one to limit sentries to level 1, but possibly not the rest of the buildings? If the buildings get nerfed as well, that's doable, but I need sentries in a moderated form.

Thanks

EDIT: For anyone referencing this thread for the same solution: http://forums.alliedmods.net/showpos...7&postcount=17

Last edited by Reconunit415; 11-06-2010 at 14:01.
Reconunit415 is offline
bobbobagan
SourceMod Donor
Join Date: May 2007
Location: New Zealand
Old 11-03-2010 , 01:42   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #2

Although I have never tried this, you could try changing MaxUpgradeLevel in /tf/scripts/objects.txt and then restarting the server.

By default it is 0, try changing it to 1. Make sure you don't have -autoupdate in the servers command line.
__________________
bobbobagan is offline
Send a message via Skype™ to bobbobagan
Swixel
Senior Member
Join Date: Jul 2010
Location: Sydney, Australia
Old 11-03-2010 , 02:02   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #3

What bobbobagan said, or try this: https://forums.alliedmods.net/showthread.php?t=133372

Just change iMaxUpgradeLevel

It's the same thing, it's just that Wazz's snippet is used in C++/an extension so you can turn it on and off without restarting.
Swixel is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-03-2010 , 02:11   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #4

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>

public Plugin:myinfo =
{
    
name "Block Sentry Upgrades",
    
author "bl4nk",
    
description "Makes it so sentries cannot be upgraded past level 1",
    
version "1.0.0",
    
url "http://forums.alliedmods.net/"
};

enum {
    
TFObject_Dispenser 0,
    
TFObject_Teleporter,
    
TFObject_Sentry
}

new 
g_iSentryIndex[MAXPLAYERS+1];

public 
OnPluginStart() {
    
HookEvent("player_builtobject"Event_ObjectBuilt);
    
HookEvent("object_destroyed"Event_ObjectDestroyed);
    
HookEvent("teamplay_round_start"Event_RoundStart);
    
HookEvent("player_changeclass"Event_ChangeClass);
}

public 
Event_ObjectBuilt(Handle:hEvent, const String:szEventName[], bool:bDontBroadcast) {
    new 
iObject GetEventInt(hEvent"object");
    if (
iObject == TFObject_Sentry) {
        new 
iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
        new 
iIndex GetEventInt(hEvent"index");
        
        
g_iSentryIndex[iClient] = iIndex;
    }
}

public 
Event_ObjectDestroyed(Handle:hEvent, const String:szEventName[], bool:bDontBroadcast) {
    new 
iObject GetEventInt(hEvent"objecttype");
    if (
iObject == TFObject_Sentry) {
        new 
iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
        
        
g_iSentryIndex[iClient] = 0;
    }
}

public 
Event_RoundStart(Handle:hEvent, const String:szEventName[], bool:bDontBroadcast) {
    for (new 
iClient 1iClient <= MaxClientsiClient++) {
        
g_iSentryIndex[iClient] = 0;
    }
}

public 
Event_ChangeClass(Handle:hEvent, const String:szEventName[], bool:bDontBroadcast) {
    new 
iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
    if (
g_iSentryIndex[iClient] > 0) {
        
g_iSentryIndex[iClient] = 0;
    }
}

public 
OnClientDisconnect(iClient) {
    
g_iSentryIndex[iClient] = 0;
}

public 
OnGameFrame() {
    for (new 
iClient 1iClient <= MaxClientsiClient++) {
        if (
g_iSentryIndex[iClient] > 0) {
            
SetEntProp(g_iSentryIndex[iClient], Prop_Send"m_iUpgradeMetal"0);
        }
    }

Requires SDKHooks. There's probably a better way to do it than OnGameFrame (I tested Think and PostThink hooks - both didn't fire as desired), but this method works for me. Engineers will lose metal when trying to upgrade their sentries, as I haven't found a reliable way to detect when they've hit their sentry to give it back.
bl4nk is offline
Swixel
Senior Member
Join Date: Jul 2010
Location: Sydney, Australia
Old 11-03-2010 , 02:46   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #5

Quote:
Originally Posted by bl4nk View Post
PHP Code:
<code was here
Requires SDKHooks. There's probably a better way to do it than OnGameFrame (I tested Think and PostThink hooks - both didn't fire as desired), but this method works for me. Engineers will lose metal when trying to upgrade their sentries, as I haven't found a reliable way to detect when they've hit their sentry to give it back.
Won't that break repair? o.O

EDIT: Or it might be repair then upgrade, I can never remember ... great engineer I am >_>

Last edited by Swixel; 11-03-2010 at 02:50.
Swixel is offline
Reconunit415
Junior Member
Join Date: Jul 2008
Old 11-03-2010 , 02:47   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #6

Quote:
Originally Posted by bl4nk View Post
Requires SDKHooks. There's probably a better way to do it than OnGameFrame (I tested Think and PostThink hooks - both didn't fire as desired), but this method works for me. Engineers will lose metal when trying to upgrade their sentries, as I haven't found a reliable way to detect when they've hit their sentry to give it back.
Thankyou! I am not the most experienced with Sourcemod, so forgive me for asking a stupid question. Where can I grab the sdkhooks.inc?
Reconunit415 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-03-2010 , 03:00   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #7

Quote:
Originally Posted by Reconunit415 View Post
Thankyou! I am not the most experienced with Sourcemod, so forgive me for asking a stupid question. Where can I grab the sdkhooks.inc?
http://forums.alliedmods.net/showthread.php?t=106748
bl4nk is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-03-2010 , 03:01   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #8

Quote:
Originally Posted by Swixel View Post
Won't that break repair? o.O
Nope, the sentry health isn't affected by the plugin, just the amount of metal put towards upgrading it.
bl4nk is offline
Swixel
Senior Member
Join Date: Jul 2010
Location: Sydney, Australia
Old 11-03-2010 , 03:18   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #9

Quote:
Originally Posted by bl4nk View Post
Nope, the sentry health isn't affected by the plugin, just the amount of metal put towards upgrading it.
I'm just checking that repair happens *before* upgrade. The issue would be you'd not be able to repair if upgrade came first (fairly sure it's repair then upgrade, now that I think about it). Anyway, I can't remember the order, so I was just checking.
Swixel is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 11-03-2010 , 11:20   Re: [REQ][TF2] Limit Sentries to Level 1
Reply With Quote #10

Would it be better to just use a timer instead? It takes X swings to upgrade the turret which translates into Y seconds total hammering. Then you just set the timer to Y/2 and repeat. Got to be much better than doing that loop every game frame.
Thraka 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 17:46.


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