AlliedModders

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

Murz 04-30-2016 15:08

help :)
 
Hello, all how to resolve this problem
this plugin should respawn first killed player

Quote:

L 04/26/2016 - 17:42:22: [HAMSANDWICH] Entity has null private data (32)
L 04/26/2016 - 17:42:22: [AMXX] Displaying debug trace (plugin "pirmas_mires_respawn.amxx", version "1.1")
L 04/26/2016 - 17:42:22: [AMXX] Run time error 10: native error (native "ExecuteHamB")
L 04/26/2016 - 17:42:22: [AMXX] [0] pirmas_mires_respawn.sma::Respawn (line 45)
Code:

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
 
new bool:gRespawn = true;
 
public plugin_init()
{
    register_plugin("Respawn After 20 Seconds", "1.1", "hleV");
 
    register_logevent("JoinedTeam", 3, "1=joined team");
 
    RegisterHam(Ham_Spawn, "player", "Spawn", 1);
    RegisterHam(Ham_Killed, "player", "Killed", 1);
 
    register_logevent("logevent_round_end", 2, "1=Round_End") 
}
 
public JoinedTeam()
{
    new Name[32];
    read_logargv(0, Name, 31);
    parse_loguser(Name, Name, 31);
    new Cl = get_user_index(Name);
 
    if (!task_exists(Cl))
        set_task(20.0, "Respawn", Cl);
}
 
public Spawn(Client)
{
    if (is_user_alive(Client))
        remove_task(Client);
}
 
public Killed(Client)
{
    if (!task_exists(Client))
        set_task(20.0, "Respawn2", Client);
}
 
public Respawn(Client)
{
    if (!is_user_alive(Client))
        ExecuteHamB(Ham_CS_RoundRespawn, Client);
}
 
public Respawn2(Client)
{
    if (!is_user_alive(Client))
    {
        if(gRespawn)
        {
            cs_user_spawn(Client);
            gRespawn = false;
        }
    }
}
 
public logevent_round_end( )
{
    gRespawn = true;
}


siriusmd99 04-30-2016 15:33

Re: help :)
 
Because you check if he is not alive but you don't check if he is connected.
You bassicaly are respawning a non connected player.

It confuses because if player is not connected then is_user_alive(id) will return false as it was connected but dead.
So use this instead in both respawn cases:

Quote:

if (!is_user_alive(Client) && is_user_connected(Client))

Murz 05-06-2016 03:42

Re: help :)
 
Quote:

Originally Posted by siriusmd99 (Post 2415492)
Because you check if he is not alive but you don't check if he is connected.
You bassicaly are respawning a non connected player.

It confuses because if player is not connected then is_user_alive(id) will return false as it was connected but dead.
So use this instead in both respawn cases:

thanks now no error
but another problem plugin work not correctly I would need each round first killed player respawn

now its 1 round ok 1 killed respawned from second round last killed respawned
siriusmd99 can help resolve this ?

Code:

#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
 
new bool:gRespawn = true;
 
public plugin_init()
{
    register_plugin("Respawn After 20 Seconds", "1.1", "hleV");
 
    register_logevent("JoinedTeam", 3, "1=joined team");
 
    RegisterHam(Ham_Spawn, "player", "Spawn", 1);
    RegisterHam(Ham_Killed, "player", "Killed", 1);
 
    register_logevent("logevent_round_end", 2, "1=Round_End") 
}
 
public JoinedTeam()
{
    new Name[32];
    read_logargv(0, Name, 31);
    parse_loguser(Name, Name, 31);
    new Cl = get_user_index(Name);
 
    if (!task_exists(Cl))
        set_task(0.5, "Respawn", Cl);
}
 
public Spawn(Client)
{
    if (!is_user_alive(Client) && is_user_connected(Client))
        remove_task(Client);
}
 
public Killed(Client)
{
    if (!task_exists(Client))
        set_task(0.5, "Respawn2", Client);
}
 
public Respawn(Client)

    if (!is_user_alive(Client) && is_user_connected(Client))
        cs_user_spawn(Client);
}
 
public Respawn2(Client)

    if (!is_user_alive(Client) && is_user_connected(Client))
    {
        if(gRespawn)
        {
            cs_user_spawn(Client);
            gRespawn = false;
        }
    }
}
 
public logevent_round_end( )
{
    gRespawn = true;
}



All times are GMT -4. The time now is 18:36.

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