Approved Replace disconnected player

Gameplay Addons
Post Reply
User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 577
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 47 times
Age: 19
Contact:

Replace disconnected player

#1

Post by Jack GamePlay » 6 Months Ago

| Description:
  • This plugin is going to replace the disconnected player' with another randomly chosen player to be the zombie/human instead of his place.
| Code:
    1. #include <zombie_escape>
    2.  
    3. public plugin_init()
    4. {
    5.     register_plugin("[ZE] Addon: Replace disconnected players", "1.0", "Jack")
    6. }
    7.  
    8. public ze_player_disconnect(id)
    9. {
    10.     // Game wasn't started? ||  Wasn't alive? || Last player?
    11.     if (!ze_is_game_started() || !is_user_alive(id) || GetAllAlivePlayersNum() <= 1)
    12.         return 0; // Continue
    13.  
    14.     // We are in freeze time?
    15.     if (!get_member_game(m_bFreezePeriod))
    16.     {
    17.         new iIndex
    18.         // Last Zombie
    19.         if (ze_is_user_zombie(id) && ze_get_zombies_number() == 1)
    20.         {
    21.             if (ze_get_humans_number() == 1)
    22.                 return 0; // Continue
    23.            
    24.             // Find replacement
    25.             while ((iIndex = GetRandomAlive(random_num(1, ze_get_humans_number()))) == id) { /* keep looping */ }
    26.            
    27.             new name[32]
    28.             get_user_name(iIndex, name, charsmax(name))
    29.             ze_colored_print(0, "!tThe last zombie has left!y. !g%s !thas been the new zombie!y.", name)
    30.             ze_set_user_zombie(iIndex)
    31.             UpdateOrigin(iIndex, id)
    32.            
    33.             return 1; // Stop main function
    34.         }
    35.         // Last Human
    36.         else if (!ze_is_user_zombie(id) && ze_get_humans_number() == 1)
    37.         {
    38.             if (ze_get_zombies_number() == 1)
    39.                 return 0;
    40.            
    41.             // Find replacement
    42.             while ((iIndex = GetRandomAlive(random_num(1, ze_get_zombies_number()))) == id) { /* keep looping */ }
    43.            
    44.             new name[32]
    45.             get_user_name(iIndex, name, charsmax(name))
    46.             ze_colored_print(0, "!tThe last human has left!y. !g%s !thas been the new human!y.", name)
    47.             ze_set_user_human(iIndex)
    48.             UpdateOrigin(iIndex, id)
    49.            
    50.             return 1; // Stop main function
    51.         }
    52.     }
    53.    
    54.     return 0; // Continue
    55. }
    56.  
    57. UpdateOrigin(iIndex, id)
    58. {
    59.     new Float:flOrigin[3]
    60.     get_entvar(id, var_origin, flOrigin)
    61.     set_entvar(iIndex, var_origin, flOrigin)
    62. }
Not interested in CS/Pawn anymore.
Accepting web projects.

User avatar
th3_king
VIP
VIP
Egypt
Posts: 35
Joined: 2 Years Ago
Location: Egypt
Has thanked: 10 times
Been thanked: 2 times
Age: 17
Contact:

#2

Post by th3_king » 6 Months Ago

Good Work,
New Idea: Better than choosing randomly, >> Choose the player who has the lowest played time << You can also make the both Ideas ( Random Choose And My Idea with Cvar ).

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 192
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#3

Post by sPe3doN » 6 Months Ago

idea: when player chosen randomly he 'll frezzing for 5 sconds

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests