Kills and Deaths counter prob.
#1

Hi there!!! I'm working on a deathmatch LMS script and everything's alright. No compilation errors, but Kills and deaths aren't increasing. Please take a look at the code.

Defining part:
Код:
enum pInfo
{
  pKills,
  pDeaths
}

new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
  INI_Int("Kills", PlayerInfo[playerid][pKills]);
  INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  return 1;
}

stock UserPath(playerid)
{
  new string[128], pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pName,sizeof(pName));
  format(string,sizeof(string),PATH,pName);
  return string;
}
OnPlayerConnect part:
Код:
public OnPlayerConnect(playerid)
{
	if(fexist(UserPath(playerid)))
	{
	 INI_ParseFile(UserPath(playerid), "LoadUser_%s",.bExtra =true, .extra =playerid);
	}
	else if(!fexist(UserPath(playerid)))
	{
	  new INI:File = INI_Open(UserPath(playerid));
	  INI_SetTag(File,"PlayerInfo");
	  INI_WriteInt(File,"Kills",0);
	  INI_WriteInt(File,"Deaths",0);
	  INI_Close(File);
	}
	
	InDM[playerid] =0;
    return 1;
}
OnPlayerDisconnect :
Код:
public OnPlayerDisconnect(playerid, reason)
{
	new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File,"PlayerInfo");
	INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
	INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
        INI_Close(File);
	if(InDM[playerid] ==1)
	{
	  cn--;
	  InDM[playerid] =0;
	}
	CheckWin();
  	return 1;
}
and finall increasing count, I did it here:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(InDM[playerid] ==1)
    {
	  InDM[playerid] =0;
	  cn--;
	  new str[100];
	  new pName[MAX_PLAYER_NAME],kName[MAX_PLAYER_NAME];
	  GetPlayerName(killerid,kName,MAX_PLAYER_NAME);
	  GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
	  format(str, sizeof(str),"%s(%d) has been killed by %s(%d) in Deathmatch Minigame",pName,kName);
          PlayerInfo[killerid][pKills]++;  // <<<<<<<<<<<< Here and
	  PlayerInfo[playerid][pDeaths]++;  //<<<<<<<<<<<< Here I applied Increment.
	  CheckWin();
   }
	return 1;
}
I wanted to count only if the player is in DM. The problem is the fiile is succesfully creating for evey player that joins, but the count isn't increasing.
Please take a look. If you want to see the complete code for reference goto http://pastebin.com/fYW4kBAR
Reply
#2

Make sure your saving folder permissions are set to 777?
Reply
#3

well bro.. Can you explain? I never came across these permissions.
By the way, I forgot to mention, It increases to 1. and from there it doesn't increase.
Reply
#4

If you are running this under linux, then go to your users folder and set the folder permissions to 777 (public) in case you are accessing it on ftp.
If you use SSH, you may check this
Reply
#5

well, Im accessing through Filezilla and when i try to change to 777, It says Operation not permitted.
Reply
#6

Try to create a command that checks the player kill and death., and see if it increases or not
Reply
#7

Well, A command to check and see whether it increases or not? I didn't get your point bro. How can a command to check increase it?
Reply
#8

pawn Код:
Command: check(players,  params[])
{
    Format a string that defines the player kill and death
    Sendclientmessage(string)
}
If it's different than the saved file, there could be an issue with the saving
Sorry, I'm on phone
Reply
#9

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(InDM[playerid] ==1)
    {
      InDM[playerid] =0;
      cn--;
      new str[100];
      new pName[MAX_PLAYER_NAME],kName[MAX_PLAYER_NAME];
      GetPlayerName(killerid,kName,MAX_PLAYER_NAME);
      GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
      format(str, sizeof(str),"%s(%d) has been killed by %s(%d) in Deathmatch Minigame",pName,kName);
          pInfo[killerid][pKills]++;  // <<<<<<<<<<<< Here and
      pInfo[playerid][pDeaths]++;  //<<<<<<<<<<<< Here I applied Increment.
      CheckWin();
   }
    return 1;
}
Reply
#10

Quote:
Originally Posted by Clad
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(InDM[playerid] ==1)
    {
      InDM[playerid] =0;
      cn--;
      new str[100];
      new pName[MAX_PLAYER_NAME],kName[MAX_PLAYER_NAME];
      GetPlayerName(killerid,kName,MAX_PLAYER_NAME);
      GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
      format(str, sizeof(str),"%s(%d) has been killed by %s(%d) in Deathmatch Minigame",pName,kName);
          pInfo[killerid][pKills]++;  // <<<<<<<<<<<< Here and
      pInfo[playerid][pDeaths]++;  //<<<<<<<<<<<< Here I applied Increment.
      CheckWin();
   }
    return 1;
}
Код:
enum pInfo
{
  pKills,
  pDeaths
}

new PlayerInfo[MAX_PLAYERS][pInfo]; //<<<<<<<<<<<<<< Check here 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)