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

Solved Revive menu: i want to understand small part of this plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-19-2021 , 16:53   Revive menu: i want to understand small part of this plugin
Reply With Quote #1

Code:
/*
	Blizzards Plugins Comply With GNU General Public License

	Revive System is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	Under no circumstances are you allowed to redistribute and/or modify
	it claming that you are the original author of such plugin/modification.
	
	Revive System is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
	
*/

#include <amxmodx>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <amxmisc>
												#pragma semicolon 1
new g_iReviveTeam[ 33 ];
new g_pReviveMsg;

public plugin_init( ) 
{
	register_plugin( "Revive System", "1.0", "Blizzards" );
	
	g_pReviveMsg = register_cvar( "amx_revive_msg", "1" );
	
	register_concmd( "cmdRevive", "cmdRevive", ADMIN_IMMUNITY );
	register_clcmd( "say /revive", "cmdReviveMenu" );
}

public cmdReviveMenu( id )
{
	if( !has_flag( id, "a" ) )
	{
		client_print( id, print_center, "You Are Not Authorized" );
		client_cmd( id, "spk ^"access denied^"" );
		return PLUGIN_HANDLED;
	}
	
	new menu = menu_create( "\rRevive Menu V1.2", "cmdReviveMenu_handler" );
	
	new players[32], pnum, tempid;
	
	new szName[32], szUserId[32], Desc[ 64 ];
	
	get_players( players, pnum ); 
	
	menu_additem( menu, "\yRevive Team \w[ \rCT/Terrorist/All\w ]" );
	switch( g_iReviveTeam[ id ] )
	{
		case 0: menu_additem( menu, "\yPlayer Team \w[ \rTerrorist\w ]^n" );
		case 1: menu_additem( menu, "\yPlayer Team \w[ \rCT\w ]^n" );
	}
	for ( new i; i<pnum; i++ )
	{
		tempid = players[i];
		
		get_user_name( tempid, szName, charsmax( szName ) );
		formatex( Desc, charsmax( Desc ), "%s [ \r%s\w ] [ %s \w]", szName, get_team_name( tempid ), is_user_alive( tempid ) ? "Alive" : "\dDead" );
		formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );
		menu_additem( menu, Desc, szUserId, 0 );
	}	
	
	menu_display( id, menu, 0 );
	return PLUGIN_HANDLED;
}

public cmdReviveMenu_handler( id, menu, item )
{
	if ( item == MENU_EXIT )
	{
		menu_destroy( menu );
		return PLUGIN_HANDLED;
	}
	
	new szData[6], szName[64], szName2[ 64 ];
	new item_access, item_callback;
	
	menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
	
	new userid = str_to_num( szData );
	
	new player = find_player( "k", userid );
	
	if( item == 0 )
	{
		client_cmd( id, "messagemode cmdRevive" );
		set_hudmessage(255, 255, 85, 0.01, 0.18, 2, 0.5, 6.0, 0.05, 0.05, -1);
		show_hudmessage(id, "Type Either @all, @ct, @t");
		menu_destroy( menu );
		return PLUGIN_HANDLED;
	}
	
	if( !player )
	{
		switch( g_iReviveTeam[ id ] )
		{
			case 0: g_iReviveTeam[ id ]++;
			case 1: g_iReviveTeam[ id ]--;
		}
		cmdReviveMenu( id );
	}
	get_user_name( id, szName2, charsmax( szName2 ) );
	get_user_name( player, szName, charsmax( szName ) );
	if ( player )
	{
		switch( g_iReviveTeam[ id ] )
		{
			case 0: {
				if( is_user_alive( player ) ) user_silentkill( player );
				cs_set_user_team( player, CS_TEAM_T, CS_T_TERROR );
				ExecuteHamB( Ham_CS_RoundRespawn, player );
				if( get_pcvar_num( g_pReviveMsg ) )
					client_print( 0, print_chat, "[ AMXX ] ADMIN: %s Revived %s On Team Terrorist", szName2, szName );
			}
			case 1: {
				if( is_user_alive( player ) ) user_silentkill( player );
				cs_set_user_team( player, CS_TEAM_CT, CS_CT_SAS );
				ExecuteHamB( Ham_CS_RoundRespawn, player );
				if( get_pcvar_num( g_pReviveMsg ) )
					client_print( 0, print_chat, "[ AMXX ] ADMIN: %s Revived %s On Team Counter-Terrorist", szName2, szName );
			}
		}		
	}
	
	menu_destroy( menu );
	cmdReviveMenu( id );
	return PLUGIN_HANDLED;
}

public cmdRevive( id, lvl, cid )
{
	if( !cmd_access( id, lvl, cid, 2 ) )
	{
		client_print( id, print_console, "[ AMXX ] You Are Not Authorized" );
		client_cmd( id, "spk ^"access denied^"" );
		return PLUGIN_HANDLED;
	}
		
	
	new iArg[ 64 ], szName[ 32 ];
	read_argv( 1, iArg, charsmax( iArg ) );
	get_user_name( id, szName, charsmax( szName ) );
	
	new iPlayers[ 32 ], iNum, i, players;
		
	if( equal( iArg, "@all" ) )
	{
		get_players( iPlayers, iNum );
		for( i = 0; i < iNum; i++ )
		{
			players = iPlayers[ i ];
			if( !is_user_alive( players ) ) ExecuteHamB( Ham_CS_RoundRespawn, players );
		}
		if( get_pcvar_num( g_pReviveMsg ) )
			client_print( 0, print_chat, "[ AMXX ] ADMIN: %s Revived All Dead Players", szName );
	}
	else if( equal( iArg, "@ct" ) )
	{
		get_players( iPlayers, iNum, "e", "CT" );
		for( i = 0; i < iNum; i++ )
		{
			players = iPlayers[ i ];
			if( !is_user_alive( players ) ) ExecuteHamB( Ham_CS_RoundRespawn, players );
		}
		if( get_pcvar_num( g_pReviveMsg ) )
			client_print( 0, print_chat, "[ AMXX ] ADMIN: %s Revived All Dead CT Players", szName );
	}
	else if( equal( iArg, "@t" ) )
	{
		get_players( iPlayers, iNum, "e", "TERRORIST" );
		for( i = 0; i < iNum; i++ )
		{
			players = iPlayers[ i ];
			if( !is_user_alive( players ) ) ExecuteHamB( Ham_CS_RoundRespawn, players );
		}
		if( get_pcvar_num( g_pReviveMsg ) )
			client_print( 0, print_chat, "[ AMXX ] ADMIN: %s Revived All Dead Terrorist Players", szName );
	}
	else if( equal( iArg, "" ) || !equal( iArg, "@all") || !equal( iArg, "@ct") || !equal( iArg, "@t") )
	{
		client_print( id, print_chat, "[ AMXX ] You Must Select Either @all, @ct, @t" );
		cmdReviveMenu( id );
		return PLUGIN_HANDLED;
	}
	
	return PLUGIN_HANDLED;
}

public client_connect( id ) 
{
g_iReviveTeam[ id ] = 0;
}

stock get_team_name( id )
{
	new string[ 32 ];
	switch( cs_get_user_team( id ) )
	{
		case CS_TEAM_T: formatex( string, charsmax( string ), "Terrorist" );
		case CS_TEAM_CT: formatex( string, charsmax( string ), "CT" );
	}
	
	return string;
}
I dont undertand this part

how does this code work ?!!, i tried to add option like spectator but didn't work!!

PHP Code:
switch( g_iReviveTeamid ] )
    {
        case 
0menu_additemmenu"\yPlayer Team \w[ \rTerrorist\w ]^n" );
        case 
1menu_additemmenu"\yPlayer Team \w[ \rCT\w ]^n" );
    }
//  g_iReviveTeam[ id ]++; = case 0 !!
// g_iReviveTeam[ id ]--; = case 1

switch( g_iReviveTeamid ] )
        {
            case 
0g_iReviveTeamid ]++;
            case 
1g_iReviveTeamid ]--;
        } 
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 11-19-2021 at 20:36.
Supremache is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 11-19-2021 , 17:07   Re: Revive menu: i want to understand small part of this plugin
Reply With Quote #2

Is the second block all you changed? Your plugin has to have code to move to spectate, not just a menu entry.
The code you are asking about looks like it just swaps the number from 0 to 1 and vise versa. If it's case 0, then we want to increment the 0 by 1. If the case is 1, then we want to decrement the number by 1 to make it 0.

The word Team is mentioned throughout your plugin. Find those places and add your entries where applicable.

Code:
cs_set_user_team( player, CS_TEAM_CT, CS_CT_SAS );
Make sure you have the correct name when changing this one too. CS_TEAM_SPECTATOR

Last edited by Sreaper; 11-19-2021 at 17:16.
Sreaper is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-19-2021 , 17:22   Re: Revive menu: i want to understand small part of this plugin
Reply With Quote #3

Quote:
Originally Posted by Sreaper View Post
Is the second block all you changed? Your plugin has to have code to move to spectate, not just a menu entry.
The word Team is mentioned throughout your plugin. Find those places and add your entries where applicable.

Code:
cs_set_user_team( player, CS_TEAM_CT, CS_CT_SAS );
Make sure you have the correct name when changing this one too.
First I'm not the author of this plugin i just liked the style of the menu selecting the team and the player in the same menu but i dont understand how to add other option like spectator

2th: i did what you are talking about but it didn't work
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 11-19-2021 at 17:38.
Supremache is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 11-19-2021 , 17:50   Re: Revive menu: i want to understand small part of this plugin
Reply With Quote #4

Quote:
Originally Posted by Supremache View Post
I don't think you can do this:

Code:
    if( !player )
    {
        switch( g_iReviveTeam[ id ] )
        {
            case 0: g_iReviveTeam[ id ]++;
            case 1: g_iReviveTeam[ id ]--;
            case 2: g_iReviveTeam[ id ]++;
        }
        cmdReviveMenu( id );
    }
I think that would try to go to Case 3 which doesn't exist when you are on Case 2. And if you do make it to Case 1, then it wont ever reach Case 2 because of the --.


Maybe try:
Code:
    if( !player )
    {
        switch( g_iReviveTeam[ id ] )
        {
            case 0: g_iReviveTeam[ id ]++;
            case 1: g_iReviveTeam[ id ]++;
            case 2: g_iReviveTeam[ id ]--;
        }
        cmdReviveMenu( id );
    }
Apologies if this doesn't help or solve your issue. I don't have any amxx related games to test things on so I'm only guessing.

Last edited by Sreaper; 11-19-2021 at 18:05.
Sreaper is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-19-2021 , 19:06   Re: Revive menu: i want to understand small part of this plugin
Reply With Quote #5

Quote:
Originally Posted by Sreaper View Post
I don't think you can do this:

Code:
    if( !player )
    {
        switch( g_iReviveTeam[ id ] )
        {
            case 0: g_iReviveTeam[ id ]++;
            case 1: g_iReviveTeam[ id ]--;
            case 2: g_iReviveTeam[ id ]++;
        }
        cmdReviveMenu( id );
    }
I think that would try to go to Case 3 which doesn't exist when you are on Case 2. And if you do make it to Case 1, then it wont ever reach Case 2 because of the --.


Maybe try:
Code:
    if( !player )
    {
        switch( g_iReviveTeam[ id ] )
        {
            case 0: g_iReviveTeam[ id ]++;
            case 1: g_iReviveTeam[ id ]++;
            case 2: g_iReviveTeam[ id ]--;
        }
        cmdReviveMenu( id );
    }
Apologies if this doesn't help or solve your issue. I don't have any amxx related games to test things on so I'm only guessing.
First time it show the three case's but when i use it again it show only case 1, case 2, but doesn't show case 0
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-19-2021 , 20:35   Re: Revive menu: i want to understand small part of this plugin
Reply With Quote #6

Quote:
Originally Posted by Supremache View Post
First time it show the three case's but when i use it again it show only case 1, case 2, but doesn't show case 0
I should reset the variable on last calling:

PHP Code:
if( !player )
    {
        switch( 
g_iReviveTeamid ] )
        {
            case 
01g_iReviveTeamid ]++;
            case 
2:
            {
                
g_iReviveTeamid ]--;
                
g_iReviveTeamid ] = 0// reset it on last case  
            
}
        }
        
cmdReviveMenuid );
    } 
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-22-2021 , 13:56   Re: Revive menu: i want to understand small part of this plugin
Reply With Quote #7

The author of the plugin is over complicating a revive menu, you don't need a global variable inorder to track whom to revive.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-23-2021 , 01:47   Re: Revive menu: i want to understand small part of this plugin
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
The author of the plugin is over complicating a revive menu, you don't need a global variable inorder to track whom to revive.
Yes but I like the style of the menu selecting command and the player in the same menu without adding multi menus and wanted to know how this code work for use the same method on another plugins
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Reply


Thread Tools
Display Modes

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 17:33.


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