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

Solved [TF2] Inverted Speed Boost?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ShadowMarioBR
Member
Join Date: Feb 2018
Old 04-21-2018 , 19:19   [TF2] Inverted Speed Boost?
Reply With Quote #1

This is my first script, and it is not working properly, it should add the attribute "move speed penalty" while the player have an speed boost (cond), but it applies the effect only when the cond ends, help!
Quote:
#pragma semicolon 1

#include <sourcemod>
#include <tf2>
#include <tf2attributes>

public TF2_OnConditionAdded(client, TFCond:condition)
{
if (condition == TFCond_SpeedBuffAlly)
{
TF2Attrib_SetByName(client, "move speed penalty", 0.5);
}
}

public TF2_OnConditionRemoved(client, TFCond:condition)
{
new Address:attrib = Address_Null;
if (condition != TFCond_SpeedBuffAlly && (attrib = TF2Attrib_GetByName(client, "move speed penalty")) != Address_Null)
{
TF2Attrib_RemoveByName(client, "move speed penalty");
}
}

Last edited by ShadowMarioBR; 06-17-2018 at 18:06. Reason: Solved it kind of by myself
ShadowMarioBR is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 04-22-2018 , 15:00   Re: [TF2] Inverted Speed Boost?
Reply With Quote #2

Quote:
Originally Posted by ShadowMarioBR View Post
This is my first script, and it is not working properly, it should add the attribute "move speed penalty" while the player have an speed boost (cond), but it applies the effect only when the cond ends, help!
https://github.com/ShadersAllen/Sour...misc.inc#L3708

Apply the speedbuffally condition for 0.0 seconds so it properly updates your speed.
Drixevel is offline
ShadowMarioBR
Member
Join Date: Feb 2018
Old 04-26-2018 , 12:52   Re: [TF2] Inverted Speed Boost?
Reply With Quote #3

But then i would need to create a timer for detecting when the speedboost was supposed to end, right?
ShadowMarioBR is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 04-27-2018 , 05:46   Re: [TF2] Inverted Speed Boost?
Reply With Quote #4

Quote:
Originally Posted by ShadowMarioBR View Post
But then i would need to create a timer for detecting when the speedboost was supposed to end, right?
If that's what you need to do, sure. lol
Drixevel is offline
ShadowMarioBR
Member
Join Date: Feb 2018
Old 05-15-2018 , 12:54   Re: [TF2] Inverted Speed Boost?
Reply With Quote #5

Ok, now it keeps giving an error
Quote:
public Plugin:myinfo = {
name = PLUGIN_NAME,
author = PLUGIN_AUTHOR,
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = PLUGIN_CONTACT
};

new Handle:SpeedDecrease[MAXPLAYERS+1];

public void TF2_OnConditionAdded(client, TFCond:condition)
{
if (condition == TFCond_SpeedBuffAlly && TF2_GetPlayerClass(client)==TFClass_Scout)
{
TF2_RemoveCondition(client, TFCond_SpeedBuffAlly);
TF2Attrib_SetByName(client, "move speed penalty", 0.737);
TF2_AddCondition(client, TFCond_SpeedBuffAlly, 0.01);
SpeedDecrease[client] = CreateTimer(2.0, Timer_SpeedDecrease, client);
}
Error 100 (on line 31): function prototypes do not match
Line 31 is the "CreateTimer" line

Last edited by ShadowMarioBR; 05-15-2018 at 12:54.
ShadowMarioBR is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 05-15-2018 , 13:13   Re: [TF2] Inverted Speed Boost?
Reply With Quote #6

Your Timer_SpeedDecrease function has the wrong prototype (parameters). You didn't provide the code for it, though.
Fyren is offline
ShadowMarioBR
Member
Join Date: Feb 2018
Old 05-15-2018 , 14:38   Re: [TF2] Inverted Speed Boost?
Reply With Quote #7

Quote:
public Action Timer_SpeedDecrease(client, Handle:timer)
{
TF2Attrib_RemoveByName(client, "move speed penalty");
TF2_AddCondition(client, TFCond_SpeedBuffAlly, 0.01);
KillTimer(SpeedDecrease[client]);
return Plugin_Continue;
}
ShadowMarioBR is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-15-2018 , 15:18   Re: [TF2] Inverted Speed Boost?
Reply With Quote #8

Make it
PHP Code:
public Action Timer_SpeedDecrease(Handle timerany client

Last edited by ThatKidWhoGames; 05-15-2018 at 15:20.
ThatKidWhoGames is offline
ShadowMarioBR
Member
Join Date: Feb 2018
Old 05-15-2018 , 21:30   Re: [TF2] Inverted Speed Boost?
Reply With Quote #9

Well, now it's partially working, but it's lagging all the servers and spamming the console with errors
Quote:
L 05/15/2018 - 22:28:42: [SM] Exception reported: TF2Attrib_RemoveByName: Invalid entity index 10 passed
L 05/15/2018 - 22:28:42: [SM] Blaming: tf2attributes.smx
L 05/15/2018 - 22:28:42: [SM] Call stack trace:
L 05/15/2018 - 22:28:42: [SM] [0] ThrowNativeError
L 05/15/2018 - 22:28:42: [SM] [1] Line 514, /home/forums/content/files/8/4/3/0/4/116848.attach::Native_Remove
L 05/15/2018 - 22:28:42: [SM] [3] TF2Attrib_RemoveByName
L 05/15/2018 - 22:28:42: [SM] [4] Line 65, C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\addons\sourcemod\scripting\test.sp::Time r_SpeedDecrease
ShadowMarioBR is offline
Reply


Thread Tools
Display Modes

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 15:08.


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