show bounties
#1

I made a bouties script and now I like to show them via command.
but not for every bounty 1 line, i like to make more as possible in one line, and then another line when it's over 128.
how to do that?

my code:

pawn Код:
if(strcmp(cmd,"/bounties",true)==0)
    {
        new amount;
        SendClientMessage(playerid,_COLOR_GREEN,"Bountys at the moment:");
        foreach(Player,i)
        {
            if(bounty[i] > 0)
            {
                amount++;
...
            }
        }
        if(amount == 0) SendClientMessage(playerid,_COLOR_WHITE,"There are not any bounties at the moment.");
        return 1;
    }
Reply
#2

bump....
Reply
#3

Show them in dialog (style list). Use strcat to put separate lines together.
Reply
#4

okay, now I got with that another idea.
i made the dialog below:

pawn Код:
if(strcmp(cmd,"/bounties",true)==0)
    {
        new amount;
        new list[960];
        foreach(Player,i)
        {
            if(bounty[i] > 0)
            {
                amount++;
                format(string,sizeof string,"%s(ID: %d) ($%d)\n",PlayerName(i), i, bounty[i]*1000);
                strcat(list,string);
            }
        }
        if(amount == 0) return SendClientMessage(playerid,_COLOR_WHITE,"There are not any bounties at the moment.");
        else
        {
            new header[15];
            format(header,sizeof(header),"Bounties: %d",amount);
            ShowPlayerDialog(playerid,200,DIALOG_STYLE_LIST,header,var,"Close", "Close");
        }
        return 1;
    }
so my idea & question is: how can I do that when the player clicks on the name in the dialog, it will open the player statistics? (I already have the player statistics, just say me how I can get or return the ID from the player in the list)
Reply
#5

bump...............
Reply
#6

another bump ..
Reply
#7

this is my bounty script


Код:
if(strcmp(cmd, "/bounties", true) == 0)
	{
//		new tmp[256];
		new x;

		SendClientMessage(playerid, COLOR_GREEN, "Current Bounties:");
	    for(new i=0; i < MAX_PLAYERS; i++) {
			if(IsPlayerConnected(i) && bounty[i] > 0) {
				GetPlayerName(i, giveplayer, sizeof(giveplayer));
				format(string, sizeof(string), "%s%s(%d): $%d", string,giveplayer,i,bounty[i]);

				x++;
				if(x > 3) {
				    SendClientMessage(playerid, COLOR_YELLOW, string);
				    x = 0;
					format(string, sizeof(string), "");
				} else {
					format(string, sizeof(string), "%s, ", string);
				}
			}
		}

		if(x <= 3 && x > 0) {
			string[strlen(string)-2] = '.';
		    SendClientMessage(playerid, COLOR_YELLOW, string);
		}

		return 1;
	}
Reply
#8

ok thx for your code, but i decided to show the bounties with dialog.
now my question, how can I do, that it orders by the largest bounty?!

Example:
#1 Ribber(ID: 3) $ 34000
#2 Player2(ID: 0) $ 30000
#3 Player3(ID: 5) $ 26000
#4 Player4(ID: 1) $ 22000
.....

my code:

pawn Код:
if(strcmp(cmd,"/bounties",true)==0)
    {
        new amount;
        new list[500];
        foreach(Player,i)
        {
            if(bounty[i] > 0)
            {
                amount++;
                format(string,sizeof string,"#%d\t%s(ID: %d)\t $%d\n",amount, PlayerName(i), i, bounty[i]*1000);
                strcat(list,string);
            }
        }
        if(amount == 0) return SendClientMessage(playerid,_COLOR_WHITE,"There are not any bounties at the moment.");
        else
        {
            new header[30];
            format(header,sizeof(header),"Bounties: %d",amount);
            ShowPlayerDialog(playerid,300,DIALOG_STYLE_LIST,header,list,"Close", "Close");
        }
        return 1;
    }
Reply
#9

bump.., how can i do that..?
I tried the whole time, the best result was that when I was id 0 i was in the first place while the id 1 had lower bounty than id 0.
but when id 1 has higher bounty than id 0, it only will show id 1..


pawn Код:
if(strcmp(cmd,"/bounties",true)==0)
    {
        new List[MAX_PLAYERS][2];
        new count;
        foreach(Player,i)
        {
            if(bounty[i] > 0)
            {
                List[count][0] = i; //ID
                List[count][1] = bounty[i]; //BOUNTY
                count++;
            }
        }
        if(count == 0) return SendClientMessage(playerid,_COLOR_WHITE,"There are not any bounties at the moment.");
        else
        {
            for(new i; i < count; i++)
            {
                if(List[i][1] > List[i+1][1])
                {
                    format(string,sizeof string,"%s (%d) - $%d", PlayerName( List[i][0] ), List[i][0], bounty[ List[i][0] ]*1000);
                    SendClientMessage(playerid,_COLOR_YELLOW,string);
                }
            }
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)