Raised This Month: $ Target: $400
 0% 

Solved Coins Plugin - Only Current Player Problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 04-20-2018 , 03:24   Re: Coins Plugin - Only Current Player Problem
Reply With Quote #5

Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <nvault>

#define PLUGIN ""
#define VERSION ""
#define AUTHOR ""

#define STATS_COINS 0  
#define UPDATETIME 5.0

new g_coins[33][1];

new vault, wid, hs;


public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)

    RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1)

    register_clcmd( "amx_setcoins", "SetCoins", ADMIN_MENU );

    set_task( UPDATETIME, "ShowCoinDetails", _, _, _, "b" );

    vault = nvault_open("SaveCoins")
}


public fw_PlayerKilled(victim, attacker)  
{
    if (victim == attacker || !is_user_alive(attacker) )
        return
    
    new A_name[32], V_name[32];

    get_user_name( attacker , A_name , charsmax( A_name ) );
    get_user_name( victim , V_name , charsmax( V_name ) );

    attacker = get_user_attacker(victim,wid,hs)

    if(get_user_weapon(attacker) == CSW_KNIFE)
    { 
        g_coins[attacker][STATS_COINS]+=1 
        //client_print (attacker, print_chat, "You killed %s with a knife", V_name) 
        //client_print (victim, print_chat, "You were killed by %s with a knife", A_name) 
    }
    else if(hs==HIT_HEAD)
    {
        g_coins[attacker][STATS_COINS]+=2  
        //client_print (victim, print_chat, "%s got you a headshoot", A_name)
    }

    g_coins[attacker][STATS_COINS]++ 
    client_print( attacker, print_center, "Coins %d", g_coins[attacker]);

}

public SetCoins( id, level, cid )
{
	if (!cmd_access(id,level,cid,2)) 
		return PLUGIN_HANDLED ;

	new sxName[ 50 ], szName[ 32 ];
        get_user_name( id , szName , charsmax( szName ) );

	read_argv( 1, sxName, 49 );
	new valSz[ 50 ], val;
	read_argv( 2, valSz, 49 );
	val = str_to_num( valSz );
	
	new user = cmd_target( id, sxName, CMDTARGET_ALLOW_SELF );

	g_coins[user][STATS_COINS] = val * 1;

        client_print_color(0, "!t%s !greceive [%d] !tfrom the admin !g%s",sxName, g_coins[user][STATS_COINS], szName);
	
	return PLUGIN_HANDLED;
}

public ShowCoinDetails()
{

    new Players[ 32 ];
    new playerCount, i, player;

    get_players(Players, playerCount, "ach");
    for (i=0; i<playerCount; i++) 
    {
        player = Players[ i ];
		
	new name[ 50 ];
	get_user_name( player, name, 49 );

	new x_coins = g_coins[player][STATS_COINS]


	if(is_user_alive(player))
        {
            set_hudmessage( 0, 255, 255, 0.02, 0.17, 0, 6.0, UPDATETIME );
	    show_hudmessage( player, "[Coins : %i]",x_coins);
	}   
    }

}

public client_putinserver(id)
{
    new name[32],data[512],raw[1][20]  
    get_user_name(id,name,31)  
     
    if(!nvault_get(vault,name,data,511)) 
        return PLUGIN_CONTINUE 
     
    parse(data,raw[0],19) 
    g_coins[id][STATS_COINS]=str_to_num(raw[0])  
     
    return PLUGIN_CONTINUE
}

public client_disconnect(id)
{
    new name[32],data[512]  
    get_user_name(id,name,31)  
    formatex(data,511,"%d",g_coins[id][STATS_COINS])  
    nvault_set(vault,name,data)

}

stock client_print_color(const id, const input[], any:...)  
{  
    new count = 1, players[32];  
    static msg[191];  
    vformat(msg, 190, input, 3);
    replace_all(msg, 190, "!g", "^x04"); // Green Color  
    replace_all(msg, 190, "!y", "^x01"); // Default Color  
    replace_all(msg, 190, "!t", "^x03"); // Team Color  
    if (id) players[0] = id; else get_players(players, count, "ch");  
    {  
        for (new i = 0; i < count; i++)  
        {  
            if (is_user_connected(players[i]))  
            {  
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);  
                write_byte(players[i]);  
                write_string(msg);  
                message_end();  

            }  
        }  
    }  
}

Last edited by raizo11; 04-20-2018 at 04:07.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
 



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 04:44.


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