saving kills;deaths (simple stuff)
#1

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.
Reply
#2

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
Reply
#3

... or check the tutorials about dini, dudb or djson!
Reply
#4

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.
Reply
#5

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

thx
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)