Raised This Month: $ Target: $400
 0% 

Save to .ini or .txt files


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-17-2012 , 11:30   Save to .ini or .txt files
Reply With Quote #1

Can someone make this save to .ini or .txt file?

PHP Code:
    g_vault nvault_open("animod")
    
//we just opened a new connection NVAULT connection
    // we will call it animod

    
register_clcmd("say /rank""ShowHud")
    
register_clcmd("say_team /rank""ShowHud")
}
public 
client_connect(id)
{
    if(
get_pcvar_num(SavePoint) == 1)
    {
        
        
LoadData(id)
    }
    if(
get_pcvar_num(SaveExp) == 1)
    {
        
        
LoadData(id)
    }
}
public 
client_disconnect(id)
{
    if(
get_pcvar_num(SavePoint) == 1)
    {
    
        
SaveData(id)
    }
    if(
get_pcvar_num(SaveExp) == 1)
    {
    
        
SaveData(id)
    }
    
PlayerPoint[id] = 0
    PlayerExp
[id] = 0
}
public 
SaveData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerPoint[id],PlayerExp[id])
    
nvault_set(g_vault,vaultkey,vaultdata)
    return 
PLUGIN_CONTINUE
}
public 
LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerPoint[id],PlayerExp[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
 
    
replace_all(vaultdata255"#"" ")
 
    new 
playerpoint[32], playerexp[32]
 
    
parse(vaultdataplayerpoint31playerexp31)
 
    
PlayerPoint[id] = str_to_num(playerpoint)
    
PlayerExp[id] = str_to_num(playerexp)
 
    return 
PLUGIN_CONTINUE

Randomize is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 08-17-2012 , 14:18   Re: Save to .ini or .txt files
Reply With Quote #2

Quote:
Originally Posted by Randomize View Post
Can someone make this save to .ini or .txt file?

PHP Code:
    g_vault nvault_open("animod")
    
//we just opened a new connection NVAULT connection
    // we will call it animod

    
register_clcmd("say /rank""ShowHud")
    
register_clcmd("say_team /rank""ShowHud")
}
public 
client_connect(id)
{
    if(
get_pcvar_num(SavePoint) == 1)
    {
        
        
LoadData(id)
    }
    if(
get_pcvar_num(SaveExp) == 1)
    {
        
        
LoadData(id)
    }
}
public 
client_disconnect(id)
{
    if(
get_pcvar_num(SavePoint) == 1)
    {
    
        
SaveData(id)
    }
    if(
get_pcvar_num(SaveExp) == 1)
    {
    
        
SaveData(id)
    }
    
PlayerPoint[id] = 0
    PlayerExp
[id] = 0
}
public 
SaveData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerPoint[id],PlayerExp[id])
    
nvault_set(g_vault,vaultkey,vaultdata)
    return 
PLUGIN_CONTINUE
}
public 
LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerPoint[id],PlayerExp[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
 
    
replace_all(vaultdata255"#"" ")
 
    new 
playerpoint[32], playerexp[32]
 
    
parse(vaultdataplayerpoint31playerexp31)
 
    
PlayerPoint[id] = str_to_num(playerpoint)
    
PlayerExp[id] = str_to_num(playerexp)
 
    return 
PLUGIN_CONTINUE

There is no reason saving them in .txt file but thats your problem. Since you can't do this yourself this is more of request than "scripting help".

Why do you want to save in .txt file?

So correct section:
Suggestions / Requests
( Don't repost )
__________________

Accepting all kinds of requests via private message.

Last edited by matsi; 08-17-2012 at 14:18.
matsi is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-17-2012 , 14:38   Re: Save to .ini or .txt files
Reply With Quote #3

You might be able to do SaveData by doing log_to_file("data.txt", "%s; %s", vaultkey, vaultdata)

But you'll have to get a bit creative in LoadDAta so you can properly seperate the key from the data, and read each line and its timestamp. What's the fun if i give you all the answers.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 08-17-2012 , 16:00   Re: Save to .ini or .txt files
Reply With Quote #4

You can also use fvault.

Look at your "Doesn't work :/" thread I posted a example for you.

Last edited by Torge; 08-17-2012 at 16:03.
Torge is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-18-2012 , 01:44   Re: Save to .ini or .txt files
Reply With Quote #5

matsi: I make my own launcher for counter strike, it detects the value of the points and exp
LiverWiz is there any tutor?
Torge: I had tried it, it saves to .txt but the CS doesn't load the .txt file again, so the exp and point start from 0 again
Randomize is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-18-2012 , 12:27   Re: Save to .ini or .txt files
Reply With Quote #6

Quote:
Originally Posted by Randomize View Post
LiverWiz is there any tutor?
not much that i've seen. But there is a whole library of file minipulation. Look around.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-19-2012 , 08:34   Re: Save to .ini or .txt files
Reply With Quote #7

what do you mean with file manipulation? O.o
Randomize is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-19-2012 , 10:10   Re: Save to .ini or .txt files
Reply With Quote #8

http://www.amxmodx.org/funcwiki.php?go=inc&id=3
File I/O, directory usage, processing, etc. You could also use it in cooperation with regex to make things even easier.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 05:44.


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