AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: CS Team Changer Ultimate [avoids crashes in aggressive changes] (https://forums.alliedmods.net/showthread.php?t=163555)

claudiuhks 07-31-2011 15:15

Module: CS Team Changer Ultimate [avoids crashes in aggressive changes]
 
1 Attachment(s)

- Counter-Strike Team Changer -


Download
View CPP file

I see that all plugins that change the teams excessively contain delay to avoid crashes. Native get_user_team is not used because of receiving wrong values and there are tasks with TeamInfo message.

Using this extension you may change the teams without any crash, indifferently you are using an aggressive changing type or not!

Also, this extension updates the AMX Mod X team indexes at clients then you will be able to use get_user_team native without problems, it will return fair values.

The difference between this and CStrike module is here (42).

An example is listed below.

PHP Code:

static iPlayers32 ], iNumiiPlayer;
get_playersiPlayersiNum );

for( 
0iNumi++ )
{
     
iPlayer iPlayers];

     switch( 
get_user_teamiPlayer ) )
     {
           case 
_:CSTEAM_TERRORISTcs_set_teamiPlayerCSTEAM_CT );
           case 
_:CSTEAM_CTcs_set_teamiPlayerCSTEAM_TERRORIST );
     }

     
// If you will use again this function, get_user_team native will give you a fair result!
     // The players will be transfering from a team to other without problems.




It is tested, it works perfectly with thirty two players. It changes sixteen players from Terrorists to Counter-terrorists and sixteen players from Counter-terrorists to Terrorists in the same time without any headaches instead of CStrike extension that crashes the server.

The header file is the one listed below.

PHP Code:

/**
 * Counter-Strike Team Changer
 * by Hattrick (Claudiu HKS)
 */

#if defined _cs_team_changer_included
  #endinput
#endif

#define _cs_team_changer_included

#if AMXX_VERSION_NUM >= 175
  #pragma reqlib cs_team_changer

  #if !defined AMXMODX_NOAUTOLOAD
    #pragma loadlib cs_team_changer
  #endif
#else
  #pragma library cs_team_changer
#endif

/** There are the teams you may use.
 */
enum CSTeam
{
  
CSTEAM_UNASSIGNED 0,
  
CSTEAM_TERRORIST 1,
  
CSTEAM_CT 2,
  
CSTEAM_SPECTATOR 3
};

/** You may do 64 transfers once a second using this extension! Server will not crash!
 * CStrike extension using cs_set_user_team native will crash server when approximately 24 transfers are reached!
 */

/** Transfers a player from a team to other one. The player's model will not be touched. The server will not be forged.
 * This native will automatically send a TeamInfo message. Will also change the team offset and the team index declared by AMX Mod X extension.
 */
native cs_set_team(ClientCSTeam:Team);

/** Changes the player's team index declared by AMX Mod X extension. The team offset and the scores' table will not be touched.
 * There will not be a TeamInfo message.
 */
native cs_set_team_id(ClientCSTeam:Team);

/** Changes the player's team offset. Scores' table will not be touched.
 */
native cs_set_team_offset(ClientCSTeam:Team);

/** Sends a fast TeamInfo message. The player will be transfered at the team you want but only in the scores' table.
*/
native cs_set_team_tablescore(ClientCSTeam:Team); 


Pastout 07-31-2011 16:10

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
Wow dude keep up the good work man.

abdul-rehman 08-01-2011 15:46

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
Plz also point out the differences between this native and cs_set_user_team.

Arkshine 08-01-2011 16:31

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
It's written in the first post.

hleV 08-02-2011 08:55

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
I remember the normal cs_set_user_team() way working on normal server, but crashing on Zombie Plague with a lot of players. Have you tried this on ZP?

fysiks 08-02-2011 09:00

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
Quote:

Originally Posted by claudiuhks (Post 1522786)
Also, this module updates the AMXX API team's ID at clients and you will can use the get_user_team native without problems, it will be giving you a fair result (not wrong)

This will be fixed in version 1.8.2dev as soon as Bail pushes the fix.

Quote:

Originally Posted by claudiuhks (Post 1522786)
Lot of thanks to Arkshine for rewriting and compiling the module in windows and linux!

This makes it sound like Arkshine did everything except post it on the forums.

Arkshine 08-02-2011 09:13

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
I've not rewritten it, even if the code is quite small, I've just cleaned up a bit the code, changing some things (like changing 80% of code taken by few "if..else if..else" replacing by a "switch") and compiling. Don't know why he says "rewritten", it was not the purpose and with such small code, not really possible. So, claudiuhks, you should fix to avoid fysiks be traumatized more ;).

claudiuhks 08-02-2011 12:35

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
Mister fysiks, I just said that Arkshine opened the source, wrote something in it and closed. Why did you think he made all the code? Am I supposed to say what exactly he wrote in the source? And am I supposed to hide that he helped me with some code?

How to fix the problem with 'get_user_team' while the big plugins are using set_pdata_int? Do you think the offset changing with the fakemeta module will update the AMXX API team's ID?

The people are supposed to do thousands of things for make you happy mister fysiks... :)

@Arkshine at

Code:

you should fix to avoid fysiks be traumatized more ;).
Sorry but I don't think I have mind/power enough for do this...

@hleV at

Code:

I remember the normal cs_set_user_team() way working on normal server, but crashing on Zombie Plague with a lot of players. Have you tried this on ZP?
Tested at 32 players with like 120 team changes in one second
Also this cs_team_changer module is running on my zombie plague server, it is still alive since two or three days ago...

[IMG]http://img607.**************/img607/1240/unledhly.th.png[/IMG]

Without proofs we don't speak :D

fysiks 08-02-2011 12:45

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
Quote:

Originally Posted by claudiuhks (Post 1524236)
Mister fysiks, I just said that Arkshine opened the source, wrote something in it and closed. Why did you think he made all the code?

In English, you said that he wrote the whole thing again. In reality, he "added/remove/optimized" a few things. No need to get all defensive.

Arkshine's comment about me being "traumatized" was a joke. FYI

K.K.Lv 08-02-2011 12:53

Re: Module: CS Team Changer [avoid crashes in aggressive changes]
 
can you explain what does "FYI" mean:mrgreen:
I'm poor in english!:oops:


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

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