Raised This Month: $ Target: $400
 0% 

Fail Spawn Protector + Team Limiter


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   General Purpose        Approver:   HamletEagle (37)
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 09-17-2014 , 02:00   Fail Spawn Protector + Team Limiter
Reply With Quote #1

Description:
This simple and useful plugin will protect you from dying due to bad spawn location. Now, you can spawn more players than existed spawn points inside map. This plugin is tested on special map with 32 spawnpoints at identical origin and its works nicely. Just visit this thread to read more about the testing.
What can you edit?
PHP Code:
    g_iStartDistance register_cvar("fw_StartDistance""32"// First search distance for finding a free location in map
    
g_iMaxAttempts register_cvar("fw_MaxAttempts""128"// How many times to search in an area for a free space 
    
g_iTerrorMaxSpawn register_cvar("fw_TerrorMaxSpawn""0"// Maximum Terror spawn entities. If you want to disable it, just add "0" value
    
g_iCTMaxSpawn register_cvar("fw_CTMaxSpawn""0"// Maximum CT spawn entities. If you want to disable it, just add "0" value 
Example:
This messages are printed in your server console:
PHP Code:
L 06/17/2016 17:09:54: -------- Mapchange to cs_assault --------
[
Fail Spawn ProtectorCreating new file
[Fail Spawn ProtectorDeleting old file
[Fail Spawn ProtectorRequired 3 less Terror spawn entities!
[
Fail Spawn ProtectorAuto reload
[Fail Spawn ProtectorRequired 3 less CT spawn entities!
[
Fail Spawn ProtectorAuto reload
[Fail Spawn ProtectorCS Spawn Entity10 || Terror Spawn Entity10
[Fail Spawn ProtectorServer is reloading
L 06
/17/2016 17:09:55: -------- Mapchange to cs_assault --------
[
Fail Spawn ProtectorCreating new file
[Fail Spawn ProtectorDeleting old file
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorCT original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorTerror original spawn is remove
[Fail Spawn ProtectorCS Spawn Entity|| Terror Spawn Entity
Note!
This plugin need at least 1 valid spawn point in the map. This plugin also do not prevent connected player. It only removing or adding the spawn entity.
Team Limiter:
If you want to use this feature,just follow below method:

1. Just uncomment this part:
PHP Code:
// Uncomment 'AUTO_SPAWNCREATOR' if your want to enable auto spawn creator
//#define AUTO_SPAWNCREATOR 
2. Then, edit this cvars:
PHP Code:
    g_iTerrorMaxSpawn register_cvar("fw_TerrorMaxSpawn""0"//  Maximum Terror spawn entities. If you want to disable it, just add "0"  value
    
g_iCTMaxSpawn register_cvar("fw_CTMaxSpawn""0"// Maximum CT  spawn entities. If you want to disable it, just add "0" value 
3. fw_TerrorMaxSpawn cvar is represent for Terrorist amount per team.
4. fw_CTMaxSpawn cvar is represent for CT amount per team.
Rare Problem!
If the spawn entities configure via fw_TerrorMaxSpawn cvar and fw_CTMaxSpawn cvar is less than the original spawn entity, the player still be spawned at the beginning of round. As example, original spawn point is 10. If we configured it into 1, then all 10's player will be spawned at the same spawn location. So, what will happen, after round started, random player will died automatically until alive player is equal to new spawn entities or points.
Credits:
1. xPaw.
2. VEN.
3. Arkshine.
4. Phant (Testing the code in his special map).
Changelog:
Code:
v1.1 (6 Dis 2015)
- [FIXED] Remove unnecessary bool.
- [FIXED] Using existing defined code.
- [FIXED] Variable naming.

v1.2 - (17 Jun 2016)
- [FIXED] First safely spawn player will be killed by worldspawn.
- [ADDED] Safety check via player origin to determine whether player is idle or not.
- [ADDED] Auto-spawn creator and team limiter features.
Downloads:

v1.0 - 40
v1.0 - 99

Feel free to use it.
Attached Files
File Type: sma Get Plugin or Get Source (fail_spawn_protector.sma - 2034 views - 11.9 KB)

Last edited by zmd94; 08-24-2021 at 13:41.
zmd94 is offline
AGoodGuy
Member
Join Date: Sep 2014
Old 09-17-2014 , 10:11   Re: Colorful Admin Message v1.0
Reply With Quote #2

Nike plugins, but i think if change command like admin_chat,

#-your text for corlor chat
$-your text for hud chat

it'll easy than this.
__________________
Without Passion Life Is Nothing

Quote:
“If you can't fly then run, if you can't run then walk, if you can't walk then crawl, but whatever you do, you have to keep moving forward.”― Martin Luther King Jr.
AGoodGuy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-17-2014 , 10:29   Re: Colorful Admin Message v1.0
Reply With Quote #3

Code:
 for ( i = 0; i < count; i ++ )     {         if ( is_user_connected ( players [ i ] ) )         {             message_begin ( MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players [ i ] )             write_byte ( players [ i ] )             write_string ( message )             message_end ( )         }     }

Cache get_user_msgid("SayText").
Don't re-index an array.
__________________

Last edited by HamletEagle; 09-17-2014 at 10:30.
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 09-17-2014 , 10:30   Re: Colorful Admin Message v1.0
Reply With Quote #4

Sorry AGoodGuy, I can't understand what are you trying to say?

;)
zmd94 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 09-17-2014 , 10:38   Re: Colorful Admin Message v1.0
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
Cache get_user_msgid("SayText"). Don't re-index an array.
Do you mean that, it is better in this way?
PHP Code:
new g_MsgText

public plugin init()
{

    
g_MsgText get_user_msgid("SayText")
}

stock print_colored ( const index, const input [ ], const any:... )
{

    for ( 
0count++ )
    {
        if ( 
is_user_connected players ] ) )
        {
            
message_begin MSG_ONE_UNRELIABLEg_MsgText_players ] )
            
write_byte players ] )
            
write_string message )
            
message_end ( )
        }
    }


Last edited by zmd94; 09-17-2014 at 10:39.
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-17-2014 , 10:41   Re: Colorful Admin Message v1.0
Reply With Quote #6

The better way is this:
Code:
new g_MsgText public plugin init() {     g_MsgText = get_user_msgid("SayText") } stock print_colored ( const index, const input [ ], const any:... ) {     new id     for ( i = 0; i < count; i ++ )     {         id = players[ i ]         if ( is_user_connected ( id  ) )         {             message_begin ( MSG_ONE_UNRELIABLE, g_MsgText, _, id )             write_byte ( id )             write_string ( message )             message_end ( )         }     } }
__________________

Last edited by HamletEagle; 09-17-2014 at 10:43.
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 09-17-2014 , 10:56   Re: Colorful Admin Message v1.0
Reply With Quote #7

HamletEagle, may I know why that your way is better?

;)
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-17-2014 , 11:17   Re: Colorful Admin Message v1.0
Reply With Quote #8

You can search by yourself:
1. It's obvious, instead of using get_user_msgid every time, you cache it's value( it won't change during run time ).
2. Search on the wiki.
__________________
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 09-17-2014 , 11:19   Re: Colorful Admin Message v1.0
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
You can search by yourself:
1. It's obvious, instead of using get_user_msgid every time, you cache it's value (it won't change during run time).
2. Search on the wiki.
Yes, my fault. Thank you for correcting me. ;)

I will update the code.

Edit:
Quote:
Originally Posted by zmd94
v1.1 - [FIXED] Cache problems.

Last edited by zmd94; 09-17-2014 at 11:27.
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-23-2015 , 15:35   Re: Colorful Admin Message v1.1
Reply With Quote #10

This is pretty useless IMO, but given that there is no other plugin that does this I will let it pass if you make this changes:

1.#define ADMIN_FLAG ADMIN_IMMUNITY make it a cvar/command instead.
2.Add cvars for colors. You could let the owner decide if he wants random color or some predefined ones(that he can set up from cvars too).
3.message should be 192 and not 64. 192 is the max.
4.Remove the "stock" keyword, stock is used for functions that may not be used, but you should use everything from your plugin, thus "stock" does not make sense.
5.In print_colored:
  • use charsmax() instead of hardcoding a string-array size, it's better for readability.
  • if (is_user_connected(id)) check is not needed, get_players give you an array of valid player.
  • if (index) -> check if it is between 1 and MaxPlayers.
6.Put any relevant informations inside source file, it's easier for the owner. This include cvars, how to use the plugin, thread link etc.

Some suggestions:
1.Allow users to use this messages too(maybe a cvar, why not ?)
2.You could include a command like amx_showcolorcodes(or sth like this) and print the shortcuts(!g, etc).
3.Allow the player to specify to which player to send the message. For example, you may want to send the message only to player X or to all players. You can add another argument inside the command for this(like 0(for all)/CT/T/X(the player name)).
__________________

Last edited by HamletEagle; 10-23-2015 at 15:37.
HamletEagle is offline
Reply


Thread Tools
Display Modes

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 12:00.


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