Raised This Month: $ Target: $400
 0% 

Save ....


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 07-31-2013 , 10:23   Re: Save ....
Reply With Quote #1

Very Simple:
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <nvault>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define TASK_HUD 3035

new vault
new coins[33]
new nicks[33][33]

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    vault = nvault_open("coins") // coins - name of the file
    
    register_event("DeathMsg", "DeathMsg", "a")
    RegisterHam(Ham_Spawn, "player", "Respawn", 1)
}
public client_connect(id)
{
    get_user_name(id, nicks[id], 32)
    Load(id)
    set_task(1.0, "ShowHud", id+TASK_HUD)
}
public client_disconnect(id)
{
    Save(id)
    replace(nicks[id], 32, nicks[id], "")
}
public Respawn(id)
{
    if(is_user_alive(id))
    {
        Save(id)
        if(!task_exists(id+TASK_HUD))
            set_task(1.0, "ShowHud", id+TASK_HUD)
    }
}
public DeathMsg()
{
    new attacker = read_data(1)
    new victim = read_data(2)
    
    if(is_user_alive(attacker) && is_user_connected(victim) && get_user_team(attacker) != get_user_team(victim))
    {
        coins[attacker]++
        Save(attacker)
    }
}
public ShowHud(id)
{
    id-=TASK_HUD
    if(is_user_alive(id))
    {
        set_hudmessage(255, 255, 0, 0.02, 0.29, 0, 6.0, 1.1)
        show_hudmessage(id, "Coins: %d", coins[id])
        set_task(0.9, "ShowHud", id+TASK_HUD)
    }
    else
    {
        remove_task(id+TASK_HUD)
        return PLUGIN_CONTINUE
    }
    
    return PLUGIN_CONTINUE
}
        
public Save(id)
{
    nvault_set(vault, nicks[id], coins[id])
}
public Load(id)
{
    new coin[5]
    nvault_get(vault, nicks[id], coin)
    coins[id] = str_to_num(coin)
}
public plugin_end()
{
    nvault_close(vault)
}
Coins ++ when player kill enemy on him team

Last edited by grs4; 07-31-2013 at 10:23.
grs4 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 15:49.


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