AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [TF2] Any idea on making a addcond plugin that reactivates if you spawn? (https://forums.alliedmods.net/showthread.php?t=279363)

StormishJustice 02-20-2016 17:13

[TF2] Any idea on making a addcond plugin that reactivates if you spawn?
 
I'm thinking of making a plugin that allows you to use addcond and it reactivates when you spawn for like 1 or 2 seconds (something like that) but the problem is, is it possible? since conditions disappear upon death and never return back unless you enter the condition or it triggers automatically, so that's what i'm worried of but i think it can be possible, so does it work if i added all this with PlayerIsAlive or apparently it won't work? if not, then like is there a code or an example of how that works?

Thanks

nosoop 02-20-2016 21:45

Re: [TF2] Any idea on making a addcond plugin that reactivates if you spawn?
 
Hook the player_spawn event to find out when the player spawns, then use TF2_AddCondition() to apply the effect.

If you want players to configure which condition they spawn with, then you probably want to create some sort of command like sm_spawncond, parse their desired condition, and store it in a plugin-scoped array:

Code:

TFCond g_DesiredConditions[MAXPLAYERS+1];

StormishJustice 02-21-2016 09:53

Re: [TF2] Any idea on making a addcond plugin that reactivates if you spawn?
 
Quote:

Originally Posted by nosoop (Post 2395142)
Hook the player_spawn event to find out when the player spawns, then use TF2_AddCondition() to apply the effect.

If you want players to configure which condition they spawn with, then you probably want to create some sort of command like sm_spawncond, parse their desired condition, and store it in a plugin-scoped array:

Code:

TFCond g_DesiredConditions[MAXPLAYERS+1];

Oh thanks, i just did it like this but i'm not really sure because it gave me a tag mismatch on that line.
PHP Code:

public void event_PlayerSpawn(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
int iCondition;
    
    
SetEntProp(clientProp_Send"m_nPlayerCond"g_DesiredConditions[client]);
    
g_DesiredConditions[client] = iCondition;


oh and i also hooked the event inside the spawncond command.

nosoop 02-21-2016 12:51

Re: [TF2] Any idea on making a addcond plugin that reactivates if you spawn?
 
Quote:

Originally Posted by StormishJustice (Post 2395287)
Oh thanks, i just did it like this but i'm not really sure because it gave me a tag mismatch on that line.

[...]

oh and i also hooked the event inside the spawncond command.

Coo'.
You're getting a mismatch because the tag is TFCond and not int:

Code:

TFCond iCondition;
I strongly recommend using TF2_AddCondition instead of modifying entity properties; the former has a greater chance of being future-proof, plus you can pass a duration value to it.

Also, the HookEvent() function would probably be better being called on plugin start just once; the event hook callback is fired on all matching events and not on any particular client (as SDKHooks does), so you'll need to make sure the client actually has a condition set.

On that note, there also isn't a default invalid value for TFCond, so use a nonexistent (e.g., negative) value for TFCond and check it before applying a condition to your players.

Powerlord 02-22-2016 10:57

Re: [TF2] Any idea on making a addcond plugin that reactivates if you spawn?
 
Quote:

Originally Posted by nosoop (Post 2395353)
Coo'.
You're getting a mismatch because the tag is TFCond and not int:

Code:

TFCond iCondition;
I strongly recommend using TF2_AddCondition instead of modifying entity properties; the former has a greater chance of being future-proof, plus you can pass a duration value to it.

Also, the HookEvent() function would probably be better being called on plugin start just once; the event hook callback is fired on all matching events and not on any particular client (as SDKHooks does), so you'll need to make sure the client actually has a condition set.

On that note, there also isn't a default invalid value for TFCond, so use a nonexistent (e.g., negative) value for TFCond and check it before applying a condition to your players.

It's not just that, but m_nPlayerCond is (last I checked) one of 3 bitfields that Valve uses to store conditions in. Which also means that just assigning a value to it is inherently wrong.


All times are GMT -4. The time now is 21:11.

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