Approved Darkness Round

Plug-ins compatibility with Zombie Escape 1.x only!


Post Reply
User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

Darkness Round

#1

Post by Mark » 5 years ago

Darkness Round

Description:
  • This will set dark rounds randomly as the new round starts
  • It will also remove the fog while in this round

Credits:
  • Rain1153 = His Idea

Code:
    1. #include <zombie_escape>
    2.  
    3. #define DARKSOUND "dark/darkness.wav"
    4. #define DEFAULT_LIGHT "d"
    5.  
    6. new g_pCvarRoundTime, g_pCvarMapTime, g_iRandomRoundNum, g_iRoundNum, bool:g_bDarkRoundCome
    7.  
    8. new g_iMaxPlayers
    9.  
    10. public plugin_init()
    11. {
    12.     register_plugin("[ZE] Darkness Round", "1.0", "Raheem")
    13.    
    14.     // Pointers
    15.     g_pCvarRoundTime = get_cvar_pointer("mp_roundtime")
    16.     g_pCvarMapTime = get_cvar_pointer("mp_timelimit")
    17.    
    18.     // Check rounds number
    19.     new iRoundsNumber = get_pcvar_num(g_pCvarMapTime) / get_pcvar_num(g_pCvarRoundTime)
    20.    
    21.     // Get random round
    22.     g_iRandomRoundNum = random_num(0, iRoundsNumber)
    23.    
    24.     // Set counter to 0 first round
    25.     g_iRoundNum = 0
    26.    
    27.     // Dark round false
    28.     g_bDarkRoundCome = false
    29.    
    30.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
    31. }
    32.  
    33. public plugin_precache()
    34. {
    35.     precache_sound(DARKSOUND)
    36. }
    37.  
    38. public ze_game_started()
    39. {
    40.     if (g_iRoundNum == g_iRandomRoundNum)
    41.     {
    42.         for (new id = 1; id <= g_iMaxPlayers; id++)
    43.         {
    44.             if (!is_user_connected(id))
    45.                 continue
    46.            
    47.             PlaySound(id, DARKSOUND)
    48.             Send_Cmd(id, "gl_fog 0")
    49.         }
    50.  
    51.         server_cmd("ze_lighting_style a")
    52.        
    53.         g_bDarkRoundCome = true
    54.         ze_colored_print(0, "!tIt's too late... Darkness round is ON!y!")
    55.     }
    56.    
    57.     g_iRoundNum++
    58. }
    59.  
    60. public ze_roundend(WinTeam)
    61. {
    62.     if (g_bDarkRoundCome == true)
    63.     {
    64.         server_cmd("ze_lighting_style %s", DEFAULT_LIGHT)
    65.        
    66.         for (new id = 1; id <= g_iMaxPlayers; id++)
    67.         {
    68.             if (!is_user_connected(id))
    69.                 continue
    70.  
    71.             Send_Cmd(id, "gl_fog 1")
    72.         }
    73.        
    74.         g_bDarkRoundCome = false
    75.     }
    76. }
    77.  
    78. stock Send_Cmd(id, text[])
    79. {
    80.     message_begin(MSG_ONE, 51, _, id)
    81.     write_byte(strlen(text) + 2)
    82.     write_byte(10)
    83.     write_string(text)
    84.     message_end()
    85. }
If your want fog to be off use this code:

    1. #include <zombie_escape>
    2.  
    3. #define DARKSOUND "dark/darkness.wav"
    4. #define DEFAULT_LIGHT "d"
    5.  
    6. new g_pCvarRoundTime, g_pCvarMapTime, g_iRandomRoundNum, g_iRoundNum, bool:g_bDarkRoundCome
    7.  
    8. public plugin_init()
    9. {
    10.     register_plugin("[ZE] Darkness Round", "1.0", "Raheem")
    11.    
    12.     // Pointers
    13.     g_pCvarRoundTime = get_cvar_pointer("mp_roundtime")
    14.     g_pCvarMapTime = get_cvar_pointer("mp_timelimit")
    15.    
    16.     // Check rounds number
    17.     new iRoundsNumber = get_pcvar_num(g_pCvarMapTime) / get_pcvar_num(g_pCvarRoundTime)
    18.    
    19.     // Get random round
    20.     g_iRandomRoundNum = random_num(0, iRoundsNumber)
    21.    
    22.     // Set counter to 0 first round
    23.     g_iRoundNum = 0
    24.    
    25.     // Dark round false
    26.     g_bDarkRoundCome = false
    27. }
    28.  
    29. public plugin_precache()
    30. {
    31.     precache_sound(DARKSOUND)
    32. }
    33.  
    34. public ze_game_started()
    35. {
    36.     if (g_iRoundNum == g_iRandomRoundNum)
    37.     {
    38.         for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
    39.         {
    40.             if (!is_user_connected(id))
    41.                 continue
    42.            
    43.             PlaySound(id, DARKSOUND)
    44.         }
    45.  
    46.         server_cmd("ze_lighting_style a")
    47.         g_bDarkRoundCome = true
    48.         ze_colored_print(0, "!tIt's too late... Darkness round is ON!y!")
    49.     }
    50.    
    51.     g_iRoundNum++
    52. }
    53.  
    54. public ze_roundend(WinTeam)
    55. {
    56.     if (g_bDarkRoundCome == true)
    57.     {
    58.         server_cmd("ze_lighting_style %s", DEFAULT_LIGHT)
    59.         g_bDarkRoundCome = false
    60.     }
    61. }
    62.  
    63. stock Send_Cmd(id, text[])
    64. {
    65.     message_begin(MSG_ONE, 51, _, id)
    66.     write_byte(strlen(text) + 2)
    67.     write_byte(10)
    68.     write_string(text)
    69.     message_end()
    70. }

Download:

Darkness Round.zip
(688.84 KiB) Downloaded 570 times
Darkness Round.zip
(688.84 KiB) Downloaded 570 times
Last edited by Raheem 4 years ago, edited 1 time in total.
Reason: Updated with right Send_Cmd loop

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#2

Post by Muhammet20 » 5 years ago

what is this can do ?

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#3

Post by Rain1153 » 5 years ago

Read the description
LOL

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#4

Post by Muhammet20 » 5 years ago

Rain1153 wrote: 5 years ago Read the description
good idea but i dont need it :)

User avatar
tmv
Member
Member
Russia
Posts: 36
Joined: 4 years ago
Contact:

#5

Post by tmv » 4 years ago

First code's fog doesn't work and the server crashes because of this error:

Code: Select all

Host_Error: WriteDest_Parm: not a client

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#6

Post by Raheem » 4 years ago

Please give a try:
    1. #include <zombie_escape>
    2.  
    3. #define DARKSOUND "dark/darkness.wav"
    4. #define DEFAULT_LIGHT "d"
    5.  
    6. new g_pCvarRoundTime, g_pCvarMapTime, g_iRandomRoundNum, g_iRoundNum, bool:g_bDarkRoundCome
    7.  
    8. new g_iMaxPlayers
    9.  
    10. public plugin_init()
    11. {
    12.     register_plugin("[ZE] Darkness Round", "1.0", "Raheem")
    13.    
    14.     // Pointers
    15.     g_pCvarRoundTime = get_cvar_pointer("mp_roundtime")
    16.     g_pCvarMapTime = get_cvar_pointer("mp_timelimit")
    17.    
    18.     // Check rounds number
    19.     new iRoundsNumber = get_pcvar_num(g_pCvarMapTime) / get_pcvar_num(g_pCvarRoundTime)
    20.    
    21.     // Get random round
    22.     g_iRandomRoundNum = random_num(0, iRoundsNumber)
    23.    
    24.     // Set counter to 0 first round
    25.     g_iRoundNum = 0
    26.    
    27.     // Dark round false
    28.     g_bDarkRoundCome = false
    29.    
    30.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
    31. }
    32.  
    33. public plugin_precache()
    34. {
    35.     precache_sound(DARKSOUND)
    36. }
    37.  
    38. public ze_game_started()
    39. {
    40.     if (g_iRoundNum == g_iRandomRoundNum)
    41.     {
    42.         for (new id = 1; id <= g_iMaxPlayers; id++)
    43.         {
    44.             if (!is_user_connected(id))
    45.                 continue
    46.            
    47.             PlaySound(id, DARKSOUND)
    48.             Send_Cmd(id, "gl_fog 0")
    49.         }
    50.  
    51.         server_cmd("ze_lighting_style a")
    52.        
    53.         g_bDarkRoundCome = true
    54.         ze_colored_print(0, "!tIt's too late... Darkness round is ON!y!")
    55.     }
    56.    
    57.     g_iRoundNum++
    58. }
    59.  
    60. public ze_roundend(WinTeam)
    61. {
    62.     if (g_bDarkRoundCome == true)
    63.     {
    64.         server_cmd("ze_lighting_style %s", DEFAULT_LIGHT)
    65.        
    66.         for (new id = 1; id <= g_iMaxPlayers; id++)
    67.         {
    68.             if (!is_user_connected(id))
    69.                 continue
    70.  
    71.             Send_Cmd(id, "gl_fog 1")
    72.         }
    73.        
    74.         g_bDarkRoundCome = false
    75.     }
    76. }
    77.  
    78. stock Send_Cmd(id, text[])
    79. {
    80.     message_begin(MSG_ONE, 51, _, id)
    81.     write_byte(strlen(text) + 2)
    82.     write_byte(10)
    83.     write_string(text)
    84.     message_end()
    85. }
He who fails to plan is planning to fail

User avatar
tmv
Member
Member
Russia
Posts: 36
Joined: 4 years ago
Contact:

#7

Post by tmv » 4 years ago

Raheem wrote: 4 years ago Please give a try:
    1. #include <zombie_escape>
    2.  
    3. #define DARKSOUND "dark/darkness.wav"
    4. #define DEFAULT_LIGHT "d"
    5.  
    6. new g_pCvarRoundTime, g_pCvarMapTime, g_iRandomRoundNum, g_iRoundNum, bool:g_bDarkRoundCome
    7.  
    8. new g_iMaxPlayers
    9.  
    10. public plugin_init()
    11. {
    12.     register_plugin("[ZE] Darkness Round", "1.0", "Raheem")
    13.    
    14.     // Pointers
    15.     g_pCvarRoundTime = get_cvar_pointer("mp_roundtime")
    16.     g_pCvarMapTime = get_cvar_pointer("mp_timelimit")
    17.    
    18.     // Check rounds number
    19.     new iRoundsNumber = get_pcvar_num(g_pCvarMapTime) / get_pcvar_num(g_pCvarRoundTime)
    20.    
    21.     // Get random round
    22.     g_iRandomRoundNum = random_num(0, iRoundsNumber)
    23.    
    24.     // Set counter to 0 first round
    25.     g_iRoundNum = 0
    26.    
    27.     // Dark round false
    28.     g_bDarkRoundCome = false
    29.    
    30.     g_iMaxPlayers = get_member_game(m_nMaxPlayers)
    31. }
    32.  
    33. public plugin_precache()
    34. {
    35.     precache_sound(DARKSOUND)
    36. }
    37.  
    38. public ze_game_started()
    39. {
    40.     if (g_iRoundNum == g_iRandomRoundNum)
    41.     {
    42.         for (new id = 1; id <= g_iMaxPlayers; id++)
    43.         {
    44.             if (!is_user_connected(id))
    45.                 continue
    46.            
    47.             PlaySound(id, DARKSOUND)
    48.             Send_Cmd(id, "gl_fog 0")
    49.         }
    50.  
    51.         server_cmd("ze_lighting_style a")
    52.        
    53.         g_bDarkRoundCome = true
    54.         ze_colored_print(0, "!tIt's too late... Darkness round is ON!y!")
    55.     }
    56.    
    57.     g_iRoundNum++
    58. }
    59.  
    60. public ze_roundend(WinTeam)
    61. {
    62.     if (g_bDarkRoundCome == true)
    63.     {
    64.         server_cmd("ze_lighting_style %s", DEFAULT_LIGHT)
    65.        
    66.         for (new id = 1; id <= g_iMaxPlayers; id++)
    67.         {
    68.             if (!is_user_connected(id))
    69.                 continue
    70.  
    71.             Send_Cmd(id, "gl_fog 1")
    72.         }
    73.        
    74.         g_bDarkRoundCome = false
    75.     }
    76. }
    77.  
    78. stock Send_Cmd(id, text[])
    79. {
    80.     message_begin(MSG_ONE, 51, _, id)
    81.     write_byte(strlen(text) + 2)
    82.     write_byte(10)
    83.     write_string(text)
    84.     message_end()
    85. }
This is Okay. Is this the same problem as Previous post when (if is_user_connected) was not defined?

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#8

Post by Raheem » 4 years ago

No, he was sending a message to all user using message_begin(MSG_ONE, 51, _, 0) and this not secured as it gives you an error, so the right is we loop through all players and send the message for every player with message_begin(MSG_ONE, 51, _, id).

Anyway not know how [mention]Mark[/mention] posted this, he maybe not tested it. I updated the main code.
He who fails to plan is planning to fail

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#9

Post by Mark » 4 years ago

Whoops Sorry!

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests