AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [TF2] Inverted Speed Boost? (https://forums.alliedmods.net/showthread.php?t=306986)

ShadowMarioBR 04-21-2018 19:19

[TF2] Inverted Speed Boost?
 
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");
}
}

Drixevel 04-22-2018 15:00

Re: [TF2] Inverted Speed Boost?
 
Quote:

Originally Posted by ShadowMarioBR (Post 2588797)
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.

ShadowMarioBR 04-26-2018 12:52

Re: [TF2] Inverted Speed Boost?
 
But then i would need to create a timer for detecting when the speedboost was supposed to end, right?

Drixevel 04-27-2018 05:46

Re: [TF2] Inverted Speed Boost?
 
Quote:

Originally Posted by ShadowMarioBR (Post 2589545)
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

ShadowMarioBR 05-15-2018 12:54

Re: [TF2] Inverted Speed Boost?
 
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

Fyren 05-15-2018 13:13

Re: [TF2] Inverted Speed Boost?
 
Your Timer_SpeedDecrease function has the wrong prototype (parameters). You didn't provide the code for it, though.

ShadowMarioBR 05-15-2018 14:38

Re: [TF2] Inverted Speed Boost?
 
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;
}

ThatKidWhoGames 05-15-2018 15:18

Re: [TF2] Inverted Speed Boost?
 
Make it
PHP Code:

public Action Timer_SpeedDecrease(Handle timerany client


ShadowMarioBR 05-15-2018 21:30

Re: [TF2] Inverted Speed Boost?
 
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


All times are GMT -4. The time now is 09:47.

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