AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to load this ? (https://forums.alliedmods.net/showthread.php?t=194103)

grs4 08-25-2012 09:28

How to load this ?
 
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 :D" "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 08-25-2012 13:27

Re: How to load this ?
 
OK its work, but if load data duplicate name i.e:
1. Glock Master[3/5][3000 exp]
2. Usp Master[2/5][3000 exp]
3. Usp Master[2/5][3000 exp] // must be P228 Master[0/5][3100 exp]
4. Deagle Master[4/5][3500 exp]
5. Deagle Master[4/5][3500 exp] // must be Elite Master[1/5][3100 exp]
6. Fiveseven Master[0/5][3500 exp]

This is currently load:
PHP Code:

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

// Load
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]) // 0 
        
else if(!= 0)
            
status_achI[id][i+1] = str_to_num(wartosc[i+1]) // 2, 4, 6, 8 itd...
    
}
    new 
j;
    for(new 
0<= liczba_achIi++)
    {
        if(
== 0)
            
postep_achI[id][1] = str_to_num(wartosc[1]) // 1
        
else if(!= 0) {
            
j+=2;
            
postep_achI[id][i+1] = str_to_num(wartosc[j+1]); // 3, 5, 7...    
        
}
    }
    
0



Napoleon_be 08-25-2012 13:38

Re: How to load this ?
 
save and load using STEAM ID

grs4 08-25-2012 14:22

Re: How to load this ?
 
Why ? On server NS/S how im load non steam player data ?

Napoleon_be 08-25-2012 14:29

Re: How to load this ?
 
We don't support non-steam servers.

Liverwiz 08-25-2012 15:08

Re: How to load this ?
 
Quote:

Originally Posted by grs4 (Post 1782525)
Why ? On server NS/S how im load non steam player data ?

By having them use LEGITIMATE versions of a non-freeware game.
i.e. GET LEGAL!

grs4 08-25-2012 17:08

Re: How to load this ?
 
I HAVE STEAM striker_mcpro

YamiKaitou 08-25-2012 17:15

Re: How to load this ?
 
What about your server?

grs4 08-25-2012 17:28

Re: How to load this ?
 
I dont have Server, but i rebuild total my expmod, and i have problem. i test my plugin on "local Server" with podbots. Im test this on my laptop, is very slow becouse my PC dont work.

Liverwiz 08-25-2012 17:33

Re: How to load this ?
 
Quote:

Originally Posted by grs4 (Post 1782659)
I dont have Server, but i rebuild total my expmod, and i have problem. i test my plugin on "local Server" with podbots. Im test this on my laptop, is very slow becouse my PC dont work.

bottom line. We DO NOT support servers that are running non-steam clients. Use STEAMIDs as your keys and we will assist. Other than that you might as well get banned. Not trying to be harsh, just stopping a problem before it starts.

Also: Usernames can change, and quite often do. SteamIDs can not. Why WOULD you use a username? Keep the data persistent.


All times are GMT -4. The time now is 05:43.

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