Raised This Month: $ Target: $400
 0% 

How to load this ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 08-25-2012 , 09:28   How to load this ?
Reply With Quote #1

Hi all it's me again.

I'm have a big problem.

I'm don't know, how save and load....

In my plugin, i'm load others plugin i.e. i use native to register achievement.

All is good. just save and load...


This is my save and load :


LOAD:
PHP Code:

public WczytajI(id)
{
    new 
nick[33], dane[500]
    
get_user_name(idnick32)
    
WczytajDane(plikInickdane499)
   
    
remove_quotes(dane)

    new 
wartosc[MAX_ACHIEVEMENTS+1][15]
   
    
explode(dane' 'wartoscMAX_ACHIEVEMENTS+114)
   
    for(new 
0<= liczba_achIi++)
    {
        if(
== 0)
            
status_achI[id][1] = str_to_num(wartosc[i])
        else if(
!= 0)
            
status_achI[id][i+1] = str_to_num(wartosc[i+1])
    }
    for(new 
0<= liczba_achIi++)
    {
        if(
== 0)
            
postep_achI[id][1] = str_to_num(wartosc[i+1])
        else if(
!= 0)
            
postep_achI[id][i+1] = str_to_num(wartosc[i+2]);
    }

SAVE:

PHP Code:
public ZapiszI(id)
{
    new 
nick[33], dane[500], szTemp[25]
    
get_user_name(idnick32)
    for(new 
1<= liczba_achIi++)
    {
        
formatex(szTemp24"%d %d "status_achI[id][i], postep_achI[id][i])
        
add(dane499szTemp)
    }
    
ZapiszDane(plikInickdane)


I'm think save its working...

i'm use my save and load engine "savev"

this is .inc :

PHP Code:
#if defined _Save_included
  #endinput
#endif

#include <amxmodx>

// save path
new sciezka[]    = "addons/amxmodx/Zapis_v2" // Folder zapisywanych plikow

/* Save function */

public ZapiszDane(const file[], const key[], const data[])
{
    new 
ominac
    
new c[1024], sciezka_[128], arg1[64], tekst[500], len;
   
    
formatex(sciezka_127"%s/%s"sciezkafile);
   
    
formatex(c1023"^"%s^" ^"%s^""keydata);
   
    if(!
dir_exists(sciezka))
        
mkdir(sciezka);   
       
    if(!
file_exists(sciezka_))
        
write_file(sciezka_""0);
       
    for(new 
iread_file(sciezka_itekst499len);i++)
    {
        
parse(tekstarg163);
       
        if(
equal(keyarg1strlen(arg1)))
        {
            
write_file(sciezka_ci);
            
ominac++
        }   
        else   
            continue;
    }
    if(!
ominac)
        
write_file(sciezka_c, -1);
    
ominac 0
}

/* Load Function */

public WczytajDane(const file[], const key[], data[], len)
{
    new 
tekst[1101], lensciezka_[128];
    new 
arg1[64], arg2[1024];
   
    
formatex(sciezka_127"%s/%s"sciezkafile)
   
    if(!
file_exists(sciezka_))
        return 
PLUGIN_CONTINUE
    
for(new iread_file(sciezka_itekst1100len);i++)
    {
        
parse(tekstarg163arg21023);
       
        if(
equal(keyarg1strlen(arg1)))
            
copy(datalenarg2);
        else   
            continue;
    }
    return 
PLUGIN_CONTINUE
}

/* Deleted Function */

public UsunDane(const file[], const key[])
{

    new 
tekst[1101], lensciezka_[128];
    new 
arg1[64], arg2[1024];
   
    
formatex(sciezka_127"%s/%s"sciezkafile)
   
    if(!
file_exists(sciezka_))
        return 
PLUGIN_CONTINUE
    
for(new iread_file(sciezka_itekst1100len);i++)
    {
        
parse(tekstarg163arg21023);
       
        if(
equal(keyarg1strlen(arg1)))
            
write_file(sciezka_""i);
        else   
            continue;
    }
    return 
PLUGIN_CONTINUE

this is result of save

"STRIKER--McPr0 " "1 3 1 0 1 0 1 0 1 3 1 0 "

"1 3 1 0 1 0 1 0 1 3 1 0 "

first number '1' is status of one achievement, second number this is '3' is progress of achievement...

third number '1' is status of two achievement ...

I'm dont know how many is achievement becouse one plugin, one achievement
so i use 'add' function...

function 'explode' by DarkGL.

PHP Code:
stock explode(const string[],const character,output[][],const maxs,const maxlen){
        new 
iDo 0;
        new 
len strlen(string);
        new 
oLen 0;
        do
        {
                
oLen += (1+copyc(output[iDo++],maxlen,string[oLen],character))
        }
        while(
oLen len && iDo maxs)

So... Please Help me!!!
grs4 is offline
 



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:43.


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