Raised This Month: $ Target: $400
 0% 

[HELP]Return user to team.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ShLuMieL
Senior Member
Join Date: Jul 2010
Old 01-02-2014 , 09:37   [HELP]Return user to team.
Reply With Quote #1

Hello to All

I made this plugin and I dont know how to do something.

Description:
If someone die it will open for him menu that asks if he want to go to spectator until next round
if yes its move him to spectator team and strip his weapons and set him invisable

and I need that will return the player to the same team he was when the round end, this is possible?
if someone know how tell me please
Thank's.

PHP Code:
/* Plugin generated by AMXX-Studio */ 

#include <amxmodx> 
#include <amxmisc> 
#include <hamsandwich> 
#include <cstrike> 
#include <fun> 
#include <fakemeta>  
#include <engine>

#define PLUGIN "Invisible Spectator" 
#define VERSION "1.0" 
#define AUTHOR "author" 

#define cm(%0)    ( sizeof(%0) - 1 )  

const m_afButtonPressed 246;  

new 
HamHook:g_iHhCBasePlayerObjectCaps;  

public 
plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
    
    
// Add your code here... 
    
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawn"1); 
    
register_event("DeathMsg""EventDeathMsg""a" );
    
DisableHamForward(g_iHhCBasePlayerObjectCaps RegisterHam(Ham_ObjectCaps"player""OnCBasePlayer_ObjectCaps"false));
    
    
register_touch("weaponbox""player""");
    
register_touch("armoury_entity""player""");
    
register_touch("weapon_shield""player""");


public 
FwdPlayerSpawn(id

    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR
    {
        
set_task(0.3"REMOVESPECA"id
    } 


public 
EventDeathMsg(id)
{
    new 
killer read_data);
    new 
victim read_data);
    
    if( 
killer == victim || ! is_user_connectedkiller ) || ! is_user_connectedvictim ) )
    {
        return 
PLUGIN_HANDLED;
        
//return;
    
}
    
    
SpecVictim(victim)
    
    return 
PLUGIN_HANDLED;
}

public 
SpecVictim(id)
{
    new 
menu menu_create("\y[ \rInvisivle Spector \y] \wDo you want to go to Spector Team until this round end?""SpecVictim_Handler" );
    
menu_additem(menu"Yes"""0);
    
menu_additem(menu"No"""0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL );
    
menu_display(idmenu);
    
    return 
PLUGIN_HANDLED;
}

public 
SpecVictim_Handler(idmenuitem
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    switch(
item)
    {
        case 
0:
        {
            if (!
is_user_alive(id))
            {
                
ExecuteHam(Ham_CS_RoundRespawn,id);
                
cs_set_user_team(idCS_TEAM_SPECTATOR)
                
set_task(0.3"REMOVESPECA"id
            }
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
REMOVESPECA(id
{
    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0)
    
set_user_godmode(id1)
    
strip_user_weapons(id)
    
EnableHamForward(g_iHhCBasePlayerObjectCaps);  
}

public 
OnCBasePlayer_ObjectCaps(id)  
{  
    new 
buttons pev(idpev_button);  
    if( 
buttons IN_USE )  
    {  
        
set_pev(idpev_buttonbuttons & ~IN_USE);  
    }  
    
buttons get_pdata_int(idm_afButtonPressed);  
    if( 
buttons IN_USE )  
    {  
        
set_pdata_int(idm_afButtonPressedbuttons & ~IN_USE);  
    }  
    return 
HAM_HANDLED;  


Last edited by ShLuMieL; 01-02-2014 at 09:38.
ShLuMieL is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-02-2014 , 09:40   Re: [HELP]Return user to team.
Reply With Quote #2

Cache his team in array.
__________________
What are you looking for here?
DavidJr is offline
ShLuMieL
Senior Member
Join Date: Jul 2010
Old 01-02-2014 , 09:55   Re: [HELP]Return user to team.
Reply With Quote #3

Quote:
Originally Posted by DavidJr View Post
Cache his team in array.
Can you show me example?
ShLuMieL is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-02-2014 , 10:04   Re: [HELP]Return user to team.
Reply With Quote #4

PHP Code:
new g_Team[33//create global array

enum
{
    
T_TEAM 1,
    
CT_TEAM
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""fwd_Spawn_Post"1// spawn forward to check user team when spawn
}

public 
fwd_Spawn_Post(id)
{
    if (
is_user_alive(id))
    {
        if (
cs_get_user_team(id) == CS_TEAM_T// if user team is ct
        
{
            
g_Team[id] = T_TEAM // save user team as in g_Team
        
}
        else if (
cs_get_user_team(id) == CS_TEAM_CT)
        {
            
g_Team[id] = CT_TEAM // save user team as in g_Team
        
}
        
        if (
g_Team[id] == T_TEAM// if g_Team is equal with team T
        
{
            
cs_set_user_team(idCS_TEAM_T//set to T
        
}
        else
        {
            
cs_set_user_team(idCS_TEAM_CT)  //set to CT
        
}
    }

__________________
What are you looking for here?
DavidJr is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 01-02-2014 , 13:04   Re: [HELP]Return user to team.
Reply With Quote #5

Quote:
Originally Posted by DavidJr View Post
PHP Code:
new g_Team[33//create global array

enum
{
    
T_TEAM 1,
    
CT_TEAM
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""fwd_Spawn_Post"1// spawn forward to check user team when spawn
}

public 
fwd_Spawn_Post(id)
{
    if (
is_user_alive(id))
    {
        if (
cs_get_user_team(id) == CS_TEAM_T// if user team is ct
        
{
            
g_Team[id] = T_TEAM // save user team as in g_Team
        
}
        else if (
cs_get_user_team(id) == CS_TEAM_CT)
        {
            
g_Team[id] = CT_TEAM // save user team as in g_Team
        
}
        
        if (
g_Team[id] == T_TEAM// if g_Team is equal with team T
        
{
            
cs_set_user_team(idCS_TEAM_T//set to T
        
}
        else
        {
            
cs_set_user_team(idCS_TEAM_CT)  //set to CT
        
}
    }



PHP Code:
public fwd_Spawn_Post(id)
{
    if (!
is_user_alive(id)) return

    
g_Team[id] = cs_get_user_team(id// save user team as in g_Team
    
cs_set_user_team(idg_Team[id]) //set Team

OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
ShLuMieL
Senior Member
Join Date: Jul 2010
Old 01-02-2014 , 10:22   Re: [HELP]Return user to team.
Reply With Quote #6

But how I do when the round end the same user will get to the same team.?
ShLuMieL is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-02-2014 , 11:15   Re: [HELP]Return user to team.
Reply With Quote #7

You can use logevent and loop through alive players
__________________
What are you looking for here?
DavidJr is offline
ShLuMieL
Senior Member
Join Date: Jul 2010
Old 01-02-2014 , 11:38   Re: [HELP]Return user to team.
Reply With Quote #8

Can you show me how to do it? can you add that to the plugin :O It look's complicate.
ShLuMieL is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 01-02-2014 , 21:45   Re: [HELP]Return user to team.
Reply With Quote #9

Try this:
PHP Code:
new g_Team[33//create global array

enum
{
    
T_TEAM 1,
    
CT_TEAM
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("logevent_round_end"2"1=Round_End")
    
    
RegisterHam(Ham_Spawn"player""fwd_Spawn_Post"1// spawn forward to check user team when spawn
}

public 
logevent_round_end()
{
    new 
players[32], numplayer
    get_players
(playersnum"a")
    
    for (new 
num ; ++i)
    {
        
player players[i]
        if (
g_Team[player] == T_TEAM// if g_Team is equal with team T
        
{
            
cs_set_user_team(playerCS_TEAM_T//set to T
        
}
        else
        {
            
cs_set_user_team(playerCS_TEAM_CT)  //set to CT
        
}
    }
}

public 
fwd_Spawn_Post(id)
{
    if (!
is_user_alive(id)) return;
    
    if (
cs_get_user_team(id) == CS_TEAM_T// if user team is ct
    
{
        
g_Team[id] = T_TEAM // save user team as in g_Team
    
}
    else if (
cs_get_user_team(id) == CS_TEAM_CT)
    {
        
g_Team[id] = CT_TEAM // save user team as in g_Team
    
}

__________________
What are you looking for here?
DavidJr is offline
ShLuMieL
Senior Member
Join Date: Jul 2010
Old 01-03-2014 , 14:32   Re: [HELP]Return user to team.
Reply With Quote #10

Juk helped me with that yesterday on skype

PHP Code:
/* Plugin generated by AMXX-Studio */ 

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <engine>

#define PLUGIN "Invisible Spectator" 
#define VERSION "1.0" 
#define AUTHOR "author" 

#define cm(%0)    ( sizeof(%0) - 1 )  

const m_afButtonPressed 246;  

new 
HamHook:g_iHhCBasePlayerObjectCaps;  

new 
gTeams[33];

public 
plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
    
    
// Add your code here... 
    
    
register_clcmd("say /gospec""SpecVictim");
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawn"1);
    
register_logevent("logevent_round_end"2"1=Round_End")
    
register_event("DeathMsg""EventDeathMsg""a" );
    
DisableHamForward(g_iHhCBasePlayerObjectCaps RegisterHam(Ham_ObjectCaps"player""OnCBasePlayer_ObjectCaps"false));
    
    
RegisterHam(Ham_Touch"armoury_entity""blockOperationArmor");
    
RegisterHam(Ham_Touch"weaponbox""blockOperationWeapon");
    
RegisterHam(Ham_Touch"weapon_shield""blockOperationShield")
}

public 
FwdPlayerSpawn(id)
{
    
give_item(id"weapon_knife")
    
set_user_godmode(id0)
    
DisableHamForward(g_iHhCBasePlayerObjectCaps);
}

public 
logevent_round_end()
{
    for(new 
32 ++)
    {
        if(
is_user_connected(i) && (cs_get_user_team(i) == CS_TEAM_SPECTATOR))
        {
            if(
gTeams[i] != 0)
            {
                
cs_set_user_team(igTeams[i]);
                
gTeams[i] = 0;
            }
        }
    }
}

public 
EventDeathMsg(id)
{
    new 
killer read_data);
    new 
victim read_data);
    
    if( 
killer == victim || ! is_user_connectedkiller ) || ! is_user_connectedvictim ) )
    {
        return 
PLUGIN_HANDLED;
        
//return;
    
}
    
    if(
cs_get_user_team(victim) != CS_TEAM_SPECTATOR)
    {
        
set_task(0.5"SpecVictim"victim)
    }
    
    return 
PLUGIN_HANDLED;
}

public 
SpecVictim(id)
{
    if (!
is_user_alive(id))
    {
        new 
menu menu_create("\y[ \rInvisivle Spector \y] \wDo you want to go to Spector Team until this round end?""SpecVictim_Handler" );
        
menu_additem(menu"Yes"""0);
        
menu_additem(menu"No"""0);
        
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(idmenu0);
    }
    
    return 
PLUGIN_HANDLED;
}

public 
SpecVictim_Handler(idmenuitem
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    switch(
item)
    {
        case 
0:
        {
            if (!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR)
            {
                
ExecuteHam(Ham_CS_RoundRespawn,id);
                
gTeams[id] = get_user_team(id)
                
cs_set_user_team(idCS_TEAM_SPECTATOR)
                
REMOVESPECA(id)
            }    
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
REMOVESPECA(id
{
    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR)
    {
        
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0)
        
set_user_godmode(id1)
        
strip_user_weapons(id)
        
EnableHamForward(g_iHhCBasePlayerObjectCaps);
        
        
set_task(0.1"REMOVESPECA"id)
    }
}

// BLOCK OPERATION
///////////////////////////////////////////
public blockOperationArmor(id)
{
    return (
cs_get_user_team(id) == CS_TEAM_SPECTATOR) ?  HAM_SUPERCEDE HAM_IGNORED
}

public 
blockOperationShield(id)
{
    return (
cs_get_user_team(id) == CS_TEAM_SPECTATOR) ?  HAM_SUPERCEDE HAM_IGNORED
}

public 
blockOperationWeapon(weaponboxid)
{
    return (
cs_get_user_team(id) == CS_TEAM_SPECTATOR) ?  HAM_SUPERCEDE HAM_IGNORED
}

// BLOCK E KEY
///////////////////////////////////////////
public OnCBasePlayer_ObjectCaps(id)  
{  
    new 
buttons pev(idpev_button);  
    if( 
buttons IN_USE )  
    {  
        
set_pev(idpev_buttonbuttons & ~IN_USE);  
    }  
    
buttons get_pdata_int(idm_afButtonPressed);  
    if( 
buttons IN_USE )  
    {  
        
set_pdata_int(idm_afButtonPressedbuttons & ~IN_USE);  
    }  
    return 
HAM_HANDLED;  

ShLuMieL 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 10:14.


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