SA-MP Forums Archive
Gang Leaderboard - 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: Gang Leaderboard (/showthread.php?tid=367531)



Gang Leaderboard - Infamous - 10.08.2012

Hi there, I am working on a a small gang system with 3 teams which all have an overall score.
The problem I have is that my gang leaderboard is conflicting (sometimes one team shows up twice or scores don't update on the board but do under OnPlayerDeath) alot and it's because of my if statements.

The link below shows all the code I use under OnPlayerUpdate.
http://pastebin.com/rMJHPgBS

pawn Код:
// Some info you may need to know.
GangTextBody1 = Top position on leader board.
GangTextBody2 = Middle position on leader board.
GangTextBody3 = Bottom position on leader board.
Also an image of the leaderboard incase that helps you see what i'm trying to do here.


If anyone can tell me where I have gone wrong or offer some advice on how to improve the checks then please do tell me.


Re: Gang Leaderboard - leonardo1434 - 10.08.2012

Kinda useless use it inside onplayerupdate, normally i make a new public and call it by using calllocalfunction, which is better calling it when it really requires.

i recommend you post the fully code, instead of post a piece. so i would be able to help you instead.


Re: Gang Leaderboard - Infamous - 10.08.2012

Well that is all the code really other than the score being increased under OnPlayerDeath.

pawn Код:
// My enum
enum ServerData
{
    Mafia_Score,
    Triads_Score,
    Aztecas_Score
};
new ServerInfo[ServerData];

// OnPlayerDeath
if(gTeam[playerid] == TEAM_MAFIA && gTeam[killerid] == TEAM_TRIADS)
    {
        ServerInfo[Triads_Score] += 1;
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
        GivePlayerMoney(killerid, 10000);
    }
    else if(gTeam[playerid] == TEAM_MAFIA && gTeam[killerid] == TEAM_AZTECAS)
    {
        ServerInfo[Aztecas_Score] += 1;
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
        GivePlayerMoney(killerid, 10000);
    }
   
    if(gTeam[playerid] == TEAM_TRIADS && gTeam[killerid] == TEAM_MAFIA)
    {
        ServerInfo[Mafia_Score] += 1;
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
        GivePlayerMoney(killerid, 10000);
    }
    else if(gTeam[playerid] == TEAM_TRIADS && gTeam[killerid] == TEAM_AZTECAS)
    {
        ServerInfo[Aztecas_Score] += 1;
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
        GivePlayerMoney(killerid, 10000);
    }
   
    if(gTeam[playerid] == TEAM_AZTECAS && gTeam[killerid] == TEAM_MAFIA)
    {
        ServerInfo[Mafia_Score] += 1;
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
        GivePlayerMoney(killerid, 10000);
    }
    else if(gTeam[playerid] == TEAM_TRIADS && gTeam[killerid] == TEAM_TRIADS)
    {
        ServerInfo[Triads_Score] += 1;
        SetPlayerScore(killerid, GetPlayerScore(killerid) +1);
        GivePlayerMoney(killerid, 10000);
    }
I hope that helps you see what i'm doing.


Re: Gang Leaderboard - leonardo1434 - 10.08.2012

Well, i couldn't see any problem under onplayerdeath, about the pastebin, it's too messed.


Re: Gang Leaderboard - Infamous - 10.08.2012

I don't suppose anyone else woul be able to see where I've gone wrong?