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

[TF2] Respawn Effects (3.2, 07/15/2017)


Post New Thread Reply   
 
Thread Tools Display Modes
Mayor Gamer
Senior Member
Join Date: Nov 2012
Location: GetLocationOfUser(me);
Old 06-19-2016 , 13:03   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
Reply With Quote #11

Quote:
Originally Posted by ddhoward View Post
No, I mean the server operator who wants to have no respawn effect for regular users can make the cvar blank on his end.
Ah couldn't understand what you meant in the last post. Yeah, you can do that. Leaving the CVAR blank would just spawn no particle at all. Do the same with sound. Haven't tested it tho.
__________________

Last edited by Mayor Gamer; 06-24-2016 at 18:41. Reason: misspell :P
Mayor Gamer is offline
Smiley123
Junior Member
Join Date: Mar 2007
Old 06-22-2016 , 14:12   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
Reply With Quote #12

tempary thirdperson view for client as he/she respawns would be nice
Smiley123 is offline
Mayor Gamer
Senior Member
Join Date: Nov 2012
Location: GetLocationOfUser(me);
Old 06-24-2016 , 18:42   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
Reply With Quote #13

Quote:
Originally Posted by Smiley123 View Post
tempary thirdperson view for client as he/she respawns would be nice
Use a non-cheats thirdperson plugin like the one seen here.

Players who died having Third Person on will respawn with it on.
__________________
Mayor Gamer is offline
Smiley123
Junior Member
Join Date: Mar 2007
Old 07-01-2016 , 13:15   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
Reply With Quote #14

Quote:
Originally Posted by Mayor Gamer View Post
Use a non-cheats thirdperson plugin like the one seen here.

Players who died having Third Person on will respawn with it on.
Yes I understand but I mean temporary thirdperson only while they respawn so they can better see the effect (as in when one taunts)
Smiley123 is offline
Nanochip
Senior Member
Join Date: Jan 2014
Old 07-01-2016 , 13:29   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
Reply With Quote #15

Hey nice plugin!

Some tips:
  • Add a version convar so that you can track how many servers use your plugin and/or see what version they're using. Here's an example:
    PHP Code:
    #define PLUGIN_VERSION    "1.8"

    public Plugin:myinfo = {
        
    name        "Nanobot (Dodgeball Bot)",
        
    author        "Nanochip",
        
    description"Play dodgeball against a bot!",
        
    version    PLUGIN_VERSION,
        
    url            "https://forums.alliedmods.net/showthread.php?p=2286346"
    };

    public 
    OnPluginStart()
    {
        
    CreateConVar("sm_nanobot_version"PLUGIN_VERSION"Nanobot Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);

  • You don't need to define a MAX_CLIENTS variable, sourcemod already has these global variables: MAXCLIENTS and MAXPLAYERS.
    PHP Code:
    // Original
    new NewTeam[MAX_CLIENTS];

    //Replace it with:
    new NewTeam[MAXPLAYERS+1]; // the +1 is just for safety, accounting for a possible SourceTV or Replay (this seems to be a tradition here). 
  • The last tip would be to try and transition to the new 1.7 traditional syntax. It's not a big deal if you don't, I haven't transitioned my older plugins, however it looks more sleek & closer to java/c# syntax.
__________________

Last edited by Nanochip; 07-01-2016 at 13:42. Reason: Added some more tips :)
Nanochip is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-01-2016 , 14:48   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
Reply With Quote #16

You do NOT want to use FCVAR_REPLICATED on that cvar. The cvar doesn't exist on the client, it only exists on the server.

FCVAR_PLUGIN has never done anything, and using it will now cause warnings when you compile.

FCVAR_NOTIFY is only necessary if, for some reason, you want to inform all clients in the chat that you updated the plugin.

The only one that you actually might want to use is FCVAR_DONTRECORD and that's only if you're using AutoExecConfig in your plugin.

PHP Code:
new NewTeam[MAXPLAYERS+1]; // the +1 is just for safety, accounting for a possible SourceTV or Replay (this seems to be a tradition here). 
That is not why. This is important to do even on games that don't even have SourceTV or Replay.

Client indexes are numbered from 1 - MaxClients. MAXPLAYERS is the maximum value of MaxClients allowable by the engine; Sourcemod has this hardcoded to 65.

So let's assume that we have the biggest possible server size: a 65 slot server. The possible client indexes would be 1 - 65.

If we declare an array with an array index for each player, such as your NewTeam array, and we specify that the array size is 65... then the array indexes range from 0 - 64.

We have a problem. There are the same number of array slots as player slots, but the numbers don't match up! The last player to connect to the server and make it full would cause the plugin to generate runtime errors, as data would be written to NewTeam[65] which doesn't exist.

For this reason, we declare all arrays like that with a +1 at the end. This means that there is one array index ( [0] ) which is not used, but that's fine.
__________________

Last edited by ddhoward; 07-02-2016 at 15:18.
ddhoward is offline
Mayor Gamer
Senior Member
Join Date: Nov 2012
Location: GetLocationOfUser(me);
Old 07-01-2016 , 20:29   Re: [TF2] Respawn Effects (3.0, 06/18/2016)
Reply With Quote #17

Quote:
Originally Posted by Nanochip View Post
Hey nice plugin!

Some tips:
  • Add a version convar so that you can track how many servers use your plugin and/or see what version they're using. Here's an example:
    PHP Code:
    #define PLUGIN_VERSION    "1.8"

    public Plugin:myinfo = {
        
    name        "Nanobot (Dodgeball Bot)",
        
    author        "Nanochip",
        
    description"Play dodgeball against a bot!",
        
    version    PLUGIN_VERSION,
        
    url            "https://forums.alliedmods.net/showthread.php?p=2286346"
    };

    public 
    OnPluginStart()
    {
        
    CreateConVar("sm_nanobot_version"PLUGIN_VERSION"Nanobot Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);

  • You don't need to define a MAX_CLIENTS variable, sourcemod already has these global variables: MAXCLIENTS and MAXPLAYERS.
    PHP Code:
    // Original
    new NewTeam[MAX_CLIENTS];

    //Replace it with:
    new NewTeam[MAXPLAYERS+1]; // the +1 is just for safety, accounting for a possible SourceTV or Replay (this seems to be a tradition here). 
  • The last tip would be to try and transition to the new 1.7 traditional syntax. It's not a big deal if you don't, I haven't transitioned my older plugins, however it looks more sleek & closer to java/c# syntax.
Pushed a small update thanks to this. Thank you for pointing out!
__________________
Mayor Gamer is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-02-2016 , 02:24   Re: [TF2] Respawn Effects (3.1, 07/01/2016)
Reply With Quote #18

Here's some suggestions! Really like the concept of this plugin, and as I stated before, I love how you checked for donator status properly using an override rather than GetUserFlags + a cvar, or some other nonsense.
  • As I touched on in my previous post, those FCVAR flags should probably be removed from the version cvar. REPLICATED will just cause error messages on your clients. SPONLY doesn't do anything on purely server-side cvars, which is the only kind of cvar that Sourcemod can create. NOTIFY isn't necessary unless you actually want it printed in the chat that the version has changed (in the event of an update), and neither is DONTRECORD unless you're using AutoExecConfig().

    PHP Code:
    CreateConVar("sm_respawnsfx_version"PLUGIN_VERSION"Respawn Effects version. Don't touch this!");
    //or
    CreateConVar("sm_respawnsfx_version"PLUGIN_VERSION"Respawn Effects version. Don't touch this!"FCVAR_NOTIFY|FCVAR_DONTRECORD); 
    You may also want to look into hooking the cvar and having the plugin actually actively prevent changes to the value. It's up to you though.


  • The NewTeam array doesn't seem to do anything, so you can safely remove both its declaration at the top of the plugin, as well as its use at the end of the spawn hook.


  • Since the plugin is exclusively for TF2, you have the option of using TF2_GetClientTeam(), which returns a TFTeam value. This will allow you to not have to hard code team values.

    PHP Code:
    #define SPEC    1 //these three lines can all be removed
    #define TEAM1    2
    #define TEAM2    3

    //...

            
    switch (TF2_GetClientTeam(user))
            {
                case 
    TFTeam_Red
                {
                    
    AttachParticle (userhRedPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
                case 
    TFTeam_Blue
                {
                    
    AttachParticle (userhBluPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
            }

    //... 
    Also, apparently the spawn event is also called shortly after OnClientPutInServer, even though he hasn't actually spawned, so you might want to throw an IsPlayerAlive() check before the call to CheckCommandAccess().


  • When using timers on players or entities, you should not be passing its entity index. You should instead be passing the user ID (in the case of clients) or the entity reference (in the case of non-players.) This way, you gurantee that you run your timer's code (in this case, deleting the entity) on the correct entity, as entity indexes are reused. You already do a basic check by seeing that the classname is the same, which is a step in the right direction, but there's an easier, more efficient, and more guaranteed way to ensure that we don't delete the wrong entity.

    PHP Code:
            CreateTimer(timeDeleteParticlesEntIndexToEntRef(particle));

    //...

    public Action:DeleteParticles(Handle:timerany:particle)
    {
        if (
    EntRefToEntIndex(particle) != INVALID_ENT_REFERENCE)
        {
            
    AcceptEntityInput(particle"Kill");
        }

__________________

Last edited by ddhoward; 07-02-2016 at 02:32.
ddhoward is offline
Mayor Gamer
Senior Member
Join Date: Nov 2012
Location: GetLocationOfUser(me);
Old 07-02-2016 , 12:11   Re: [TF2] Respawn Effects (3.1, 07/01/2016)
Reply With Quote #19

Quote:
Originally Posted by ddhoward View Post
Here's some suggestions! Really like the concept of this plugin, and as I stated before, I love how you checked for donator status properly using an override rather than GetUserFlags + a cvar, or some other nonsense.
  • As I touched on in my previous post, those FCVAR flags should probably be removed from the version cvar. REPLICATED will just cause error messages on your clients. SPONLY doesn't do anything on purely server-side cvars, which is the only kind of cvar that Sourcemod can create. NOTIFY isn't necessary unless you actually want it printed in the chat that the version has changed (in the event of an update), and neither is DONTRECORD unless you're using AutoExecConfig().

    PHP Code:
    CreateConVar("sm_respawnsfx_version"PLUGIN_VERSION"Respawn Effects version. Don't touch this!");
    //or
    CreateConVar("sm_respawnsfx_version"PLUGIN_VERSION"Respawn Effects version. Don't touch this!"FCVAR_NOTIFY|FCVAR_DONTRECORD); 
    You may also want to look into hooking the cvar and having the plugin actually actively prevent changes to the value. It's up to you though.


  • The NewTeam array doesn't seem to do anything, so you can safely remove both its declaration at the top of the plugin, as well as its use at the end of the spawn hook.


  • Since the plugin is exclusively for TF2, you have the option of using TF2_GetClientTeam(), which returns a TFTeam value. This will allow you to not have to hard code team values.

    PHP Code:
    #define SPEC    1 //these three lines can all be removed
    #define TEAM1    2
    #define TEAM2    3

    //...

            
    switch (TF2_GetClientTeam(user))
            {
                case 
    TFTeam_Red
                {
                    
    AttachParticle (userhRedPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
                case 
    TFTeam_Blue
                {
                    
    AttachParticle (userhBluPart2.5);
                    
    EmitSoundToClient(userhSound);
                }
            }

    //... 
    Also, apparently the spawn event is also called shortly after OnClientPutInServer, even though he hasn't actually spawned, so you might want to throw an IsPlayerAlive() check before the call to CheckCommandAccess().


  • When using timers on players or entities, you should not be passing its entity index. You should instead be passing the user ID (in the case of clients) or the entity reference (in the case of non-players.) This way, you gurantee that you run your timer's code (in this case, deleting the entity) on the correct entity, as entity indexes are reused. You already do a basic check by seeing that the classname is the same, which is a step in the right direction, but there's an easier, more efficient, and more guaranteed way to ensure that we don't delete the wrong entity.

    PHP Code:
            CreateTimer(timeDeleteParticlesEntIndexToEntRef(particle));

    //...

    public Action:DeleteParticles(Handle:timerany:particle)
    {
        if (
    EntRefToEntIndex(particle) != INVALID_ENT_REFERENCE)
        {
            
    AcceptEntityInput(particle"Kill");
        }

Pushed another update for this. Thanks a lot ddhoward! Helped me a lot ;)
__________________
Mayor Gamer is offline
MaloModo
Veteran Member
Join Date: Aug 2008
Old 07-12-2016 , 21:34   Re: [TF2] Respawn Effects (3.1, 07/02/2016)
Reply With Quote #20

Hey there...just testing out your plugin...works as advertised with donator sounds/effects etc.

It would be cool if people could choose from a list of particle effects and sounds that they could set themselves. Further to this, if possible, having a config file that the server operator could edit to add/create "the list".

Cheers.
MaloModo 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 15:46.


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