Raised This Month: $ Target: $400
 0% 

Solved Coins Plugin - Only Current Player Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 04-19-2018 , 01:45   Re: Coins Plugin - Only Current Player Problem
Reply With Quote #1

Sample

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

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

new g_coins[33];

new wid, hs;

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

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


public fw_PlayerKilled(victim, attacker)  
{
    if (victim == attacker || !is_user_alive(attacker) )
        return
    
    attacker = get_user_attacker(victim,wid,hs)

    if(get_user_weapon(attacker) == CSW_KNIFE)
    { 
        g_coins[attacker]+= 1
    }
    else if(hs==HIT_HEAD)
    {
        g_coins[attacker]+= 2
    }

    g_coins[attacker]++
    client_print( attacker, print_center, "Coins %d", g_coins[attacker]);
}
Save coins

Code:
#include <amxmodx>
#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)

    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 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)

}

Last edited by raizo11; 04-19-2018 at 05:50.
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
polimpo4
Member
Join Date: Jan 2017
Old 04-19-2018 , 17:06   Re: Coins Plugin - Only Current Player Problem
Reply With Quote #2

Quote:
Originally Posted by raizo11 View Post
sample

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

#define plugin ""
#define version ""
#define author ""

new g_coins[33];

new wid, hs;

public plugin_init() 
{
    register_plugin(plugin, version, author)

    registerham(ham_killed, "player", "fw_playerkilled", 1)
}


public fw_playerkilled(victim, attacker)  
{
    if (victim == attacker || !is_user_alive(attacker) )
        return
    
    attacker = get_user_attacker(victim,wid,hs)

    if(get_user_weapon(attacker) == csw_knife)
    { 
        g_coins[attacker]+= 1
    }
    else if(hs==hit_head)
    {
        g_coins[attacker]+= 2
    }

    g_coins[attacker]++
    client_print( attacker, print_center, "coins %d", g_coins[attacker]);
}
save coins

Code:
#include <amxmodx>
#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)

    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 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)

}
you are the man... !!!! May i use your credits?! Like publish your nick?
polimpo4 is offline
Reply



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