SA-MP Forums Archive
Facing some issues - 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: Facing some issues (/showthread.php?tid=281376)



Facing some issues - Jafet_Macario - 05.09.2011

Hello, I need help with some stuff, tried some methods but didn't succed.So, I made somthing, when a leader types /acceptwar, after 1 hour the war will be automatically announced over.
pawn Код:
if(strcmp(cmd, "/acceptwar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(acceptwar == 1)
            {
                if(PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pLeader] == 17 || PlayerInfo[playerid][pLeader] == 16)
                {
                    acceptwar = 0;
                    SendClientMessageToAll(COLOR_BLUE,"Mafia,Ballas,VLA has accepted the WAR");
                    SetTimer("WarEnded", 60000, 0);
                }
                else if(PlayerInfo[playerid][pLeader] == 6 || PlayerInfo[playerid][pLeader] == 15 || PlayerInfo[playerid][pLeader] == 18)
                {
                    acceptwar = 0;
                    SendClientMessageToAll(COLOR_BLUE,"Grove,Triads,LSV has accepted the war!");
                    SetTimer("WarEnded", 60000, 0);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY," You are not authorized to use this command(LEADERS ONLY)");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "  there were not proposed any war");
            }
        }
        return 1;
    }
pawn Код:
forward WarEnded();
    public WarEnded()
    {
        SendClientMessageToAll(COLOR_RED,"60 Minutes has passed, WAR OVER");
        return 1;
    }
And the thing what I want to do is, when the leader of a faction types /acceptwar, from then on it will save every faction kills, only for 1 hour, until the war is over.And when the war is over, also announced every faction kills.
For example:

Jafet Macario types /acceptwar

-----1 hour passed

Код:
60 Minutes has passed,war over.Mafia Ballas VLA: 56 Kills || Grove Triads LSV 60 Kills.
Damn, I tried some methods but didn't worked, can anyone give me some tips what functions should I use, or anything ^^ ? Thank you.


Re: Facing some issues - =WoR=Varth - 05.09.2011

pawn Код:
new Killing[MAX_TEAMS],
    bool:IsWar;

//When the war started
IsWar++;

public OnPlayerDeath(playerid,killerid,reason)
{
    if(IsWar && killerid != INVALID_PLAYER_ID) Killing[gTeam[killerid]]++;//Simple??
    return 1;
}

//When the war ended
IsWar--;
for(new i;i<MAX_TEAMS;i++)
{
    Killing[i] = 0;
}
EDITED


Re: Facing some issues - [MWR]Blood - 05.09.2011

EDIT: too late


Re: Facing some issues - Jafet_Macario - 05.09.2011

Getting always 0 kills at the end.
Any ideas?


Re: Facing some issues - [MWR]Blood - 06.09.2011

A little edit of varthshenon's code.
pawn Код:
new Killing[MAX_TEAMS],
    bool:IsWar;

//When the war started
for(new i;i < MAX_TEAMS;i++)
{
    Killing[i] = 0;
}
IsWar = true;

public OnPlayerDeath(playerid,killerid,reason)
{
    if(IsWar && killerid != INVALID_PLAYER_ID) Killing[gTeam[killerid]]++;//Simple??
    return 1;
}

//When the war ended
IsWar = false;



Re: Facing some issues - Jafet_Macario - 06.09.2011

So I got this now:
pawn Код:
#define MAX_TEAMS 10 // top
new Killing[MAX_TEAMS], // top
    bool:IsWar;
   

forward WarEnded();
public WarEnded()
{
    new str[128];
    IsWar = false;
    for(new a;a<MAX_PLAYERS;a++)
    {
        format(str, 128,"WAR OVER.Triads Grove LSV: %d kills || Mafia Ballas VLA %d kills,",Killing[18] + Killing[6] + Killing[15], Killing[5] + Killing[17] + Killing[16]);
        SendClientMessageToAll(COLOR_WHITE,str);
    }
    return 1;
}
if(IsWar && killerid != INVALID_PLAYER_ID) Killing[gTeam[killerid]]++; // OnPlayerDeath

    if(strcmp(cmd, "/acceptwar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(acceptwar == 1)
            {
                if(PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pLeader] == 17 || PlayerInfo[playerid][pLeader] == 16)
                {
                    acceptwar = 0;
                    SendClientMessageToAll(COLOR_BLUE,"Mafia,Ballas,VLA has Accepted WARUL!");
                    SetTimer("WarEnded", 60000, 0);
                    for(new i;i < MAX_TEAMS;i++)
                    {
                        Killing[i] = 0;
                    }
                    IsWar = true;
                }
                else if(PlayerInfo[playerid][pLeader] == 6 || PlayerInfo[playerid][pLeader] == 15 || PlayerInfo[playerid][pLeader] == 18)
                {
                    acceptwar = 0;
                    SendClientMessageToAll(COLOR_BLUE,"Grove,Triads,LSV has Accepted WARUL!");
                    SetTimer("WarEnded", 60000, 0);
                    for(new i;i < MAX_TEAMS;i++)
                    {
                        Killing[i] = 0;
                    }
                    IsWar = true;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY,"    you are not authorized to use this command(LEADERS ONLY)");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   there wasn't any war proposed");
            }
        }
        return 1;
    }
The problem is, when the war is over ( after 1 minute ) it send me like 100 messages that the war is over, but the kills for Mafia Ballas and VLA doesn't show up, it shows 0 for them, but for anothers it shows the right ones.


Re: Facing some issues - [MWR]Blood - 06.09.2011

Well, check your PMs.
I fixed your code...


Re: Facing some issues - Jafet_Macario - 06.09.2011

Still not working, shows 0 kills.And in varthshenon case also.


Re: Facing some issues - =WoR=Varth - 06.09.2011

pawn Код:
#define MAX_TEAMS 10 // top
new Killing[MAX_TEAMS], // top
    bool:IsWar;
   

forward WarEnded();
public WarEnded()
{
    new str[128];
    IsWar = false;
    format(str, 128,"WAR OVER.Triads Grove LSV: %d kills || Mafia Ballas VLA %d kills,",Killing[18] + Killing[6] + Killing[15], Killing[5] + Killing[17] + Killing[16]);
    SendClientMessageToAll(COLOR_WHITE,str);
    for(new i;i<MAX_TEAM;i++)
    {
        Killing[i] = 0;
    }
    return 1;
}

if(IsWar && killerid != INVALID_PLAYER_ID) Killing[gTeam[killerid]]++; // OnPlayerDeath

    if(strcmp(cmd, "/acceptwar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(acceptwar == 1)
            {
                if(PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pLeader] == 17 || PlayerInfo[playerid][pLeader] == 16)
                {
                    acceptwar = 0;
                    SendClientMessageToAll(COLOR_BLUE,"Mafia,Ballas,VLA has Accepted WARUL!");
                    SetTimer("WarEnded", 60000, 0);
                    for(new i;i < MAX_TEAMS;i++)
                    {
                        Killing[i] = 0;
                    }
                    IsWar = true;
                }
                else if(PlayerInfo[playerid][pLeader] == 6 || PlayerInfo[playerid][pLeader] == 15 || PlayerInfo[playerid][pLeader] == 18)
                {
                    acceptwar = 0;
                    SendClientMessageToAll(COLOR_BLUE,"Grove,Triads,LSV has Accepted WARUL!");
                    SetTimer("WarEnded", 60000, 0);
                    for(new i;i < MAX_TEAMS;i++)
                    {
                        Killing[i] = 0;
                    }
                    IsWar = true;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY,"    you are not authorized to use this command(LEADERS ONLY)");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   there wasn't any war proposed");
            }
        }
        return 1;
    }

OnPlayerDeath(playerid,killerid,reason)
{
    Killing[PlayerInfo[killerid][pLeader]]++;
    return 1;
}



Re: Facing some issues - Jafet_Macario - 06.09.2011

Damn damn damn IT WORKS! Thanks guys. rep++ for you.