Raised This Month: $ Target: $400
 0% 

How to load this ?


Post New Thread Reply   
 
Thread Tools Display Modes
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
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 08-25-2012 , 13:27   Re: How to load this ?
Reply With Quote #2

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

grs4 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-25-2012 , 13:38   Re: How to load this ?
Reply With Quote #3

save and load using STEAM ID
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 08-25-2012 , 14:22   Re: How to load this ?
Reply With Quote #4

Why ? On server NS/S how im load non steam player data ?
grs4 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-25-2012 , 14:29   Re: How to load this ?
Reply With Quote #5

We don't support non-steam servers.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-25-2012 , 15:08   Re: How to load this ?
Reply With Quote #6

Quote:
Originally Posted by grs4 View Post
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!
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 08-25-2012 , 17:08   Re: How to load this ?
Reply With Quote #7

I HAVE STEAM striker_mcpro
grs4 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-25-2012 , 17:15   Re: How to load this ?
Reply With Quote #8

What about your server?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 08-25-2012 , 17:28   Re: How to load this ?
Reply With Quote #9

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.
grs4 is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-25-2012 , 17:33   Re: How to load this ?
Reply With Quote #10

Quote:
Originally Posted by grs4 View Post
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.
__________________
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:43.


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