Can't count kills on faction wars - 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)
+--- Thread: Can't count kills on faction wars (
/showthread.php?tid=644813)
Can't count kills on faction wars -
Saddin - 14.11.2017
PHP Code:
if(killerid != INVALID_PLAYER_ID)
{
PlayerInfo[killerid][pKills] += 1;
//WAR SISTEM
new xs[200];
if(IsPlayerConnected(killerid) && is_war_active == true && player_in_war[playerid] == 1 && player_in_war[killerid] == 1)
{
if(PlayerInfo[playerid][pMember] == PlayerInfo[killerid][pMember])
{
if(PlayerInfo[killerid][pMember] == War_T1) War_T1_Score--;
else if(PlayerInfo[killerid][pMember] == War_T2) War_T2_Score--;
format(xs, 200, "* %s killed his teammate. His faction lose 1 point.", GetName(killerid));
SendClientMessage(playerid, COLOR_INFO, xs);
//IgracSkorUbistva[killerid]--,
}
if(PlayerInfo[killerid][pMember] == War_T1 && PlayerInfo[playerid][pMember] == War_T2)
{
War_T1_Score++;
//IgracSkorUbistva[killerid]++;
//IgracSkorSmrti[playerid]++;
}
else if(PlayerInfo[killerid][pMember] == War_T2 && PlayerInfo[playerid][pMember] == War_T1)
{
War_T2_Score++;
//IgracSkorUbistva[killerid]++;
//IgracSkorSmrti[playerid]++;
}
foreach (new i : Player)
{
if(gPlayerLogged[i] == 1 && IsPlayerConnected(i))
{
if(player_in_war[i] == 1)
{
SendDeathMessageToPlayer(i, killerid, playerid, reason);
}
}
}
}
}
Problem is that it don't count anything, when 1 member from team1 kill another from team2 counter won't work. When member from team2 kill member from team1 it count but it increase point for team1 and team2 in the same time.
Also I have a question, because SendDeathMessage is spamming and it works correctly. How to delete 'log' when the war is over.
Command for score:
PHP Code:
YCMD:score(playerid, params[],help)
{
#pragma unused help
if(player_in_war[playerid] == 1)
{
new scoremsg[200];
format(scoremsg, 200, "* Team #1 (%s): %d {EE3939}/// {FFFFFF}Team #2 (%s): %d {EE3939}/// {FFFFFF}Do kraja rata: %s", GetOrgName(War_T1), War_T1_Score, GetOrgName(War_T2), War_T1_Score, SecToMin(War_Time));
SendClientMessage(playerid, COLOR_WHITE, scoremsg);
}
return 1;
}
Re: Can't count kills on faction wars -
Jaxium - 14.11.2017
You need else if rather than if in the second statement. Try this code, not tested. Also make sure the callback has its return.
Code:
if(killerid != INVALID_PLAYER_ID)
{
PlayerInfo[killerid][pKills] += 1;
//WAR SISTEM
new xs[200];
if(IsPlayerConnected(killerid) && is_war_active == true && player_in_war[playerid] == 1 && player_in_war[killerid] == 1)
{
if(PlayerInfo[playerid][pMember] == PlayerInfo[killerid][pMember])
{
if(PlayerInfo[killerid][pMember] == War_T1) War_T1_Score--;
else if(PlayerInfo[killerid][pMember] == War_T2) War_T2_Score--;
format(xs, 200, "* %s killed his teammate. His faction lose 1 point.", GetName(killerid));
SendClientMessage(playerid, COLOR_INFO, xs);
//IgracSkorUbistva[killerid]--,
}
else if(PlayerInfo[killerid][pMember] == War_T1 && PlayerInfo[playerid][pMember] == War_T2)
{
War_T1_Score++;
//IgracSkorUbistva[killerid]++;
//IgracSkorSmrti[playerid]++;
}
else if(PlayerInfo[killerid][pMember] == War_T2 && PlayerInfo[playerid][pMember] == War_T1)
{
War_T2_Score++;
//IgracSkorUbistva[killerid]++;
//IgracSkorSmrti[playerid]++;
}
foreach (new i : Player)
{
if(gPlayerLogged[i] == 1 && IsPlayerConnected(i))
{
if(player_in_war[i] == 1)
{
SendDeathMessageToPlayer(i, killerid, playerid, reason);
}
}
}
}
}
Re: Can't count kills on faction wars -
Saddin - 14.11.2017
It won't work.