AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   respawn plugin help (https://forums.alliedmods.net/showthread.php?t=185080)

kp3t3h 05-12-2012 13:40

respawn plugin help
 
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
    } 



<VeCo> 05-12-2012 13:43

Re: respawn plugin help
 
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).

ConnorMcLeod 05-12-2012 13:45

Re: respawn plugin help
 
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.

kp3t3h 05-12-2012 14:01

Re: respawn plugin help
 
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

ConnorMcLeod 05-12-2012 15:23

Re: respawn plugin help
 
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]



kp3t3h 05-12-2012 15:36

Re: respawn plugin help
 
Quote:

Originally Posted by ConnorMcLeod (Post 1707590)
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


All times are GMT -4. The time now is 00:23.

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