Raised This Month: $ Target: $400
 0% 

[Snippet] Basic Textfile Save/Load


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 04-12-2008 , 00:46   [Snippet] Basic Textfile Save/Load
Reply With Quote #1

Code:
//Vault v1.0 by Pinkfairie
 
//Termination:
#pragma semicolon 1
 
//Includes:
#include <sourcemod>
 
//Path:
static String:Path[64];
 
//Save:
public Action:Save(Client, Arguments)
{
 
 //Declare:
 decl Handle:Vault;
 
 //Initialize:
 Vault = CreateKeyValues("Vault");
 
 //Retrieve:
 FileToKeyValues(Vault, Path);
 
 //Money:
 KvJumpToKey(Vault, "Money", true);
 KvSetNum(Vault, "Joe", 1337);
 KvSetNum(Vault, "Scott", 69);
 KvRewind(Vault);
 
 //Bank:
 KvJumpToKey(Vault, "Bank", true);
 KvSetNum(Vault, "Joe", 134);
 KvSetNum(Vault, "Scott", 666);
 KvRewind(Vault);
 
 //Send:
 KeyValuesToFile(Vault, Path);
 
 //Close:
 CloseHandle(Vault);
}
 
//Load:
public Action:Load(Client, Arguments)
{
 
 //Declare:
 decl Handle:Vault;
 
 //Initialize:
 Vault = CreateKeyValues("Vault");
 
 //Retrieve:
 FileToKeyValues(Vault, Path);
 
 //Money:
 KvJumpToKey(Vault, "Money", false);
 KvGetNum(Vault, "Joe");
 KvGetNum(Vault, "Scott");
 KvRewind(Vault);
 
 //Bank:
 KvJumpToKey(Vault, "Bank", false);
 KvGetNum(Vault, "Joe");
 KvGetNum(Vault, "Scott");
 KvRewind(Vault);
 
 //Close:
 CloseHandle(Vault);
}
 
 
//Initation:
public OnPluginStart()
{
 
 //Commands:
 RegConsoleCmd("sm_save", Save);
 RegConsoleCmd("sm_load", Load);
 
 //Build:
 BuildPath(Path_SM, Path, 64, "data/vault.txt");
}
Then for example you could change the "joe" and "scott" to steamid's and save basic variables like a bank or something.
__________________
"Every man is guilty of all the good he did not do"

Last edited by DiscoBBQ; 04-12-2008 at 01:45.
DiscoBBQ is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 04-12-2008 , 02:32   Re: [Snippet] Basic Textfile Save/Load
Reply With Quote #2

lol . i think its funny to take the time to actualy include

Code:
 
#pragma semicolan 1
just to have it force an error if your missing a semi colan which has no purpase at the end of a line in pawn

anyways ....

this seems usefull im horable with sending things to file
Peoples Army is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 04-12-2008 , 03:41   Re: [Snippet] Basic Textfile Save/Load
Reply With Quote #3

the semicolan lets you multi line one command ;]

was not needed in that snippet though, force of habat
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 04-12-2008 , 04:51   Re: [Snippet] Basic Textfile Save/Load
Reply With Quote #4

Quote:
Originally Posted by Pinkfairie View Post
the semicolan lets you multi line one command ;]

was not needed in that snippet though, force of habat
oh i thought it was just to make it semicolons required. although i do use semicolons too .
Peoples Army 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 09:44.


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