Raised This Month: $ Target: $400
 0% 

respawn plugin help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kp3t3h
Senior Member
Join Date: Feb 2011
Old 05-12-2012 , 13:40   respawn plugin help
Reply With Quote #1

can someone find the flaws here
its not working as it should'
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>

#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "01"


new Countdown[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("DeathMsg","StartCountdown","a")
}

public 
StartCountdown(id)
{
       
       
        
Countdown[id] = 20    
        
        
if(task_exists(id 3431))
        {
                
remove_task(id 3431)
        }
        
set_task(1.0"fin"id 3431__"b")
        
        return 
PLUGIN_CONTINUE
}

public 
fin(task_id)
{
        new 
id task_id 3431
        
        set_hudmessage
(02550, -1.00.406.01.0)
        
show_hudmessage(id"Respawn za : %d"Countdown[id]) 
        
        
Countdown[id] -= 
        
        
if(Countdown[id] <= 0)
        {
                if(
task_exists(task_id))
                {
                        
remove_task(task_id)
                }
                
respawn(id)
        }
}

public 
respawn(id
{      
    if (!
is_user_connected(id) || is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)         return; 
    
    
set_pev(idpev_deadflagDEAD_RESPAWNABLE
    
dllfunc(DLLFunc_Thinkid
    
    if (
is_user_bot(id) && pev(idpev_deadflag) == DEAD_RESPAWNABLE
    { 
        
dllfunc(DLLFunc_Spawnid
    } 

__________________
need help with the following
no.1, no.2, no.3, no.4 no.5
kp3t3h is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-12-2012 , 13:43   Re: respawn plugin help
Reply With Quote #2

Function StartCountdown doesn't have an index.
You should get it by making a new variable inside the function and setting it's value to read_data(2), which is the index of the victim (i.e. killed player).
__________________
<VeCo> is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-12-2012 , 13:45   Re: respawn plugin help
Reply With Quote #3

Put Countdown[id] -= 1 at the enf of fin() function.

Also, you can replace respawn(id) with ExecuteHam(Ham_CS_RoundRespawn, id), will perfectly work with bots and humans.

Lasy, you can remove task_exists checks, remove_task is already performing that check.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kp3t3h
Senior Member
Join Date: Feb 2011
Old 05-12-2012 , 14:01   Re: respawn plugin help
Reply With Quote #4

i have done the changes and now the server crashes when it is supposed to respwan
i need the counter and at the end to respawn
also i dont want bots or spectators to be revived

can you change it and put the full code here. tahkns
__________________
need help with the following
no.1, no.2, no.3, no.4 no.5

Last edited by kp3t3h; 05-12-2012 at 14:47.
kp3t3h is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-12-2012 , 15:23   Re: respawn plugin help
Reply With Quote #5

Try :

PHP Code:
#include <amxmodx>

#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <fun>

#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "01"

new g_iCountdown[33]
new 
g_pCvarRespawnDelay

enum _
:PlayersTasksOffsets (+=33) {
    
TASK_PLAYER_RESPAWN,
// id %= 33 in task callback


public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_pCvarRespawnDelay register_cvar("amx_respawn_delay""20")
    
RegisterHam(Ham_Killed"player""CBasePlayer_Killed_Post"true)
}

public 
CBasePlayer_Killed_Post(id)
{
    
g_iCountdown[id] = get_pcvar_num(g_pCvarRespawnDelay)

    
remove_task(id TASK_PLAYER_RESPAWN)
    
set_task(1.0"fin"id TASK_PLAYER_RESPAWN, .flags="b")
    
ShowPlayerRespawnTimeid )
    --
g_iCountdown[id]
}

ShowPlayerRespawnTimeid )
{
    
set_hudmessage(02550, -1.00.406.01.0, .channel = -1)
    
show_hudmessage(id"Respawn za : %d"g_iCountdown[id]) 
}

public 
fin(task_id)
{
    new 
id task_id 33

    
if( !is_user_connected(id) || is_user_alive(id) )
    {
        
remove_tasktask_id )
        return
    }

    if(
g_iCountdown[id] <= 0)
    {
        
remove_task(task_id)
        
ExecuteHam(Ham_CS_RoundRespawnid)
        return
    }

    
ShowPlayerRespawnTimeid )

    --
g_iCountdown[id]

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kp3t3h
Senior Member
Join Date: Feb 2011
Old 05-12-2012 , 15:36   Re: respawn plugin help
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
Try :

PHP Code:
#include <amxmodx>

#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <fun>

#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "01"

new g_iCountdown[33]
new 
g_pCvarRespawnDelay

enum _
:PlayersTasksOffsets (+=33) {
    
TASK_PLAYER_RESPAWN,
// id %= 33 in task callback


public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_pCvarRespawnDelay register_cvar("amx_respawn_delay""20")
    
RegisterHam(Ham_Killed"player""CBasePlayer_Killed_Post"true)
}

public 
CBasePlayer_Killed_Post(id)
{
    
g_iCountdown[id] = get_pcvar_num(g_pCvarRespawnDelay)

    
remove_task(id TASK_PLAYER_RESPAWN)
    
set_task(1.0"fin"id TASK_PLAYER_RESPAWN, .flags="b")
    
ShowPlayerRespawnTimeid )
    --
g_iCountdown[id]
}

ShowPlayerRespawnTimeid )
{
    
set_hudmessage(02550, -1.00.406.01.0, .channel = -1)
    
show_hudmessage(id"Respawn za : %d"g_iCountdown[id]) 
}

public 
fin(task_id)
{
    new 
id task_id 33

    
if( !is_user_connected(id) || is_user_alive(id) )
    {
        
remove_tasktask_id )
        return
    }

    if(
g_iCountdown[id] <= 0)
    {
        
remove_task(task_id)
        
ExecuteHam(Ham_CS_RoundRespawnid)
        return
    }

    
ShowPlayerRespawnTimeid )

    --
g_iCountdown[id]

it works good now,
but the hud message is blurry

edti
nvm, got it working great now
__________________
need help with the following
no.1, no.2, no.3, no.4 no.5

Last edited by kp3t3h; 05-13-2012 at 04:44.
kp3t3h is offline
Reply


Thread Tools
Display Modes

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 00:23.


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