Raised This Month: $ Target: $400
 0% 

Respawned player is flying


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hitmany
Senior Member
Join Date: Jul 2010
Old 11-01-2013 , 01:59   Respawned player is flying
Reply With Quote #1

Hello AlliedModders!
My plugin must respawn player after dead. But spawned player flying like spectator.

some parts of plugin:
PHP Code:
#define XO_PLAYER                5 
#define m_iMenuCode                205 
// #define m_iSpawnTimes            365 

#define Menu_ChooseAppearance    3 
#define cs_get_user_menu(%0)    get_pdata_int(%0, m_iMenuCode, XO_PLAYER) 

#define DISABLE_CS 0

// team ids 
#define UNASSIGNED 0 
#define TS 1 
#define CTS 2 
#define AUTO_TEAM 5 

public plugin_init()
{
        
register_event"DeathMsg""death_event""a" )
        
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET

        
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0"
        
register_logevent("on_EndRound"2"0=World triggered""1=Round_End")
        
        
//events used in plugin
        
register_event("ResetHUD""ResetHUD""be")
        
RegisterHam(Ham_TakeDamage"player""TakeDamage"1);
        
register_event("CurWeapon""Event_Change_Weapon""be""1=1")
    
RegisterHam(Ham_Spawn"player""HamPlayerSpawn"1);
}

public 
on_EndRound()
{
        
g_bRoundEnd true 
}

public 
Event_HLTV_New_Round() 

        
g_bRoundEnd false 
}

public 
death_event()
{    
    if( !
is_user_alive (id) && !g_bRoundEnd && cs_get_user_menu(id) != Menu_ChooseAppearance && HasRespawn[id] && !respawned[id]) 
    { 
        
respawned[id] = 1;
        new 
parm[1]
        
parm[0]=id
        
/* Spawn the player twice to avoid the HL engine bug */
        
set_task(0.5,"player_spawn",72,parm,1)
        
set_task(0.7,"player_spawn",72,parm,1)

        
/* Then give them a suit and a knife */
        
set_task(0.9,"player_giveitems",72,parm,1)
    } 
}

public 
player_giveitems(parm[1])
{
    new 
id parm[0]

    
give_item(id"item_suit")
    
give_item(id"weapon_knife")

    
/* Determines if a players should be given a pistol */
    
new wpnList[32] = 0number 0bool:foundGlock falsebool:foundUSP false 
    get_user_weapons
(id,wpnList,number)
    
    
/* Determine if the player already has a pistol */
    
for (new 0;number;i++)
    { 
        if (
wpnList[i] == CSW_GLOCK18
            
foundGlock true 
        
if (wpnList[i] == CSW_USP
            
foundUSP true 
    
}
    
    
/* Give a T his/her pistol */
    
if ( get_user_team(id)==TS && !foundGlock )
    {
            
give_item(id,"weapon_glock18")
            
give_item(id,"ammo_9mm")
            
give_item(id,"ammo_9mm")
    }
    
/* Give a CT his/her pistol */
    
else if ( get_user_team(id)==CTS && !foundUSP )
    {
            
give_item(id,"weapon_usp")
            
give_item(id,"ammo_45acp")
            
give_item(id,"ammo_45acp")
    }

    return 
PLUGIN_CONTINUE
}

public 
player_spawn(parm[1])
{
    
spawn(parm[0])

hitmany is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-01-2013 , 04:29   Re: Respawned player is flying
Reply With Quote #2

You use a wrong respawn method.

Use this instead, you don't need to give items with this method.

PHP Code:
enum _:playersTasks (+= 33)
{
    
TASK_PLR_RESPAWN,
    
// TASK_PLR_GIVEITEMS // not needed
}

public 
death_event() 
{
    if( !
g_bRoundEnd && HasRespawn[id] && !respawned[id] && !is_user_alive(id) && cs_get_user_menu(id) != Menu_ChooseAppearance )
    {
        
set_task(0.1"player_spawn"TASK_PLR_RESPAWN id);
        
// set_task(0.2, "player_giveitems", TASK_PLR_GIVEITEMS + id); // not needed
    
}


public 
player_spawnid 
{
    
id %= 33;
    if( 
is_user_connected(id) && !is_user_alive(id) )
    {
        
ExecuteHamB(Ham_CS_RoundRespawnid);
        if( 
is_user_alive(id) )
        {
            
respawned[id] = 1;
        }
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hitmany
Senior Member
Join Date: Jul 2010
Old 11-02-2013 , 04:20   Re: Respawned player is flying
Reply With Quote #3

Thank you for reply.
But its not help me, i am flying like spectator again.
hitmany is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2013 , 04:41   Re: Respawned player is flying
Reply With Quote #4

And it is not related to the code you have given.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hitmany
Senior Member
Join Date: Jul 2010
Old 11-02-2013 , 04:46   Re: Respawned player is flying
Reply With Quote #5

My fault,thats work. Many thanks!

Last edited by hitmany; 11-02-2013 at 05:21.
hitmany is offline
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 23:21.


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