SA-MP Forums Archive
saving kills;deaths (simple stuff) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: saving kills;deaths (simple stuff) (/showthread.php?tid=96936)



saving kills;deaths (simple stuff) - klavins - 11.09.2009

I cant get working saving kills and deaths saving here`s the code - http://pawno.pastebin.com/f57e40583
I tried almoust everything and none of them works. it doesnt save those numbers in scriptfiles.


Re: saving kills;deaths (simple stuff) - [HiC]TheKiller - 12.09.2009

I hate DUDB . I'll just make a simple one for you out of DINI because I am bored.

TOP
pawn Код:
new Kills[MAX_PLAYERS];
new Deaths[MAX_PLAYERS];
Under OnGameModeInit
pawn Код:
if(!dini_Exists("Deaths.cfg"))
{
  dini_Create("Deaths.cfg");
}
   
if(!dini_Exists("Kills.cfg"))
{
  dini_Create("Kills.cfg");
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  Kills[killerid]++;
  Deaths[playerid]++;
  return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  Deaths[playerid] = dini_Int("Deaths.cfg", Pname);
  Kills[playerid] = dini_Int("Kills.cfg", Pname);
  return 1;
}
pawn Код:
OnPlayerDisconnect(playerid, reason)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  dini_IntSet("Deaths.cfg", Pname, Deaths[playerid]);
  dini_IntSet("Kills.cfg", Pname, Kills[playerid]);
}
Simple

The format shown in the file will be:
Код:
NAME = KILLS/DEATHS



Re: saving kills;deaths (simple stuff) - x-cutter - 12.09.2009

... or check the tutorials about dini, dudb or djson!


Re: saving kills;deaths (simple stuff) - Dak_Cobain - 12.09.2009

Quote:
Originally Posted by [HiC
TheKiller ]
I hate DUDB . I'll just make a simple one for you out of DINI because I am bored.

TOP
pawn Код:
new Kills[MAX_PLAYERS];
new Deaths[MAX_PLAYERS];
Under OnGameModeInit
pawn Код:
if(!dini_Exists("Deaths.cfg"))
{
  dini_Create("Deaths.cfg");
}
   
if(!dini_Exists("Kills.cfg"))
{
  dini_Create("Kills.cfg");
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  Kills[killerid]++;
  Deaths[playerid]++;
  return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  Deaths[playerid] = dini_Int("Deaths.cfg", Pname);
  Kills[playerid] = dini_Int("Kills.cfg", Pname);
  return 1;
}
pawn Код:
OnPlayerDisconnect(playerid, reason)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  dini_IntSet("Deaths.cfg", Pname, Deaths[playerid]);
  dini_IntSet("Kills.cfg", Pname, Kills[playerid]);
}
Simple

The format shown in the file will be:
Код:
NAME = KILLS/DEATHS
DUDB > DINI for player files.
Here's why, when the player disconnects, the file is saved as Deaths, when another player disconnects, the file is overwritten. Then when a new player connects, (s)he gets the kills and deaths of the last person to disconnect. DUDB saves the file as the player's name or however you set it up.


Re: saving kills;deaths (simple stuff) - Jakku - 12.09.2009

Quote:
Originally Posted by [HiC
TheKiller ]
I hate DUDB .
I hate DINI


Re: saving kills;deaths (simple stuff) - klavins - 12.09.2009

thx


Re: saving kills;deaths (simple stuff) - [HiC]TheKiller - 12.09.2009

Quote:
Originally Posted by Dak_Narden
Quote:
Originally Posted by [HiC
TheKiller ]
I hate DUDB . I'll just make a simple one for you out of DINI because I am bored.

TOP
pawn Код:
new Kills[MAX_PLAYERS];
new Deaths[MAX_PLAYERS];
Under OnGameModeInit
pawn Код:
if(!dini_Exists("Deaths.cfg"))
{
  dini_Create("Deaths.cfg");
}
   
if(!dini_Exists("Kills.cfg"))
{
  dini_Create("Kills.cfg");
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  Kills[killerid]++;
  Deaths[playerid]++;
  return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  Deaths[playerid] = dini_Int("Deaths.cfg", Pname);
  Kills[playerid] = dini_Int("Kills.cfg", Pname);
  return 1;
}
pawn Код:
OnPlayerDisconnect(playerid, reason)
{
  new Pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Pname, MAX_PLAYER_NAME);
  dini_IntSet("Deaths.cfg", Pname, Deaths[playerid]);
  dini_IntSet("Kills.cfg", Pname, Kills[playerid]);
}
Simple

The format shown in the file will be:
Код:
NAME = KILLS/DEATHS
DUDB > DINI for player files.
Here's why, when the player disconnects, the file is saved as Deaths, when another player disconnects, the file is overwritten. Then when a new player connects, (s)he gets the kills and deaths of the last person to disconnect. DUDB saves the file as the player's name or however you set it up.
Where did you get that info? It won't overwrite the file, it adds to the file. In most cases DINI can do the same thing as DUDB. I've done this many times so, I'm 100% sure it works.