Ginciuxzs

del save sistemos

Recommended Posts

sveiki gal galetumete padet isimt pinigu ir score save

forward LoadWeaponsToFile(playerid);
forward Disconnect(playerid);
forward Connect(playerid);
#include 
#include 
#include 
#include 

#define PATH "zaidejai"  //  Folderis kuriame issaugomi failai

new bool:AlreadyGiveWeapons[MAX_PLAYERS];
new pname[MAX_PLAYER_NAME];
new BurridgeScore[100];

#if defined FILTERSCRIPT
#else
#endif

public OnPlayerConnect(playerid)
{
{
AlreadyGiveWeapons[playerid] = false;
}
{
Connect(playerid);
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
{
   SaveWeaponsToFile(playerid);
   }
   {
   Disconnect(playerid);
   }
return 1;
}

public OnPlayerSpawn(playerid)
{
if (!AlreadyGiveWeapons[playerid]) SetTimerEx("LoadWeaponsToFile",250,false,"i",playerid);
return 1;
}

SaveWeaponsToFile(playerid)
{
   new i, path[50], string[128], weaponid, ammo;
   path = GetPlayerFormattedName(playerid);
   if (!dini_Exists(path)) dini_Create(path);
   for (i=0; i<13; i++)
   {
       GetPlayerWeaponData(playerid,i,weaponid,ammo);
       format(string,sizeof(string),"Weapon - %d",i);
       dini_IntSet(path,string,weaponid);
       format(string,sizeof(string),"AmmoID - %d",i);
       dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
   }
}

public LoadWeaponsToFile(playerid)
{
   new i, path[50], string[128], weaponid, ammo;
   path = GetPlayerFormattedName(playerid);
   ResetPlayerWeapons(playerid);
   for (i=0; i<13; i++)
   {
       format(string,sizeof(string),"Weapon - %d",i);
       weaponid = dini_Int(path,string);
       format(string,sizeof(string),"AmmoID - %d",i);
       ammo = dini_Int(path,string);
       GivePlayerWeapon(playerid,weaponid,ammo);
   }
   AlreadyGiveWeapons[playerid] = true;
}

GetPlayerFormattedName(playerid)
{
   new name[24], full[50];
   GetPlayerName(playerid,name,sizeof(name));
   format(full,sizeof(full),"%s/%s.ini",PATH,name);
   return full;
}

public Disconnect(playerid)
{
   GetPlayerName(playerid, pname, sizeof(pname));
   format(BurridgeScore, sizeof(BurridgeScore), "/zaidejai/%s.ini",pname);
   if(!dini_Exists(BurridgeScore)) {
   }
   else {
       dini_IntSet(BurridgeScore, "Score", GetPlayerScore(playerid));
       dini_IntSet(BurridgeScore, "Pinigai", GetPlayerMoney(playerid));
   }
}


public Connect(playerid)
{
   GetPlayerName(playerid, pname, sizeof(pname));
   format(BurridgeScore, sizeof(BurridgeScore), "/zaidejai/%s.ini",pname);
   if(!dini_Exists(BurridgeScore)) {
       dini_Create(BurridgeScore);
       dini_IntSet(BurridgeScore, "Score", 0);
       dini_IntSet(BurridgeScore, "Pinigai", 0);
       SetPlayerScore(playerid, dini_Int(BurridgeScore, "Score"));
       SetPlayerMoney(playerid, dini_Int(BurridgeScore, "Pinigai"));
   }
   else {
       SetPlayerScore(playerid, dini_Int(BurridgeScore, "Score"));
       SetPlayerMoney(playerid, dini_Int(BurridgeScore, "Pinigai"));
   }
   return 1;
}

Dalintis šį pranešimą


Nuoroda iki šio pranešimo
Dalintis per kitą puslapį

Prisijungti prie diskusijos

Palikti atsakymą galite iš karto, o užsiregistruoti vėliau. Jeigu jau turite paskyrą mūsų forume, Prisijunkite.

Svečias
Atsakyti Å¡ioje temoje...

×   Ä®klijuotas tekstas turi teksto formatavimą.   PaÅ¡alinti teksto formatavimą

  Galimi tik 75 veidukai.

×   Nuoroda buvo automatiÅ¡kai įterpta.   Ä®terpti nuorodą paprastai

×   JÅ«sų ankstesnis praneÅ¡imas buvo atkurtas.   IÅ¡valyti redaktorių

×   You cannot paste images directly. Upload or insert images from URL.


  • Å iame puslapyje narÅ¡o:   0 nariai

    Nėra registruotų narių peržiūrinčių šį forumą.

  • eneba
  • eneba
  • eneba



  • SuperGames programele
  • SuperGames programele