SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/11/2017, 08:37 PM   #1
Saddin
Huge Clucker
 
Saddin's Avatar
 
Join Date: Mar 2011
Posts: 372
Reputation: 35
Default Can't count kills on faction wars

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] == && player_in_war[killerid] == 1
        {
            if(
PlayerInfo[playerid][pMember] == PlayerInfo[killerid][pMember]) 
            {
                if(
PlayerInfo[killerid][pMember] == War_T1War_T1_Score--;
                else if(
PlayerInfo[killerid][pMember] == War_T2War_T2_Score--;

                
format(xs200"* %s killed his teammate. His faction lose 1 point."GetName(killerid));
                
SendClientMessage(playeridCOLOR_INFOxs);
                
//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 
Player)
            {
                if(
gPlayerLogged[i] == && IsPlayerConnected(i))
                {
                    if(
player_in_war[i] == 1)
                    {
                        
SendDeathMessageToPlayer(ikilleridplayeridreason);
                    }
                }
            }
        }
    } 
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(playeridparams[],help)
{
    
#pragma unused help

    
if(player_in_war[playerid] == 1)
    {
        new 
scoremsg[200];
        
format(scoremsg200"* Team #1 (%s): %d {EE3939}/// {FFFFFF}Team #2 (%s): %d {EE3939}/// {FFFFFF}Do kraja rata: %s"GetOrgName(War_T1), War_T1_ScoreGetOrgName(War_T2), War_T1_ScoreSecToMin(War_Time));
        
SendClientMessage(playeridCOLOR_WHITEscoremsg);
    }
    return 
1;

Saddin is offline   Reply With Quote
Old 14/11/2017, 08:59 PM   #2
Jaxium
Little Clucker
 
Join Date: Nov 2017
Location: Egypt
Posts: 11
Reputation: 1
Default Re: Can't count kills on faction wars

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); 
                    } 
                } 
            } 
        } 
    }
Jaxium is offline   Reply With Quote
Old 14/11/2017, 09:09 PM   #3
Saddin
Huge Clucker
 
Saddin's Avatar
 
Join Date: Mar 2011
Posts: 372
Reputation: 35
Default Re: Can't count kills on faction wars

It won't work.
Saddin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How count % Done Headshots from kills done G4m4r Scripting Help 0 07/06/2016 04:33 PM
How to count how much players in a faction DemME Scripting Help 5 23/05/2016 12:22 PM
Kills count bug NeamPojma Scripting Help 2 10/11/2015 05:11 PM
Count team kills SalmaN97 Scripting Help 6 18/08/2015 05:50 AM


All times are GMT. The time now is 12:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.