AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Remember The Teams (https://forums.alliedmods.net/showthread.php?t=299267)

Rohanlogs 07-09-2017 14:35

Remember The Teams
 
2 Attachment(s)
Remember The Teams


Description

After time runs out and map changes or admin changes the map using amx_map,
this plugin saves the current teams and loads them on the next map.
This will not work with changelevel <map>.

Requirements
Recommended AMXX 1.8.2 or higher

Includes
< cstrike >
< nvault >

Installation
1. Place the plugin remember_the_teams.amxx into your plugins directory (addons/amxmodx/plugins)
2. Open plugins.ini (addons/amxmodx/configs) and add remember_the_teams.amxx ON TOP of amxmodx base plugins (see example below)
3. Add mapsdata.txt to your configs directory
4. Add your server's mapcycle maps (or all valid maps) into mapsdata.txt (each map on a new line)
5. Reload the map.

Example of plugins.ini:
Example of mapsdata.txt:
Usage
Just wait for the timelimit to run out or use amx_map <mapname>
Command amx_map works only for the maps you've saved into mapsdata.txt.
Why? Before we can start saving the teams, plugin needs to check the arguments when amx_map is used to check if the changed map is valid.
So add only VALID maps in mapsdata.txt

Changelog
Code:


0.0.1
        - Initial release

0.0.2
        - Added clearing old nVault entries

0.0.3
        - Some code fix

0.0.4
        - Blocked jointeam commands 1 minute before map change
            and for sometime after change

0.0.5
        - Added check if someone joins when teams are already written

0.0.6
        - Fixed error

0.0.7
        - Moved 0.0.5 update to client_putinserver where its supposed to be

0.0.8
        - Small change in code



Credits
This post
• I took parts of auto-join code from Auto Join On Connect by VEN
• Learned Tries based on how this was made

Source
Spoiler

EFFx 07-09-2017 18:11

Re: Remember The Teams
 
This is useless whether you can change your team after the join. You can use client_disconnect() instead of a few functions to check if the map was changed.

SpawnerF 07-09-2017 19:15

Re: Remember The Teams
 
Hi,

TBH, that's a bad indentation and bad practice.
In Task you don't need to store big numbers.
Don't use get_maxplayers to make a loop to check "something" always get the real number of connected players using get_players().
Use switch instead of if and else if because it's more efficient&cleaner and faster ...
Code:

public task_force_team_join( menu_msgid[], id )
{
        if ( get_user_team(id) )
                return

        force_team_join( id, menu_msgid[0] )
}

It's used one time so you can use it directly without using set_task.
You don't need to close nvault at every changement so it's better to let it open and do ur stuff and then call nvault_close() in plugin_end.
It's always good to dispose objects to free up memory ( I'm talking about Array:X and Trie:X ).
There is also something called charsmax which is a macro replace sizeof (X) - 1.
Sometimes you use stock and sometimes no! I don't understand why.

Good luck.

Rohanlogs 07-10-2017 11:43

Re: Remember The Teams
 
Thanks..


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

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