AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]Return user to team. (https://forums.alliedmods.net/showthread.php?t=232618)

ShLuMieL 01-02-2014 09:37

[HELP]Return user to team.
 
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 :P
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;  



DavidJr 01-02-2014 09:40

Re: [HELP]Return user to team.
 
Cache his team in array.

ShLuMieL 01-02-2014 09:55

Re: [HELP]Return user to team.
 
Quote:

Originally Posted by DavidJr (Post 2079957)
Cache his team in array.

Can you show me example?

DavidJr 01-02-2014 10:04

Re: [HELP]Return user to team.
 
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
        
}
    }



ShLuMieL 01-02-2014 10:22

Re: [HELP]Return user to team.
 
But how I do when the round end the same user will get to the same team.?

DavidJr 01-02-2014 11:15

Re: [HELP]Return user to team.
 
You can use logevent and loop through alive players

ShLuMieL 01-02-2014 11:38

Re: [HELP]Return user to team.
 
Can you show me how to do it? can you add that to the plugin :O It look's complicate.

OnePL 01-02-2014 13:04

Re: [HELP]Return user to team.
 
Quote:

Originally Posted by DavidJr (Post 2079972)
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
        
}
    }



:arrow:

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



DavidJr 01-02-2014 21:45

Re: [HELP]Return user to team.
 
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
    
}



ShLuMieL 01-03-2014 14:32

Re: [HELP]Return user to team.
 
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;  




All times are GMT -4. The time now is 10:13.

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