Page 1 of 1

I need help in plugin ze_gamemode_survivor

Posted: 01 Feb 2020, 11:45
by z0h1r-LK
Hi
i create plugin ze_gamemode_survivor, when start round game is crashed !
if u can finish plugin, not problem :) :) :)
just help
Warning : survivor has have high HP and gravity and speed and ultimate ammo and clip and model and blue glow and m249 weapon
  1. /*
  2.  
  3.     survivor is human alone is human, but all is zombies, zombie not become infect
  4.     become damaged mean kill,
  5.     survivor have m249 +  ultimate ammo + high health  + glow ... etc
  6.  
  7. */
  8.  
  9. #include < zombie_escape >
  10. #include < fun >
  11.  
  12. #define ACCESS_ADMIN ADMIN_KICK
  13.  
  14. // Variable
  15. new pcvar_chance, pcvar_health, pcvar_gravity, pcvar_speed, pcvar_glow, pcvar_weaponblock, pcvar_weapon
  16.  
  17. // Bool
  18. new bool:IsSurvivor[ 33 ]
  19. new bool:RoundSurvivor[ 33 ]
  20.  
  21. // Default Sound
  22. new SndSrv[ ] =
  23. {
  24.     "zombie_escape/gamemode_survivor.wav"
  25. }
  26.  
  27. new gMaxPlayers
  28.  
  29. public plugin_init()
  30. {
  31.     // Load Plugin
  32.     register_plugin("[ ZE ] Gamemode: Survivor", "1.0", "LiZou Mapper")
  33.    
  34.     // Clcmds
  35.     register_clcmd( "drop", "clcmd_drop" )
  36.     register_clcmd( "ze_survivor_round", "cmdSurvivor", ACCESS_ADMIN, "< Round Survivor >" )
  37.    
  38.     // Event
  39.     register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" )
  40.    
  41.     // Cvars
  42.     pcvar_chance = register_cvar( "ze_survivor_chance", "10" )
  43.     pcvar_health = register_cvar( "ze_survivor_health", "8000" )
  44.     pcvar_gravity = register_cvar( "ze_survivor_gravity", "0.8" )
  45.     pcvar_speed = register_cvar( "ze_survivor_speed", "265" )
  46.     pcvar_glow = register_cvar( "ze_survivor_glow", "1" )
  47.     pcvar_weaponblock = register_cvar( "ze_survivor_blockdrop", "1" )
  48.     pcvar_weapon = register_cvar( "ze_survivor_weapon", "m249" )
  49.    
  50.     // More
  51.     gMaxPlayers = get_maxplayers( )
  52.    
  53. }
  54.  
  55. public plugin_precache( )
  56. {
  57.     precache_sound( SndSrv )
  58. }
  59.  
  60. public plugin_natives( )
  61. {
  62.     register_native( "ze_is_user_survivor", "_native_get_user_survivor" )
  63.     register_native( "ze_set_user_survivor", "_native_set_user_survivor" )
  64. }
  65.  
  66. public _native_get_user_survivor( iPlugin, iParams )
  67. {
  68.     return IsSurvivor[ get_param( 1 ) ]
  69. }
  70.  
  71. public _native_set_user_survivor( iPlugin, iParams )
  72. {
  73.     SetSurvivor( get_param( 1 ) )
  74. }
  75.  
  76. // Client is Connected
  77. public client_connect( id )
  78. {
  79.     RoundSurvivor[ id ] = false
  80. }
  81.  
  82. // Client is Disconnected
  83. public client_disconnected( id )
  84. {
  85.     RoundSurvivor[ id ] = false
  86. }
  87.  
  88. // Cmd Start Round Survivor
  89. public cmdSurvivor( id )
  90. {
  91.     RoundSurvivor[ id ] = true
  92. }
  93.  
  94. // New Round function
  95. public EventNewRound( id )
  96. {
  97.     // if pcvar_chance = 1, make round survivor
  98.     if(random_num(1, get_pcvar_num( pcvar_chance ) ) == 1 )
  99.     {
  100.         RoundSurvivor[ id ] = true
  101.     }
  102. }
  103.  
  104. public ze_zombie_appear( )
  105. {
  106.     for( new id; id < gMaxPlayers;id++ )
  107.     {
  108.         if( RoundSurvivor[ id ] )
  109.         {
  110.             // choose one random player
  111.             new TargetPlayer = GetRandomAlive(random_num(1, GetAliveCount()))
  112.            
  113.             // Set client survivor
  114.             SetSurvivor( TargetPlayer )
  115.            
  116.             // start effect survivor
  117.             EffectRoundSurvivor( )
  118.            
  119.             while( RoundSurvivor[ id ] )
  120.             {
  121.                 // is user is not alive
  122.                 if( !is_user_alive( id ) )
  123.                     continue;
  124.                
  125.                 // user is already survivor or zombies
  126.                 if( IsSurvivor[ id ] && !ze_is_user_zombie( id ) )
  127.                     continue;
  128.                    
  129.                 // infect remaining player into zombies
  130.                 ze_set_user_zombie( id )
  131.                
  132.             }
  133.         }
  134.        
  135.     }
  136. }
  137.            
  138.  
  139. public SetSurvivor( id )
  140. {
  141.     // if player alive and is survivor and is player not zombie
  142.     if( is_user_alive( id ) && IsSurvivor[ id ] && !ze_is_user_zombie( id ) )
  143.     {
  144.         // Set Survivor Health
  145.         if( get_pcvar_num( pcvar_health ) != 0 )
  146.         {
  147.             set_user_health( id, get_pcvar_num( pcvar_health ) )
  148.            
  149.         }
  150.        
  151.         // Set Survivor Gravity
  152.         if( get_pcvar_num( pcvar_gravity ) != 0 )
  153.         {
  154.             set_user_gravity( id, get_pcvar_float( pcvar_gravity ) )
  155.         }
  156.        
  157.         // Set Survivor Speed
  158.         if( get_pcvar_num( pcvar_speed ) != 0 )
  159.         {
  160.             set_user_maxspeed( id, get_pcvar_float( pcvar_speed ) )
  161.         }
  162.        
  163.         // Set Survivor Glow
  164.         if( get_pcvar_num( pcvar_glow ) != 0 )
  165.         {
  166.             set_user_rendering( id, kRenderFxNone, 0, 0, 255, kRenderGlow, 100 )
  167.         }
  168.        
  169.         new WpnSrv[ 64 ]
  170.        
  171.         formatex( WpnSrv, charsmax( WpnSrv ), "weapon_%s", pcvar_weapon )
  172.         give_item( id, WpnSrv )
  173.        
  174.         // return make player is survivor
  175.         return IsSurvivor[ id ]
  176.     }
  177.    
  178.     return PLUGIN_HANDLED;
  179.                    
  180. }
  181.  
  182. EffectRoundSurvivor( )
  183. {
  184.     for( new id; id < gMaxPlayers ;id++ )
  185.     {
  186.         static LangHUD[ 64 ]
  187.        
  188.         // Message Round Survivor
  189.         formatex( LangHUD, charsmax( LangHUD ), "%L", LANG_PLAYER, "GAMEMODE_SURVIVOR" )
  190.         set_hudmessage( 0, 0, 255, -1.0, 0.25, 1, 6.0, 5.0, 0.1, 1.5 )
  191.         show_hudmessage( id, LangHUD )
  192.        
  193.         // Sound Round Survivor
  194.         client_cmd( id, "spk %s", SndSrv )  
  195.     }
  196. }      
  197.  
  198. public clcmd_drop( id ) {
  199.    
  200.     // Block Survivor drop weapons
  201.     if( IsSurvivor[ id ] && get_pcvar_num( pcvar_weaponblock ) != 0 )
  202.     {
  203.         return PLUGIN_HANDLED;
  204.     }
  205.    
  206.     return PLUGIN_CONTINUE;
  207. }
  208.  
  209. // Get Alive Count -returns alive players number-
  210. GetAliveCount()
  211. {
  212.     new iAlive, id
  213.    
  214.     for (id = 1; id <= gMaxPlayers; id++)
  215.     {
  216.         if (is_user_alive(id))
  217.             iAlive++
  218.     }
  219.    
  220.     return iAlive;
  221. }

Re: I need help in plugin ze_gamemode_survivor

Posted: 11 Feb 2020, 06:48
by Night Fury
Your server is crashing because of the infinity loop.in ze_zombie_appear forward. The round variable shouldn't have id, it should be bool ( either true or false ).

Re: I need help in plugin ze_gamemode_survivor

Posted: 16 Feb 2020, 13:53
by z0h1r-LK
Mohamed Alaa wrote: 4 years ago Your server is crashing because of the infinity loop.in ze_zombie_appear forward. The round variable shouldn't have id, it should be bool ( either true or false ).
what is solution
how to fix it !

Re: I need help in plugin ze_gamemode_survivor

Posted: 26 Feb 2020, 07:25
by Night Fury
Try:

Code: Select all

/*
 
    survivor is human alone is human, but all is zombies, zombie not become infect
    become damaged mean kill,
    survivor have m249 +  ultimate ammo + high health  + glow ... etc
 
*/
 
#include < zombie_escape >
#include < fun >
 
#define ACCESS_ADMIN ADMIN_KICK
 
// Variable
new pcvar_chance, pcvar_health, pcvar_gravity, pcvar_speed, pcvar_glow, pcvar_weaponblock, pcvar_weapon
 
// Bool
new bool:IsSurvivor[ 33 ]
new bool:RoundSurvivor
 
// Default Sound
new SndSrv[ ] =
{
    "zombie_escape/gamemode_survivor.wav"
}
 
new gMaxPlayers
 
public plugin_init()
{
    // Load Plugin
    register_plugin("[ ZE ] Gamemode: Survivor", "1.0", "LiZou Mapper")
   
    // Clcmds
    register_clcmd( "drop", "clcmd_drop" )
    register_clcmd( "ze_survivor_round", "cmdSurvivor", ACCESS_ADMIN, "< Round Survivor >" )
   
    // Event
    register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" )
   
    // Cvars
    pcvar_chance = register_cvar( "ze_survivor_chance", "10" )
    pcvar_health = register_cvar( "ze_survivor_health", "8000" )
    pcvar_gravity = register_cvar( "ze_survivor_gravity", "0.8" )
    pcvar_speed = register_cvar( "ze_survivor_speed", "265" )
    pcvar_glow = register_cvar( "ze_survivor_glow", "1" )
    pcvar_weaponblock = register_cvar( "ze_survivor_blockdrop", "1" )
    pcvar_weapon = register_cvar( "ze_survivor_weapon", "m249" )
   
    // More
    gMaxPlayers = get_maxplayers( )
   
}
 
public plugin_precache( )
{
    precache_sound( SndSrv )
}
 
public plugin_natives( )
{
    register_native( "ze_is_user_survivor", "_native_get_user_survivor" )
    register_native( "ze_set_user_survivor", "_native_set_user_survivor" )
}
 
public _native_get_user_survivor( iPlugin, iParams )
{
    return IsSurvivor[ get_param( 1 ) ]
}
 
public _native_set_user_survivor( iPlugin, iParams )
{
    SetSurvivor( get_param( 1 ) )
}
 
// Client is Connected
public client_connect( id )
{
    IsSurvivor[ id ] = false
}
 
// Client is Disconnected
public client_disconnected( id )
{
    IsSurvivor[ id ] = false
}
 
// Cmd Start Round Survivor
public cmdSurvivor( id )
{
    RoundSurvivor = true
}
 
// New Round function
public EventNewRound( id )
{
    // if pcvar_chance = 1, make round survivor
    if(random_num(1, get_pcvar_num( pcvar_chance ) ) == 1 )
    {
        RoundSurvivor = true
    }
}
 
public ze_zombie_appear( )
{
    for( new id; id < gMaxPlayers;id++ )
    {
        if( RoundSurvivor )
        {
            // choose one random player
            new TargetPlayer = GetRandomAlive(random_num(1, GetAliveCount()))
           
            // Set client survivor
            SetSurvivor( TargetPlayer )
           
            // start effect survivor
            EffectRoundSurvivor( )
           
            for (new id = 0; id < get_maxplayers(); id++)
            {
                // is user is not alive
                if( !is_user_alive( id ) )
                    continue;
               
                // user is already survivor or zombies
                if( IsSurvivor[ id ] && !ze_is_user_zombie( id ) )
                    continue;
                   
                // infect remaining player into zombies
                ze_set_user_zombie( id )
               
            }
        }
       
    }
}
           
 
public SetSurvivor( id )
{
    // if player alive and is survivor and is player not zombie
    if( is_user_alive( id ) && !ze_is_user_zombie( id ) )
    {
        IsSurvivor[ id ] = true
        
        // Set Survivor Health
        if( get_pcvar_num( pcvar_health ) != 0 )
        {
            set_user_health( id, get_pcvar_num( pcvar_health ) )
           
        }
       
        // Set Survivor Gravity
        if( get_pcvar_num( pcvar_gravity ) != 0 )
        {
            set_user_gravity( id, get_pcvar_float( pcvar_gravity ) )
        }
       
        // Set Survivor Speed
        if( get_pcvar_num( pcvar_speed ) != 0 )
        {
            set_user_maxspeed( id, get_pcvar_float( pcvar_speed ) )
        }
       
        // Set Survivor Glow
        if( get_pcvar_num( pcvar_glow ) != 0 )
        {
            set_user_rendering( id, kRenderFxNone, 0, 0, 255, kRenderGlow, 100 )
        }
       
        new WpnSrv[ 64 ]
       
        formatex( WpnSrv, charsmax( WpnSrv ), "weapon_%s", pcvar_weapon )
        give_item( id, WpnSrv )
       
        // return make player is survivor
        return IsSurvivor[ id ]
    }
   
    return PLUGIN_HANDLED;
                   
}
 
EffectRoundSurvivor( )
{
    for( new id; id < gMaxPlayers ;id++ )
    {
        static LangHUD[ 64 ]
       
        // Message Round Survivor
        formatex( LangHUD, charsmax( LangHUD ), "%L", LANG_PLAYER, "GAMEMODE_SURVIVOR" )
        set_hudmessage( 0, 0, 255, -1.0, 0.25, 1, 6.0, 5.0, 0.1, 1.5 )
        show_hudmessage( id, LangHUD )
       
        // Sound Round Survivor
        client_cmd( id, "spk %s", SndSrv )  
    }
}      
 
public clcmd_drop( id ) {
   
    // Block Survivor drop weapons
    if( IsSurvivor[ id ] && get_pcvar_num( pcvar_weaponblock ) != 0 )
    {
        return PLUGIN_HANDLED;
    }
   
    return PLUGIN_CONTINUE;
}
 
// Get Alive Count -returns alive players number-
GetAliveCount()
{
    new iAlive, id
   
    for (id = 1; id <= gMaxPlayers; id++)
    {
        if (is_user_alive(id))
            iAlive++
    }
   
    return iAlive;
}

Re: I need help in plugin ze_gamemode_survivor

Posted: 16 May 2020, 06:33
by z0h1r-LK
thanks bro :)