Статистиката да се запазва в Vault

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
TryAgain
Извън линия
Потребител
Потребител
Мнения: 182
Регистриран на: 25 Яну 2017, 16:59
Се отблагодари: 1 път
Получена благодарност: 26 пъти

Статистиката да се запазва в Vault

Мнение от TryAgain » 09 Апр 2018, 23:58

Така ли? xD

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <nvault>

#define PLUGIN		"Score HUD"
#define VERSION		"1.0"
#define AUTHOR 		"AndrewZ"
	
enum _:SCORE_DATA
{
	DISABLE,
	KILLS,
	HEADSHOTS,
	KNIFEKILLS,
	GRENADEKILLS,
	DEATHS
}

new g_user_score[ 33 ][ SCORE_DATA + 1 ]
new g_maxplayers
new g_iVault	

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )
	g_maxplayers = get_maxplayers()
	register_clcmd( "say /score", "cmd_score" )
	register_event( "DeathMsg", "event_death", "a" )
	set_task( 1.0, "rtask_show_hud", _, _, _, "b" )
	g_iVault = nvault_open("ScoreHUD")
}

public cmd_score( id )
{
	if( g_user_score[ id ][ DISABLE ] )
	{
		g_user_score[ id ][ DISABLE ] = 0
		client_print( id, print_chat, "HUD Statistics informer is on" )
	}
	else
	{
		g_user_score[ id ][ DISABLE ] = 1
		client_print( id, print_chat, "HUD Statistics informer is off." )
	}
	
	return PLUGIN_HANDLED
}	

public clear_data( id )
{
	if( !id )
	{
		for( new i = 1; i <= g_maxplayers; i ++ )
		{
			for( new data; data <= SCORE_DATA; data ++ )
				g_user_score[ i ][ data ] = 0
		}
	}
	else
	{
		for( new data; data <= SCORE_DATA; data ++ )
			g_user_score[ id ][ data ] = 0
	}
}
public plugin_end()	nvault_close(g_iVault)
public client_putinserver(id)		UseVault(id, 1)
public client_disconnect(id) 		UseVault(id, 0)

public event_death()
{
	new killer = read_data(1)
	new victim = read_data(2)
	new headshot = read_data(3)
	new weapon[ 12 ]; read_data(4, weapon, 11)
	
	if(!is_user_connected(killer) && !is_user_connected(victim))
		return
		
	if(killer == victim)
	{
		g_user_score[ victim ][ DEATHS ] ++
		return
	}
		
	g_user_score[ killer ][ KILLS ] ++
	
	if( headshot )
		g_user_score[ killer ][ HEADSHOTS ] ++
		
	if( equal( weapon, "knife" ) )
		g_user_score[ killer ][ KNIFEKILLS ] ++
	else if( equal( weapon, "grenade" ) )
		g_user_score[ killer ][ GRENADEKILLS ] ++
	
	g_user_score[ victim ][ DEATHS ] ++
	UseVault(killer, 0)
}
	

public rtask_show_hud()
{
	for( new id = 1; id <= g_maxplayers; id ++ )
	{
		if( !is_user_alive( id ) || g_user_score[ id ][ DISABLE ] )
			continue
		
		new Float:kd, 
			Float:k = float( g_user_score[ id ][ KILLS ] ), 
			Float:d = float( g_user_score[ id ][ DEATHS ] )
		
		if( k && d )
			kd = k / d
			
		else kd = 0.0
		
		
		set_hudmessage(255, 255, 255, -1.0, 0.89, 0, 6.0, 1.0)
		
		show_hudmessage
		( 
			id, "Kills: %d | Headshots: %d | Knife kills: %d | Grenade kills: %d | Deaths: %d | К/D: %.2f", 
			g_user_score[ id ][ KILLS ], 
			g_user_score[ id ][ HEADSHOTS ], 
			g_user_score[ id ][ KNIFEKILLS ], 
			g_user_score[ id ][ GRENADEKILLS],
			g_user_score[ id ][ DEATHS ],
			kd
		)
	}
}
UseVault(id, iType)
{        
    new szIP[23], szData[128]
    get_user_ip(id, szIP, charsmax(szIP),1) 
    
    switch(iType)
    {
        case 0:
        {
            formatex(szData,charsmax(szData),"%i|%i|%i|%i|%i",g_user_score[ id ][ KILLS ] , g_user_score[ id ][ HEADSHOTS ],g_user_score[ id ][ KNIFEKILLS ], g_user_score[ id ][ GRENADEKILLS],g_user_score[ id ][ DEATHS ])
            nvault_set(g_iVault, szIP, szData)
        }
        case 1:
        {
            nvault_get(g_iVault, szIP, szData, charsmax(szData))
            replace_all(szData, charsmax(szData), "|", " ")
            
            new szKills[8], szHS[8], szKnKill[8], szGnKills[8], szDeaths[8]
            parse(szData, szKills,charsmax(szKills), szHS,charsmax(szHS), szKnKill, charsmax(szKnKill), szGnKills,charsmax(szGnKills), szDeaths, charsmax(szDeaths))
            g_user_score[ id ][ KILLS ] = str_to_num(szKills)
            g_user_score[ id ][ HEADSHOTS ] = str_to_num(szHS)
            g_user_score[ id ][ KNIFEKILLS ] = str_to_num(szKnKill)
            g_user_score[ id ][ GRENADEKILLS] = str_to_num(szGnKills)
            g_user_score[ id ][ DEATHS ] = str_to_num(szDeaths)
        } 
    }
}

Аватар
Fr0sTt
Извън линия
Потребител
Потребител
Мнения: 138
Регистриран на: 16 Фев 2018, 19:11

Статистиката да се запазва в Vault

Мнение от Fr0sTt » 10 Апр 2018, 09:07

Изтрий пак файловете, че бях забравил да го направя по IP:

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <nvault>

#define PLUGIN		"Score HUD"
#define VERSION		"1.0"
#define AUTHOR 		"AndrewZ"
	
enum _:SCORE_DATA
{
	DISABLE,
	KILLS,
	HEADSHOTS,
	KNIFEKILLS,
	GRENADEKILLS,
	DEATHS
}

new g_user_score[ 33 ][ SCORE_DATA + 1 ]
new g_maxplayers
new g_iVault	

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )
	g_maxplayers = get_maxplayers()
	register_clcmd( "say /score", "cmd_score" )
	register_event( "DeathMsg", "event_death", "a" )
	set_task( 1.0, "rtask_show_hud", _, _, _, "b" )
	g_iVault = nvault_open("ScoreHUD")
}

public cmd_score( id )
{
	if( g_user_score[ id ][ DISABLE ] )
	{
		g_user_score[ id ][ DISABLE ] = 0
		client_print( id, print_chat, "HUD Statistics informer is on" )
	}
	else
	{
		g_user_score[ id ][ DISABLE ] = 1
		client_print( id, print_chat, "HUD Statistics informer is off." )
	}
	
	return PLUGIN_HANDLED
}	

public clear_data( id )
{
	if( !id )
	{
		for( new i = 1; i <= g_maxplayers; i ++ )
		{
			for( new data; data <= SCORE_DATA; data ++ )
				g_user_score[ i ][ data ] = 0
		}
	}
	else
	{
		for( new data; data <= SCORE_DATA; data ++ )
			g_user_score[ id ][ data ] = 0
	}
}
public client_putinserver(id)		UseVault(id, 1)
public client_disconnect(id) 		UseVault(id, 0)

public event_death()
{
	new killer = read_data(1)
	new victim = read_data(2)
	new headshot = read_data(3)
	new weapon[ 12 ]; read_data(4, weapon, 11)
	
	if(!is_user_connected(killer) && !is_user_connected(victim))
		return
		
	if(killer == victim)
	{
		g_user_score[ victim ][ DEATHS ] ++
		return
	}
		
	g_user_score[ killer ][ KILLS ] ++
	
	if( headshot )
		g_user_score[ killer ][ HEADSHOTS ] ++
		
	if( equal( weapon, "knife" ) )
		g_user_score[ killer ][ KNIFEKILLS ] ++
	else if( equal( weapon, "grenade" ) )
		g_user_score[ killer ][ GRENADEKILLS ] ++
	
	g_user_score[ victim ][ DEATHS ] ++
	UseVault(killer, 0)
}
	

public rtask_show_hud()
{
	for( new id = 1; id <= g_maxplayers; id ++ )
	{
		if( !is_user_alive( id ) || g_user_score[ id ][ DISABLE ] )
			continue
		
		new Float:kd, 
			Float:k = float( g_user_score[ id ][ KILLS ] ), 
			Float:d = float( g_user_score[ id ][ DEATHS ] )
		
		if( k && d )
			kd = k / d
			
		else kd = 0.0
		
		
		set_hudmessage(255, 255, 255, -1.0, 0.89, 0, 6.0, 1.0)
		
		show_hudmessage
		( 
			id, "Kills: %d | Headshots: %d | Knife kills: %d | Grenade kills: %d | Deaths: %d | К/D: %.2f", 
			g_user_score[ id ][ KILLS ], 
			g_user_score[ id ][ HEADSHOTS ], 
			g_user_score[ id ][ KNIFEKILLS ], 
			g_user_score[ id ][ GRENADEKILLS],
			g_user_score[ id ][ DEATHS ],
			kd
		)
	}
}
UseVault(id, iType)
{        
    new szIP[23], szData[128]
    get_user_ip(id, szIP, charsmax(szIP)) 
    
    switch(iType)
    {
        case 0:
        {
            formatex(szData,charsmax(szData),"%i#%i#%i#%i#%i", g_user_score[ id ][ KILLS ], g_user_score[ id ][ HEADSHOTS ], g_user_score[ id ][ KNIFEKILLS ], g_user_score[ id ][ GRENADEKILLS], g_user_score[ id ][ DEATHS ])
            nvault_set(g_iVault, szIP, szData)
        }
        case 1:
        {
            nvault_get(g_iVault, szIP, szData, charsmax(szData))
            replace_all(szData, charsmax(szData), "#", " ")
            
            new szKills[8], szHS[8], szKnKill[8], szGnKills[8], szDeaths[8]
            parse(szData, szKills,charsmax(szKills), szHS,charsmax(szHS), szKnKill, charsmax(szKnKill), szGnKills,charsmax(szGnKills), szDeaths, charsmax(szDeaths))
            g_user_score[ id ][ KILLS ] = str_to_num(szKills)
            g_user_score[ id ][ HEADSHOTS ] = str_to_num(szHS)
            g_user_score[ id ][ KNIFEKILLS ] = str_to_num(szKnKill)
            g_user_score[ id ][ GRENADEKILLS] = str_to_num(szGnKills)
            g_user_score[ id ][ DEATHS ] = str_to_num(szDeaths)
        } 
    }
}

Аватар
cgozzie
Извън линия
Потребител
Потребител
Мнения: 1318
Регистриран на: 13 Окт 2016, 22:10
Местоположение: Варна
Се отблагодари: 244 пъти
Получена благодарност: 42 пъти

Статистиката да се запазва в Vault

Мнение от cgozzie » 29 Юли 2018, 12:47

Fr0sTt написа: 10 Апр 2018, 09:07 Изтрий пак файловете, че бях забравил да го направя по IP:

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <nvault>

#define PLUGIN		"Score HUD"
#define VERSION		"1.0"
#define AUTHOR 		"AndrewZ"
	
enum _:SCORE_DATA
{
	DISABLE,
	KILLS,
	HEADSHOTS,
	KNIFEKILLS,
	GRENADEKILLS,
	DEATHS
}

new g_user_score[ 33 ][ SCORE_DATA + 1 ]
new g_maxplayers
new g_iVault	

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )
	g_maxplayers = get_maxplayers()
	register_clcmd( "say /score", "cmd_score" )
	register_event( "DeathMsg", "event_death", "a" )
	set_task( 1.0, "rtask_show_hud", _, _, _, "b" )
	g_iVault = nvault_open("ScoreHUD")
}

public cmd_score( id )
{
	if( g_user_score[ id ][ DISABLE ] )
	{
		g_user_score[ id ][ DISABLE ] = 0
		client_print( id, print_chat, "HUD Statistics informer is on" )
	}
	else
	{
		g_user_score[ id ][ DISABLE ] = 1
		client_print( id, print_chat, "HUD Statistics informer is off." )
	}
	
	return PLUGIN_HANDLED
}	

public clear_data( id )
{
	if( !id )
	{
		for( new i = 1; i <= g_maxplayers; i ++ )
		{
			for( new data; data <= SCORE_DATA; data ++ )
				g_user_score[ i ][ data ] = 0
		}
	}
	else
	{
		for( new data; data <= SCORE_DATA; data ++ )
			g_user_score[ id ][ data ] = 0
	}
}
public client_putinserver(id)		UseVault(id, 1)
public client_disconnect(id) 		UseVault(id, 0)

public event_death()
{
	new killer = read_data(1)
	new victim = read_data(2)
	new headshot = read_data(3)
	new weapon[ 12 ]; read_data(4, weapon, 11)
	
	if(!is_user_connected(killer) && !is_user_connected(victim))
		return
		
	if(killer == victim)
	{
		g_user_score[ victim ][ DEATHS ] ++
		return
	}
		
	g_user_score[ killer ][ KILLS ] ++
	
	if( headshot )
		g_user_score[ killer ][ HEADSHOTS ] ++
		
	if( equal( weapon, "knife" ) )
		g_user_score[ killer ][ KNIFEKILLS ] ++
	else if( equal( weapon, "grenade" ) )
		g_user_score[ killer ][ GRENADEKILLS ] ++
	
	g_user_score[ victim ][ DEATHS ] ++
	UseVault(killer, 0)
}
	

public rtask_show_hud()
{
	for( new id = 1; id <= g_maxplayers; id ++ )
	{
		if( !is_user_alive( id ) || g_user_score[ id ][ DISABLE ] )
			continue
		
		new Float:kd, 
			Float:k = float( g_user_score[ id ][ KILLS ] ), 
			Float:d = float( g_user_score[ id ][ DEATHS ] )
		
		if( k && d )
			kd = k / d
			
		else kd = 0.0
		
		
		set_hudmessage(255, 255, 255, -1.0, 0.89, 0, 6.0, 1.0)
		
		show_hudmessage
		( 
			id, "Kills: %d | Headshots: %d | Knife kills: %d | Grenade kills: %d | Deaths: %d | К/D: %.2f", 
			g_user_score[ id ][ KILLS ], 
			g_user_score[ id ][ HEADSHOTS ], 
			g_user_score[ id ][ KNIFEKILLS ], 
			g_user_score[ id ][ GRENADEKILLS],
			g_user_score[ id ][ DEATHS ],
			kd
		)
	}
}
UseVault(id, iType)
{        
    new szIP[23], szData[128]
    get_user_ip(id, szIP, charsmax(szIP)) 
    
    switch(iType)
    {
        case 0:
        {
            formatex(szData,charsmax(szData),"%i#%i#%i#%i#%i", g_user_score[ id ][ KILLS ], g_user_score[ id ][ HEADSHOTS ], g_user_score[ id ][ KNIFEKILLS ], g_user_score[ id ][ GRENADEKILLS], g_user_score[ id ][ DEATHS ])
            nvault_set(g_iVault, szIP, szData)
        }
        case 1:
        {
            nvault_get(g_iVault, szIP, szData, charsmax(szData))
            replace_all(szData, charsmax(szData), "#", " ")
            
            new szKills[8], szHS[8], szKnKill[8], szGnKills[8], szDeaths[8]
            parse(szData, szKills,charsmax(szKills), szHS,charsmax(szHS), szKnKill, charsmax(szKnKill), szGnKills,charsmax(szGnKills), szDeaths, charsmax(szDeaths))
            g_user_score[ id ][ KILLS ] = str_to_num(szKills)
            g_user_score[ id ][ HEADSHOTS ] = str_to_num(szHS)
            g_user_score[ id ][ KNIFEKILLS ] = str_to_num(szKnKill)
            g_user_score[ id ][ GRENADEKILLS] = str_to_num(szGnKills)
            g_user_score[ id ][ DEATHS ] = str_to_num(szDeaths)
        } 
    }
}
Запазва само докато не дадеш рестарт на сървъра след това пак сичко си е на 0.
Изображение

Аватар
cgozzie
Извън линия
Потребител
Потребител
Мнения: 1318
Регистриран на: 13 Окт 2016, 22:10
Местоположение: Варна
Се отблагодари: 244 пъти
Получена благодарност: 42 пъти

Статистиката да се запазва в Vault

Мнение от cgozzie » 31 Юли 2018, 19:03

Ще може ли някой да помогне с този плъгин запазва си всичко до рестарт на сървъра и пак отново всичко е на 0.
Изображение

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Статистиката да се запазва в Vault

Мнение от OciXCrom » 31 Юли 2018, 21:44

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <nvault>

#if defined client_disconnected
	#define client_disconnect client_disconnected
#endif

#define PLUGIN		"Score HUD"
#define VERSION		"1.0"
#define AUTHOR 		"AndrewZ"
	
enum _:SCORE_DATA
{
	DISABLE,
	KILLS,
	HEADSHOTS,
	KNIFEKILLS,
	GRENADEKILLS,
	DEATHS
}

new g_user_score[ 33 ][ SCORE_DATA + 1 ]
new g_maxplayers
new g_iVault	

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )
	g_maxplayers = get_maxplayers()
	register_clcmd( "say /score", "cmd_score" )
	register_event( "DeathMsg", "event_death", "a" )
	set_task( 1.0, "rtask_show_hud", _, _, _, "b" )
	g_iVault = nvault_open("ScoreHUD")
}

public plugin_end()
	nvault_close(g_iVault)

public cmd_score( id )
{
	if( g_user_score[ id ][ DISABLE ] )
	{
		g_user_score[ id ][ DISABLE ] = 0
		client_print( id, print_chat, "HUD Statistics informer is on" )
	}
	else
	{
		g_user_score[ id ][ DISABLE ] = 1
		client_print( id, print_chat, "HUD Statistics informer is off." )
	}
	
	return PLUGIN_HANDLED
}	

public clear_data( id )
{
	if( !id )
	{
		for( new i = 1; i <= g_maxplayers; i ++ )
		{
			for( new data; data <= SCORE_DATA; data ++ )
				g_user_score[ i ][ data ] = 0
		}
	}
	else
	{
		for( new data; data <= SCORE_DATA; data ++ )
			g_user_score[ id ][ data ] = 0
	}
}
public client_connect(id)		UseVault(id, 1)
public client_disconnect(id) 		UseVault(id, 0)

public event_death()
{
	new killer = read_data(1)
	new victim = read_data(2)
	new headshot = read_data(3)
	new weapon[ 12 ]; read_data(4, weapon, 11)
	
	if(!is_user_connected(killer) && !is_user_connected(victim))
		return
		
	if(killer == victim)
	{
		g_user_score[ victim ][ DEATHS ] ++
		return
	}
		
	g_user_score[ killer ][ KILLS ] ++
	
	if( headshot )
		g_user_score[ killer ][ HEADSHOTS ] ++
		
	if( equal( weapon, "knife" ) )
		g_user_score[ killer ][ KNIFEKILLS ] ++
	else if( equal( weapon, "grenade" ) )
		g_user_score[ killer ][ GRENADEKILLS ] ++
	
	g_user_score[ victim ][ DEATHS ] ++
	UseVault(killer, 0)
}
	

public rtask_show_hud()
{
	for( new id = 1; id <= g_maxplayers; id ++ )
	{
		if( !is_user_alive( id ) || g_user_score[ id ][ DISABLE ] )
			continue
		
		new Float:kd, 
			Float:k = float( g_user_score[ id ][ KILLS ] ), 
			Float:d = float( g_user_score[ id ][ DEATHS ] )
		
		if( k && d )
			kd = k / d
			
		else kd = 0.0
		
		
		set_hudmessage(255, 255, 255, -1.0, 0.89, 0, 6.0, 1.0)
		
		show_hudmessage
		( 
			id, "Kills: %d | Headshots: %d | Knife kills: %d | Grenade kills: %d | Deaths: %d | К/D: %.2f", 
			g_user_score[ id ][ KILLS ], 
			g_user_score[ id ][ HEADSHOTS ], 
			g_user_score[ id ][ KNIFEKILLS ], 
			g_user_score[ id ][ GRENADEKILLS],
			g_user_score[ id ][ DEATHS ],
			kd
		)
	}
}
UseVault(id, iType)
{        
    new szIP[23], szData[128]
    get_user_ip(id, szIP, charsmax(szIP)) 
    
    switch(iType)
    {
        case 0:
        {
            formatex(szData,charsmax(szData),"%i#%i#%i#%i#%i", g_user_score[ id ][ KILLS ], g_user_score[ id ][ HEADSHOTS ], g_user_score[ id ][ KNIFEKILLS ], g_user_score[ id ][ GRENADEKILLS], g_user_score[ id ][ DEATHS ])
            nvault_set(g_iVault, szIP, szData)
        }
        case 1:
        {
            nvault_get(g_iVault, szIP, szData, charsmax(szData))
            replace_all(szData, charsmax(szData), "#", " ")
            
            new szKills[8], szHS[8], szKnKill[8], szGnKills[8], szDeaths[8]
            parse(szData, szKills,charsmax(szKills), szHS,charsmax(szHS), szKnKill, charsmax(szKnKill), szGnKills,charsmax(szGnKills), szDeaths, charsmax(szDeaths))
            g_user_score[ id ][ KILLS ] = str_to_num(szKills)
            g_user_score[ id ][ HEADSHOTS ] = str_to_num(szHS)
            g_user_score[ id ][ KNIFEKILLS ] = str_to_num(szKnKill)
            g_user_score[ id ][ GRENADEKILLS] = str_to_num(szGnKills)
            g_user_score[ id ][ DEATHS ] = str_to_num(szDeaths)
        } 
    }
}

Аватар
cgozzie
Извън линия
Потребител
Потребител
Мнения: 1318
Регистриран на: 13 Окт 2016, 22:10
Местоположение: Варна
Се отблагодари: 244 пъти
Получена благодарност: 42 пъти

Статистиката да се запазва в Vault

Мнение от cgozzie » 01 Авг 2018, 11:23

Записва уж всичко в ScoreHUD.vault по IP: но след рестарт на сървъра пак всичко е на 0.
Изображение

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: Google [Bot] и 1 гост