Raised This Month: $ Target: $400
 0% 

|REQ| Respawn plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 01-31-2016 , 02:40   |REQ| Respawn plugin
Reply With Quote #1

Has anyone knows how to achieve the following:
When zombie dies first time revive(respawn) after 1 secods.
When die a second time respawn after 2 seconds.
When she dies the third time respawn after 3 seconds.
And so on ...that the limit be ten seconds.

PHP Code:
#include <amxmodx>
#include <biohazard>
#include <hamsandwich>

#define TASK_RESPAWN 123543

new cvar_respawncvar_timerespawng_maxplayers 

public plugin_init()
{
    
register_plugin("[Bio] Addon: Zombie Spawn""1.0""Dias")
    
register_event("DeathMsg""event_death""a")
    
register_logevent("round_end"2"1=Round_End")
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
    
cvar_respawn register_cvar("bh_zombie_respawn""1")
    
cvar_timerespawn register_cvar("bio_zombie_cooldown_time""7.0")

    
g_maxplayers get_maxplayers()
}

public 
event_death()
{
    new 
victim read_data(2)
    
    if(
is_user_zombie(victim) && is_user_connected(victim) && get_pcvar_num(cvar_respawn))
    {
        
set_task(get_pcvar_float(cvar_timerespawn), "do_respawn"victim+TASK_RESPAWN)
    }
}

public 
round_end()
{
    static 
id;
    for(
id id <= get_maxplayers() ; id++)
    {
        if(!
is_user_connected(id))
            continue

        if(
task_exists(id+TASK_RESPAWN)) 
        {
             
remove_task(id+TASK_RESPAWN)
        }
    }
}

public 
event_infect(id)

     if(
is_user_zombie(id) && is_user_alive(id))
     { 
             
set_task(1.0"iRespawn"id)
     }
}

public 
iRespawn(id)
{
    
ExecuteHamB(Ham_CS_RoundRespawnid)  
}

public 
event_round_start() 

    static 
id 
    
for(id 1id <= g_maxplayersid++) 
    { 
        if(
is_user_connected(id)) 
        {     
            
remove_task(id+TASK_RESPAWN
        } 
    }     
}

public 
client_disconnect(id)
{
    if(
task_exists(id+TASK_RESPAWN)) 
    {
    
remove_task(id+TASK_RESPAWN)
    }
}

public 
do_respawn(taskid)
{
    static 
id
    id 
taskid TASK_RESPAWN
    
    
if(is_user_zombie(id))
    {
        
ExecuteHam(Ham_CS_RoundRespawnid)
    }
}

public 
client_putinserver(id
{     
    if(
task_exists(id+TASK_RESPAWN)) 
    {
    
remove_task(id+TASK_RESPAWN)
    }

Krtola is offline
Send a message via Skype™ to Krtola
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-31-2016 , 03:16   Re: |REQ| Respawn plugin
Reply With Quote #2

something like this

Code:
new Float:g_time[33]

in deathevent
{
g_time[victim] += 1.0

new Float:respawntime
respawntime = get_pcvar_float(cvar_respawn_time) + g_time[victim]

set_task(respawntime, "blabla", victim)
}

in end round and client disconnect
{
g_time[id] = 0.0
}
__________________

Last edited by Depresie; 01-31-2016 at 03:18.
Depresie is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 01-31-2016 , 05:41   Re: |REQ| Respawn plugin
Reply With Quote #3

Thanks. Will try as soon as I could...
Krtola is offline
Send a message via Skype™ to Krtola
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-01-2016 , 02:53   Re: |REQ| Respawn plugin
Reply With Quote #4

PHP Code:
g_time[victim] += 1.0 
=
PHP Code:
g_time[victim]++ 
PHP Code:
g_time[id] = 0.0 
=
PHP Code:
g_time[id] = 
PHP Code:
new Float:g_time[33
=
PHP Code:
new g_time[33
With this changes work.

Last edited by Krtola; 02-01-2016 at 03:27.
Krtola is offline
Send a message via Skype™ to Krtola
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 02-01-2016 , 05:00   Re: |REQ| Respawn plugin
Reply With Quote #5

Quote:
Originally Posted by Krtola View Post
PHP Code:
g_time[victim] += 1.0 
=
PHP Code:
g_time[victim]++ 
PHP Code:
g_time[id] = 0.0 
=
PHP Code:
g_time[id] = 
PHP Code:
new Float:g_time[33
=
PHP Code:
new g_time[33
With this changes work.
Probably because you create g_time as an integer not as float, Depresie show you how to increment and manage an float.
__________________
Project: Among Us

Last edited by Craxor; 02-01-2016 at 05:00.
Craxor is offline
Send a message via ICQ to Craxor
Reply



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 11:15.


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