29.07.2014, 11:44
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:
OnPlayerConnect part:
OnPlayerDisconnect :
and finall increasing count, I did it here:
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
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;
}
Код:
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;
}
Код:
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;
}
Код:
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;
}
Please take a look. If you want to see the complete code for reference goto http://pastebin.com/fYW4kBAR


