Approved Darkness Round

Gameplay Addons
Post Reply
User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 283
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

Darkness Round

#1

Post by Mark » 1 Year 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 69 times
Darkness Round.zip
(688.84 KiB) Downloaded 69 times
Last edited by Raheem on 30 Jul 2019, 12:39, edited 1 time in total.
Reason: Updated with right Send_Cmd loop
These users thanked the author Mark for the post:
Raheem (1 Year Ago)

User avatar
Muhammet20
Veteran Member
Veteran Member
Turkey
Posts: 408
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 15
Contact:

#2

Post by Muhammet20 » 10 Months Ago

what is this can do ?
[Learning HTML coding language]
[Learning Unreal Engine 4]
[Learning Adobe programs]

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 1 Year Ago
Has thanked: 2 times
Been thanked: 1 time
Age: 19
Contact:

#3

Post by Rain1153 » 10 Months Ago

Read the description
LOL

User avatar
Muhammet20
Veteran Member
Veteran Member
Turkey
Posts: 408
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 15
Contact:

#4

Post by Muhammet20 » 10 Months Ago

Rain1153 wrote:
10 Months Ago
Read the description
good idea but i dont need it :)
[Learning HTML coding language]
[Learning Unreal Engine 4]
[Learning Adobe programs]

User avatar
tmv
Member
Member
Russia
Posts: 31
Joined: 4 Months Ago
Has thanked: 2 times
Been thanked: 0
Age: 19
Contact:

#5

Post by tmv » 4 Months 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
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#6

Post by Raheem » 4 Months 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. }
You don't know? Learn and you will know.

User avatar
tmv
Member
Member
Russia
Posts: 31
Joined: 4 Months Ago
Has thanked: 2 times
Been thanked: 0
Age: 19
Contact:

#7

Post by tmv » 4 Months Ago

Raheem wrote:
4 Months 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
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#8

Post by Raheem » 4 Months 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 @Mark posted this, he maybe not tested it. I updated the main code.
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 283
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

#9

Post by Mark » 3 Weeks Ago

Whoops Sorry!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests