Raised This Month: $12 Target: $400
 3% 

[Req] Resetscore EDIT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
botz
AlliedModders Donor
Join Date: Jan 2015
Old 09-02-2015 , 21:47   [Req] Resetscore EDIT
Reply With Quote #1

Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >

#define PLUGIN "ResetScore"
#define VERSION "0.2.0"
#define AUTHOR "aNNakin"

new const gs_Commands[ ][ ] =
{
	"say /resetscore",
	"say /rs"
};

new ToggleMax, ToggleInterval, ToggleMoney, g_Pointer;
new gi_Reset[ 33 ], gi_CanReset[ 33 ];

public plugin_init ( )
{
	register_plugin ( PLUGIN, VERSION, AUTHOR );
	register_dictionary ( "resetscore.txt" );
	
	register_concmd ( "amx_resetscore", "resetscore_concmd", ADMIN_KICK, "- <target>" );
	
	for ( new i_Index; i_Index < sizeof gs_Commands; i_Index++ )
		register_clcmd ( gs_Commands[ i_Index ], "resetscore_clcmd" );
	
	// how many times players can reset their score
	ToggleMax = register_cvar ( "resetscore_max", "0" );
	
	// how many minutes must pass before players can reset theirs score again
	ToggleInterval = register_cvar ( "resetscore_interval", "0" );
	
	// -2 don't set, -1 set at mp_startmoney value, another number will set to that value (e.g 0)
	ToggleMoney = register_cvar ( "resetscore_money", "-2" );
	
	g_Pointer = get_cvar_pointer ( "mp_startmoney" );
	
}

public client_putinserver ( e_Index ) gi_Reset[ e_Index ] = get_pcvar_num ( ToggleMax );

public resetscore_clcmd ( e_Index )
{
	new i_TimeCvar, i_Free, i_GameTime, Float:f_GameTime;
			
	if ( ScoreReseted ( e_Index ) )
	{
		client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_ALREADY_RESETED" );
		return PLUGIN_HANDLED;
	}
	
	f_GameTime = get_gametime ( );
	i_GameTime = floatround ( f_GameTime );
	i_TimeCvar = get_pcvar_num ( ToggleInterval );
	
	if ( ! get_pcvar_num ( ToggleMax ) )
	{
		i_Free = 1;
		goto CheckLimit;
		FreeReset:
		client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_SUCCES_FREE_RESET" );
		ResetScore ( e_Index );
		gi_CanReset[ e_Index ] = i_GameTime;
	}
	else
	{
		if ( gi_Reset[ e_Index ] > 0 )
		{
			CheckLimit:
			if ( gi_CanReset[ e_Index ] && ( i_GameTime - gi_CanReset[ e_Index ] < ( i_TimeCvar * 60 ) ) )
			{
				client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_WAIT_BEFORE_RESET", i_TimeCvar );
				return PLUGIN_HANDLED;
			}
			else	
				if ( i_Free )
					goto FreeReset;
				
			gi_Reset[ e_Index ]--;
			gi_CanReset[ e_Index ] = i_GameTime;
			ResetScore ( e_Index );
					
			if ( gi_Reset[ e_Index ] > 0 )
			{
				if ( gi_Reset[ e_Index ] == 1 )
					client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_SUCCESS_ONE_REMAIN" );
				else	
					client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_SUCCESS_MORE_RAMAIN", gi_Reset[ e_Index ] );
			}
			else
				client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_SUCCESS_NOT_REMAIN" );
			
			return PLUGIN_CONTINUE;
		}
		else
		{
			client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_CANT_USE_NOT_REMAIN" );
			return PLUGIN_HANDLED;
		}
	}
	
	return PLUGIN_CONTINUE;
}

public resetscore_concmd ( id, level, cid )
{
	if ( ! cmd_access ( id, level, cid, 2 ) )
		return PLUGIN_HANDLED;
		
	new s_Arg[ 32 ];
	read_argv ( 1, s_Arg, 31 );
	
	new e_Target = cmd_target ( id, s_Arg, 3 );
	if ( ! e_Target )
		return PLUGIN_HANDLED;
		
	if ( ScoreReseted ( e_Target ) )
	{
		console_print ( id, "%L", id, "RESETSCORE_ADMIN_ALREADY_RESETED" );
		return PLUGIN_HANDLED;
	}
	
	ResetScore ( e_Target );
	
	client_print ( e_Target, print_chat, "%L", e_Target, "RESETSCORE_PLAYER_ADMIN_HAS_RESETSCORE" );
	console_print ( id, "%L", id, "RESETSCORE_ADMIN_SUCCESS_RESETED" );
	return PLUGIN_HANDLED;
}
	
ResetScore ( e_Index )
{
	set_user_frags ( e_Index, 0 );
	cs_set_user_deaths ( e_Index, 0 );
	set_user_frags ( e_Index, 0 );
	cs_set_user_deaths ( e_Index, 0 );
	
	new i_MoneyCvar = get_pcvar_num ( ToggleMoney );
	new i_Value;
	
	// make sure he won't get more money
	if ( i_MoneyCvar >= 0 && cs_get_user_money ( e_Index ) <= i_MoneyCvar )
		return 1;
		
	switch ( i_MoneyCvar )
	{
		case -2: return 1;
		case -1: i_Value = get_pcvar_num ( g_Pointer );
		default: i_Value = i_MoneyCvar;
	}
	
	cs_set_user_money ( e_Index, i_Value );
	return 1;
}

ScoreReseted ( e_Index )
	return  ( !get_user_frags ( e_Index ) && !get_user_deaths ( e_Index ) ) ? 1 : 0;
This is code of this plugin

When someone types /rs or /reset score

Everyone can see what they typed..

Code:
client_print ( e_Index, print_chat, "%L", e_Index, "RESETSCORE_PLAYER_SUCCES_FREE_RESET" );
here is the code to that in this .sma

I want it like old plugin, like if someone types that /rs or /resetscore
No one should see if they typed /rs or /reset score, but it resets and shows the message to the guy who resets

Its working all good it shows the guy he resetted but in chat others can see this

Player: /rs

I dont want that only the guy who resetted should get the message from LANG file thats it

Thanks
__________________
botz is offline
sonel
Member
Join Date: Jul 2012
Old 09-03-2015 , 10:50   Re: [Req] Resetscore EDIT
Reply With Quote #2

Just replace "return PLUGIN_CONTINUE" by "return PLUGIN_HANDLED"
Here ya go:

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >

#define PLUGIN "ResetScore"
#define VERSION "0.2.0"
#define AUTHOR "aNNakin"

new const gs_Commands[ ][ ] =
{
    
"say /resetscore",
    
"say /rs"
};

new 
ToggleMaxToggleIntervalToggleMoneyg_Pointer;
new 
gi_Reset33 ], gi_CanReset33 ];

public 
plugin_init ( )
{
    
register_plugin PLUGINVERSIONAUTHOR );
    
register_dictionary "resetscore.txt" );
    
    
register_concmd "amx_resetscore""resetscore_concmd"ADMIN_KICK"- <target>" );
    
    for ( new 
i_Indexi_Index sizeof gs_Commandsi_Index++ )
        
register_clcmd gs_Commandsi_Index ], "resetscore_clcmd" );
    
    
// how many times players can reset their score
    
ToggleMax register_cvar "resetscore_max""0" );
    
    
// how many minutes must pass before players can reset theirs score again
    
ToggleInterval register_cvar "resetscore_interval""0" );
    
    
// -2 don't set, -1 set at mp_startmoney value, another number will set to that value (e.g 0)
    
ToggleMoney register_cvar "resetscore_money""-2" );
    
    
g_Pointer get_cvar_pointer "mp_startmoney" );
    
}

public 
client_putinserver e_Index gi_Resete_Index ] = get_pcvar_num ToggleMax );

public 
resetscore_clcmd e_Index )
{
    new 
i_TimeCvari_Freei_GameTimeFloat:f_GameTime;
            
    if ( 
ScoreReseted e_Index ) )
    {
        
client_print e_Indexprint_chat"%L"e_Index"RESETSCORE_PLAYER_ALREADY_RESETED" );
        return 
PLUGIN_HANDLED;
    }
    
    
f_GameTime get_gametime ( );
    
i_GameTime floatround f_GameTime );
    
i_TimeCvar get_pcvar_num ToggleInterval );
    
    if ( ! 
get_pcvar_num ToggleMax ) )
    {
        
i_Free 1;
        goto 
CheckLimit;
        
FreeReset:
        
client_print e_Indexprint_chat"%L"e_Index"RESETSCORE_PLAYER_SUCCES_FREE_RESET" );
        
ResetScore e_Index );
        
gi_CanResete_Index ] = i_GameTime;
    }
    else
    {
        if ( 
gi_Resete_Index ] > )
        {
            
CheckLimit:
            if ( 
gi_CanResete_Index ] && ( i_GameTime gi_CanResete_Index ] < ( i_TimeCvar 60 ) ) )
            {
                
client_print e_Indexprint_chat"%L"e_Index"RESETSCORE_PLAYER_WAIT_BEFORE_RESET"i_TimeCvar );
                return 
PLUGIN_HANDLED;
            }
            else    
                if ( 
i_Free )
                    goto 
FreeReset;
                
            
gi_Resete_Index ]--;
            
gi_CanResete_Index ] = i_GameTime;
            
ResetScore e_Index );
                    
            if ( 
gi_Resete_Index ] > )
            {
                if ( 
gi_Resete_Index ] == )
                    
client_print e_Indexprint_chat"%L"e_Index"RESETSCORE_PLAYER_SUCCESS_ONE_REMAIN" );
                else    
                    
client_print e_Indexprint_chat"%L"e_Index"RESETSCORE_PLAYER_SUCCESS_MORE_RAMAIN"gi_Resete_Index ] );
            }
            else
                
client_print e_Indexprint_chat"%L"e_Index"RESETSCORE_PLAYER_SUCCESS_NOT_REMAIN" );
            
            return 
PLUGIN_CONTINUE;
        }
        else
        {
            
client_print e_Indexprint_chat"%L"e_Index"RESETSCORE_PLAYER_CANT_USE_NOT_REMAIN" );
            return 
PLUGIN_HANDLED;
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
resetscore_concmd idlevelcid )
{
    if ( ! 
cmd_access idlevelcid) )
        return 
PLUGIN_HANDLED;
        
    new 
s_Arg32 ];
    
read_argv 1s_Arg31 );
    
    new 
e_Target cmd_target ids_Arg);
    if ( ! 
e_Target )
        return 
PLUGIN_HANDLED;
        
    if ( 
ScoreReseted e_Target ) )
    {
        
console_print id"%L"id"RESETSCORE_ADMIN_ALREADY_RESETED" );
        return 
PLUGIN_HANDLED;
    }
    
    
ResetScore e_Target );
    
    
client_print e_Targetprint_chat"%L"e_Target"RESETSCORE_PLAYER_ADMIN_HAS_RESETSCORE" );
    
console_print id"%L"id"RESETSCORE_ADMIN_SUCCESS_RESETED" );
    return 
PLUGIN_HANDLED;
}
    
ResetScore e_Index )
{
    
set_user_frags e_Index);
    
cs_set_user_deaths e_Index);
    
set_user_frags e_Index);
    
cs_set_user_deaths e_Index);
    
    new 
i_MoneyCvar get_pcvar_num ToggleMoney );
    new 
i_Value;
    
    
// make sure he won't get more money
    
if ( i_MoneyCvar >= && cs_get_user_money e_Index ) <= i_MoneyCvar )
        return 
1;
        
    switch ( 
i_MoneyCvar )
    {
        case -
2: return 1;
        case -
1i_Value get_pcvar_num g_Pointer );
        default: 
i_Value i_MoneyCvar;
    }
    
    
cs_set_user_money e_Indexi_Value );
    return 
1;
}

ScoreReseted e_Index )
    return  ( !
get_user_frags e_Index ) && !get_user_deaths e_Index ) ) ? 0

Last edited by sonel; 09-03-2015 at 10:51.
sonel is offline
afyfv
Junior Member
Join Date: Oct 2014
Old 09-03-2015 , 23:11   Re: [Req] Resetscore EDIT
Reply With Quote #3

hey noob there you go, use this..


Quote:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define adtime 600.0 //Default of 10 minuites

new pcvar_Advertise
new pcvar_Display

public plugin_init()
{
register_plugin("Reset Score", "1.0", "")

//You may type /resetscore or /restartscore
register_clcmd("say /resetscore", "reset_score")
register_clcmd("say /restartscore", "reset_score")
register_clcmd("say /rs", "reset_score")
register_clcmd("say rs", "reset_score")

//This command by default will be set at 0
//Change it to 1 in server.cfg if you want
//A message to be shown to advertise this.
pcvar_Advertise = register_cvar("sv_rsadvertise", "0")
//This command by default is also 0
//Change it to 1 in server.cfg if you want
//It to show who reset their scores when they do it
pcvar_Display = register_cvar("sv_rsdisplay", "1")

if(get_cvar_num("sv_rsadvertise") == 1)
{
set_task(adtime, "advertise", _, _, _, "b")
}
}

public reset_score(id)
{
//These both NEED to be done twice, otherwise your frags wont
//until the next round
cs_set_user_deaths(id, 0)
set_user_frags(id, 0)
cs_set_user_deaths(id, 0)
set_user_frags(id, 0)

if(get_pcvar_num(pcvar_Display) == 1)
{
new name[33]
get_user_name(id, name, 32)
client_print(0, print_chat, "%s has just reset his score", name)
}
else
{
client_print(id, print_chat, "You have just reset your score")
}
return PLUGIN_HANDLED
}

public advertise()
{
set_hudmessage(255, 0, 0, -1.0, 0.20, 0, 0.2, 12.0)
show_hudmessage(0, "By typing /rs you can restart your deaths and kills back to 0")
}

public client_putinserver(id)
{
if(get_pcvar_num(pcvar_Advertise) == 1)
{
set_task(10.0, "connectmessage", id, _, _, "a", 1)
}
}

public connectmessage(id)
{
if(is_user_connected(id))
{
client_print(id, print_chat, "By typing /resetscore at any time during the game, you can reset your deaths and kills back to 0 (rather than reconnecting)")
}
}
afyfv is offline
botz
AlliedModders Donor
Join Date: Jan 2015
Old 09-03-2015 , 23:25   Re: [Req] Resetscore EDIT
Reply With Quote #4

The plugin u posted here, crashes the server.. Thats why i found Advanced Reset score and asked for a bit edit there. But thanks anyways

Also sonel thanks buddy for the code
__________________
botz 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 02:13.


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