TopScoreCreate
#1

hi,
i want to display a top 5, top 10, top 15 or what ever texdraw after every round (Kills).
The texdraw is no problem but how to check whos the best, the second best third and so on?
Is that possible with this code?

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if (val < zdmcount[i] && i != id)
    {
        val = zdmcount[i];
        id2 = i;
    }
}
i hope u can help me.

regards...
Reply
#2

I am working on this for you... I have just created some code although i need to test it out and stuff.. Bare with me
Reply
#3

pawn Код:
new TotalScores[15];
new PlayerScore[2];
for(new player;player<MAX_PLAYERS;player++)
{
    PlayerScore[0]=GetPlayerScore(player);
    for(new place;place<sizeof(TotalScores);place++)
    {
        if(PlayerScore[0]>TotalScores[place])
        {
            strins(TotalScores,PlayerScore,place);
            place=sizeof(TotalScores); //Stop the second loop (place)
        }
    }
}
I was pleasantly surprised that this works


It works by turning the player's score into a string (PlayerScore[2]), it has to be '[2]' because the last spot is a place holder for 'NULL' which makes it a string, then I used the 'strins' function to place the score into TotalScores[15], just be sure that TotalScores is 1 more larger in size than what you want, so for 15 players you should put '[16]'
Reply
#4

GJ SilentHuntR, basicly the same as I what i was doing even though my strins was messing around but its okay now...
Reply
#5

hi,
thx alot, u both
im gonna try it out as soon as i got some time
thx!!
Reply
#6

hi,
ive created 2 texdraws that are shown to all players (a top 2 board )
The 2 players with the most kills currently playing in the server shall be displayed.
But the texdraw only shows my name,kills and rank.
Im listed in both texdraws but i want that the player with the most kills is shown in the first td and the second best killer in the second td.
How to do that with the given code?
Pls help.


pawn Код:
new TotalScores[3];
new PlayerScore[2];
for(new player;player<MAX_PLAYERS;player++)
{
PlayerScore[0]=kills[playerid]; //kills
for(new place;place<sizeof(TotalScores);place++)
    {
        if(PlayerScore[0]>TotalScores[place])
        {
            strins(TotalScores,PlayerScore,place);
            place=sizeof(TotalScores);
        }
    }


new stringa[80];
GetPlayerName(playerid, stringa, sizeof(stringa));
format(stringa, sizeof(stringa), "~r~1.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringa,kills[playerid],RankName[pRank[playerid]]);
TextDrawShowForPlayer(playerid,Top52);
TextDrawSetString(Text:Top52, stringa);
new stringb[80];
GetPlayerName(playerid, stringb, sizeof(stringb));
format(stringb, sizeof(stringb), "~r~2.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringb,kills[playerid],RankName[pRank[playerid]]);
TextDrawShowForPlayer(playerid,Top53);
TextDrawSetString(Text:Top53, stringb);

}
Reply
#7

pawn Код:
new TotalScores[3];
new TotalPlayers[3];
new PlayerScore[2];
new PlayerID[2];
for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        PlayerScore[0] = kills[i]; //kills
        PlayerID[0] = i;
        for(new place; place < sizeof(TotalScores); place++)
        {
            if(PlayerScore[0] > TotalScores[place])
            {
                strins(TotalScores, PlayerScore, place);
                strins(TotalPlayers, PlayerID, place);
                place = sizeof(TotalScores);
            }
        }
    }
}
new stringa[80];
GetPlayerName(TotalPlayers[0], stringa, sizeof(stringa));
format(stringa, sizeof(stringa), "~r~1.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringa,TotalScores[0],RankName[pRank[TotalPlayers[0]]]);
TextDrawShowForPlayer(playerid,Top52);
TextDrawSetString(Top52, stringa);
new stringb[80];
GetPlayerName(TotalPlayers[1], stringb, sizeof(stringb));
format(stringb, sizeof(stringb), "~r~2.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringb,TotalScores[1],RankName[pRank[TotalPlayers[1]]]);
TextDrawShowForPlayer(playerid,Top53);
TextDrawSetString(Top53, stringb);
Reply
#8

hi,
thx a lot once again MadeMan
Mhh, i dont know if its the fault if this code but it seems that its buggy as soon as there are more then 1-2 players in the server?
The first player that joins is able to view the top 5 board with /top
but if the second and third player that join type in /top it says unknown command.
But the ClientMessage still shows up.
Anyone knows where the probem might be?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
//Top5 Show
if (strcmp("/top", cmdtext, true) == 0)
{

SendClientMessage(playerid,0xAA3333AA,"{283A90}The {B0171F}Top 5 {283A90}board is displayed. {283A90}Type in {855E42}/tophide {283A90}to hide the {B0171F}Top 5 {283A90}board again.");

new TotalScores[6];
new TotalPlayers[6];
new PlayerScore[2];
new PlayerID[2];
for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        PlayerScore[0] = kills[i]; //kills
        PlayerID[0] = i;
        for(new place; place < sizeof(TotalScores); place++)
        {
            if(PlayerScore[0] > TotalScores[place])
            {
                strins(TotalScores, PlayerScore, place);
                strins(TotalPlayers, PlayerID, place);
                place = sizeof(TotalScores);
            }
        }
    }
}

TextDrawShowForPlayer(playerid,Top51);
new stringa[80];
GetPlayerName(TotalPlayers[0], stringa, sizeof(stringa));
format(stringa, sizeof(stringa), "~r~1.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringa,TotalScores[0],RankName[pRank[TotalPlayers[0]]]);
TextDrawShowForPlayer(playerid,Top52);
TextDrawSetString(Text:Top52, stringa);
new stringb[80];
GetPlayerName(TotalPlayers[1], stringb, sizeof(stringb));
format(stringb, sizeof(stringb), "~r~2.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringb,TotalScores[1],RankName[pRank[TotalPlayers[1]]]);
TextDrawShowForPlayer(playerid,Top53);
TextDrawSetString(Text:Top53, stringb);
new stringc[80];
GetPlayerName(TotalPlayers[2], stringc, sizeof(stringc));
format(stringc, sizeof(stringc), "~r~3.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringc,TotalScores[2],RankName[pRank[TotalPlayers[2]]]);
TextDrawShowForPlayer(playerid,Top54);
TextDrawSetString(Text:Top54, stringc);
new stringd[80];
GetPlayerName(TotalPlayers[3], stringd, sizeof(stringd));
format(stringd, sizeof(stringd), "~r~4.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringd,TotalScores[3],RankName[pRank[TotalPlayers[3]]]);
TextDrawShowForPlayer(playerid,Top55);
TextDrawSetString(Text:Top55, stringd);
new stringe[80];
GetPlayerName(TotalPlayers[4], stringe, sizeof(stringe));
format(stringe, sizeof(stringe), "~r~5.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringe,TotalScores[4],RankName[pRank[TotalPlayers[4]]]);
TextDrawShowForPlayer(playerid,Top56);
TextDrawSetString(Text:Top56, stringe);

return 1;
}

//Top5 Hide
if (strcmp("/tophide", cmdtext, true) == 0)
{

SendClientMessage(playerid,0xAA3333AA,"{283A90}The {B0171F}Top 5 {283A90}board is hidden now. {283A90}Type in {855E42}/top {283A90}to show the {B0171F}Top 5 {283A90}board again.");

TextDrawHideForPlayer(playerid,Top51);
TextDrawHideForPlayer(playerid,Top52);
TextDrawHideForPlayer(playerid,Top53);
TextDrawHideForPlayer(playerid,Top54);
TextDrawHideForPlayer(playerid,Top55);
TextDrawHideForPlayer(playerid,Top56);
return 1;
}
SendClientMessage(playerid, 0xAA3333AA,"This command doesn't exist!");
return 1;
}
regards...

//Edit:

Yeah, this code simply crashes the server
If there is just 1 player in the server it works fine but as soon as there are more than 1 players online it doesnt work.
In that case it says unknown command and no commands that are available on my server works anymore.
It always says unknown command. In addition to that it also bugs up my spawnpoints, the deathMessage isnt shown anymore ect.....
This is very important to me, id be very thankful if someone could tell me the error
Reply
#9

could someone pls tell me what wrong with this code
Reply
#10

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
//Top5 Show
if (strcmp("/top", cmdtext, true) == 0)
{

SendClientMessage(playerid,0xAA3333AA,"{283A90}The {B0171F}Top 5 {283A90}board is displayed. {283A90}Type in {855E42}/tophide {283A90}to hide the {B0171F}Top 5 {283A90}board again.");

new TotalScores[6];
new TotalPlayers[6];
new PlayerScore[2];
new PlayerID[2];
for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        PlayerScore[0] = kills[i]; //kills
        PlayerID[0] = i;
        for(new place; place < sizeof(TotalScores); place++)
        {
            if(PlayerScore[0] > TotalScores[place])
            {
                strins(TotalScores, PlayerScore, place);
                strins(TotalPlayers, PlayerID, place);
                place = sizeof(TotalScores);
            }
        }
    }
}

TextDrawShowForPlayer(playerid,Top51);
new stringa[80];
GetPlayerName(TotalPlayers[0], stringa, sizeof(stringa));
format(stringa, sizeof(stringa), "~r~1.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringa,TotalScores[0],RankName[pRank[TotalPlayers[0]]]);
TextDrawShowForPlayer(playerid,Top52);
TextDrawSetString(Text:Top52, stringa);
new stringb[80];
GetPlayerName(TotalPlayers[1], stringb, sizeof(stringb));
format(stringb, sizeof(stringb), "~r~2.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringb,TotalScores[1],RankName[pRank[TotalPlayers[1]]]);
TextDrawShowForPlayer(playerid,Top53);
TextDrawSetString(Text:Top53, stringb);
new stringc[80];
GetPlayerName(TotalPlayers[2], stringc, sizeof(stringc));
format(stringc, sizeof(stringc), "~r~3.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringc,TotalScores[2],RankName[pRank[TotalPlayers[2]]]);
TextDrawShowForPlayer(playerid,Top54);
TextDrawSetString(Text:Top54, stringc);
new stringd[80];
GetPlayerName(TotalPlayers[3], stringd, sizeof(stringd));
format(stringd, sizeof(stringd), "~r~4.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringd,TotalScores[3],RankName[pRank[TotalPlayers[3]]]);
TextDrawShowForPlayer(playerid,Top55);
TextDrawSetString(Text:Top55, stringd);
new stringe[80];
GetPlayerName(TotalPlayers[4], stringe, sizeof(stringe));
format(stringe, sizeof(stringe), "~r~5.  ~w~%s  ~r~%d ~w~Kills  ~y~%s", stringe,TotalScores[4],RankName[pRank[TotalPlayers[4]]]);
TextDrawShowForPlayer(playerid,Top56);
TextDrawSetString(Text:Top56, stringe);

return 1;
}

//Top5 Hide
if (strcmp("/tophide", cmdtext, true) == 0)
{

SendClientMessage(playerid,0xAA3333AA,"{283A90}The {B0171F}Top 5 {283A90}board is hidden now. {283A90}Type in {855E42}/top {283A90}to show the {B0171F}Top 5 {283A90}board again.");

TextDrawHideForPlayer(playerid,Top51);
TextDrawHideForPlayer(playerid,Top52);
TextDrawHideForPlayer(playerid,Top53);
TextDrawHideForPlayer(playerid,Top54);
TextDrawHideForPlayer(playerid,Top55);
TextDrawHideForPlayer(playerid,Top56);
return 1;
}
SendClientMessage(playerid, 0xAA3333AA,"This command doesn't exist!");
return 1;
}
Pls, could someone take a look at this code
Cause this is bugged up if there are more than 1 players online.
What could cause this problem?
Pls, this is very important to me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)