Raised This Month: $ Target: $400
 0% 

Save ....


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
med
Member
Join Date: Mar 2013
Old 07-30-2013 , 17:37   Save ....
Reply With Quote #1

hello all ..... i am new at scripting and i need help

How to save data ? The best way

like money ect ........
__________________
med is offline
Send a message via Skype™ to med
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-30-2013 , 18:09   Re: Save ....
Reply With Quote #2

Do you mean save within your script or more of a permanent save in a database, like vault or a SQL?
__________________
Black Rose is offline
med
Member
Join Date: Mar 2013
Old 07-31-2013 , 04:34   Re: Save ....
Reply With Quote #3

i mean like vault ...
exemple ! this a part of plugin..
new icoins // kill = 3 coins
how to save this .. if server restart or shutdown or change maps..
__________________
med is offline
Send a message via Skype™ to med
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 07-31-2013 , 10:23   Re: Save ....
Reply With Quote #4

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
med
Member
Join Date: Mar 2013
Old 07-31-2013 , 16:26   Re: Save ....
Reply With Quote #5

ty
__________________
med is offline
Send a message via Skype™ to med
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 07-31-2013 , 17:35   Re: Save ....
Reply With Quote #6

np
grs4 is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 07-31-2013 , 20:00   Re: Save ....
Reply With Quote #7

With witch system you want to work?
SQL?
Vault (includes nVault, fVault and nfVault)?
File Save (not as Vault)?
__________________
simanovich 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 08:52.


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