SA-MP Forums Archive
[Ajuda] Complementar Save/Load - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Complementar Save/Load (/showthread.php?tid=603203)



Complementar Save/Load - DiiMeNoR - 20.03.2016

Olб, preciso de ajuda em um sistema antigo de salvamento, jб tenho a funзгo de salvar e carregar, preciso complementar verificando se o arquivo existe, caso nгo criar o mesmo com o nome do player.

Salvar
PHP код:
stock SaveInventory(playerid)
{
    
gItemList="";
    new 
filename[48];
    
GetPlayerName(playerid,filename,24);
    
format(filename,48,Inventarios,filename);
    new 
File:file=fopen(filename,io_write);
    
fwrite(file,gItemList);
    
fclose(file);
    
GetPlayerName(playerid,filename,24);

PHP код:
stock LoadInventory(playerid)
{
    new 
tstring[48];
    new 
tstring2[12];
    
GetPlayerName(playerid,tstring,48);
    
format(tstring,48,Inventarios,tstring);
    if(!
fexist(tstring))return 0;
    new 
File:file=fopen(tstring,io_read);
    
fread(file,tstring);
    while(
tstring[0])
    {
        
format(tstring,strlen(tstring),"%s",tstring);
        
fread(file,tstring2);
        
AddItem(playerid,tstring,strval(tstring2));
        
fread(file,tstring);
    }
    
fclose(file);
    
GetPlayerName(playerid,tstring,24);
    return 
1;

Minha ideia й salvar os itens quando o players deslogar e carregar os mesmo assim que logar, grato desde jб !


Re: Complementar Save/Load - F1N4L - 20.03.2016

Nгo entendo o motivo de nгo utilizar nenhuma include de salvamento!