28.07.2014, 14:45
Well, I'm trying to make a Deathmatch script where a winner is declared when theres only one player left. Maybe this is what called as Last Man Standing. Whatever, I have a problem. No compilation errors. But when tested, Winner is not declared even when theres only one player left. Check the code and help me in rectifying it. And yes I'm a noob, newbie or whatever.

Here's the function :
Well, If the problem isn't in here but somewhere else in the code, Here's the link for the whole script I Made
http://pastebin.com/UWFNqMSi
Thank you.

Код:
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]++;
PlayerInfo[playerid][pDeaths]++;
CheckWin(); // Here I call to check winner
}
return 1;
}
Код:
forward CheckWin();
public CheckWin()
{
if(cn ==1)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(InDM[i] ==1)
{
new string[128], winner[MAX_PLAYER_NAME];
GetPlayerName(i,winner,MAX_PLAYER_NAME);
format(string,sizeof(string),"%s(%d) Has won the DeathMatch[Minigame]",winner,i);
}
}
}
}
http://pastebin.com/UWFNqMSi
Thank you.

