Raised This Month: $32 Target: $400
 8% 

help :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Murz
Member
Join Date: Jan 2015
Location: Lithuania Vilnius
Old 04-30-2016 , 15:08   help :)
Reply With Quote #1

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;
}
Murz is offline
Send a message via Skype™ to Murz
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 04-30-2016 , 15:33   Re: help :)
Reply With Quote #2

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))

Last edited by siriusmd99; 04-30-2016 at 15:39.
siriusmd99 is offline
Murz
Member
Join Date: Jan 2015
Location: Lithuania Vilnius
Old 05-06-2016 , 03:42   Re: help :)
Reply With Quote #3

Quote:
Originally Posted by siriusmd99 View Post
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;
}

Last edited by Murz; 05-06-2016 at 03:53.
Murz is offline
Send a message via Skype™ to Murz
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:08.


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