Raised This Month: $ Target: $400
 0% 

Save File/ Load file - TXT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mweb
Junior Member
Join Date: Aug 2010
Old 04-02-2011 , 08:16   Save File/ Load file - TXT
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define IsPlayer(%1)         (1 <= %1 <= get_maxplayers())

static const VERSION[] = "0.1";
new 
gszFile[128];

public 
plugin_init(){
    
register_plugin("Save it"VERSION"diablix");
    
register_clcmd("say /save""cmdSave");
    
register_clcmd("say /load""cmdLoad");
    
    new 
szDir[64];
    
get_basedir(szDirsizeof szDir);
    
add(szDirsizeof szDir"/zapisani");
    
    if (!
dir_exists(szDir))
        
mkdir(szDir);

    
formatex(gszFile96"%s/players_saved.txt"szDir);
}

public 
cmdSave(id) { Save(id); return 1; }
public 
cmdLoad(id) { Load(id); return 1; }

Save(id){
    new    
file fopen(gszFile"wt"),
        
szData[512],
        
szSTEAMID[32],
        
        
Float:fFrags;
    
    
pev(idpev_fragsfFrags);
    
    
get_user_authid(idszSTEAMIDsizeof szSTEAMID 1);    
    
    if(
IsPlayer(id)){
        
formatex(szData512"%f %s^n"fFragsszSTEAMID);
        
fputs(fileszData);
        
client_print(id3"Pomyslnie zapisano!");
    }
    
    
fclose(file);
}

Load(id){
    if(
file_exists(gszFile)){
        new     
szLine[768],
            
szType[3],
            
szSTEAMID[32],
            
szTEMPID[32],
            
szFrags[20],
            
Float:fFrags,
                
            
file fopen(gszFile"rt");
        
        
get_user_authid(idszTEMPIDsizeof szTEMPID 1);    
        
        while (!
feof(file)){
            
szType "";
            
fgets(fileszLine767);
            
remove_quotes(szLine);
            
parse(szLineszType2szFrags19szSTEAMID31);
            
            
fFrags str_to_float(szFrags);
            
            if(
equal(szTEMPIDszSTEAMID)){
                
set_pev(idpev_fragsfFrags);
                
client_print(id3"Twoj Steam_ID to: %s, Twoje Fragi: %d"szSTEAMIDfloatround(fFrags));
            }
            else
                
client_print(id3"Nie odnaleziono Cie na liscie!");
        }
        
        
        
fclose(file);
    }

Hi can you repair this plugin ??
Is does not search in function Save.

Last edited by mweb; 04-05-2011 at 07:50.
mweb is offline
Old 04-03-2011, 12:47
mweb
This message has been deleted by Arkshine. Reason: Don't bump until 14 days have passed.
Old 04-03-2011, 13:14
ConnorMcLeod
This message has been deleted by Arkshine. Reason: Don't bump until 14 days have passed.
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 14:32.


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