How to pass this to a dialog
#1

Hi, i need someone to explain me how to pass this into a dialog. I don't know how :/
pawn Код:
//New
new Text:txtdraw;
new Text:Stats;

new
        Text: text_Top5[2]
;

enum rankingEnum
{
    player_Score,
    player_ID
}

public OnGameModeInit()
{

text_Top5[1] = TextDrawCreate(16.000000, 135.000000, " ");
    TextDrawBackgroundColor(text_Top5[1], 255);
    TextDrawFont(text_Top5[1], 1);
    TextDrawLetterSize(text_Top5[1], 0.200000, 0.999999);
    TextDrawColor(text_Top5[1], -1);
    TextDrawSetOutline(text_Top5[1], 0);
    TextDrawSetProportional(text_Top5[1], 1);
    TextDrawSetShadow(text_Top5[1], 0);
    TextDrawUseBox(text_Top5[1], 1);
    TextDrawBoxColor(text_Top5[1], 150);
    TextDrawTextSize(text_Top5[1], 143.000000, 20.000000);

    Stats = TextDrawCreate(291.000000, 390.000000, "Stats");
    TextDrawBackgroundColor(Stats, 255);
    TextDrawFont(Stats, 1);
    TextDrawLetterSize(Stats, 0.500000, 1.400000);
    TextDrawColor(Stats, -1);
    TextDrawSetOutline(Stats, 0);
    TextDrawSetProportional(Stats, 1);
    TextDrawSetShadow(Stats, 1);
    TextDrawSetSelectable(Stats, true);
    TextDrawTextSize(Stats, 293.000000, 405.000000);
   
    txtdraw = TextDrawCreate(240.000000, 20.000000 , "TOP PLAYERS");
    TextDrawFont(txtdraw, 1);
    TextDrawLetterSize(txtdraw, 0.6, 4.2);
    TextDrawColor(txtdraw, 0x33AA33AA);
    TextDrawSetOutline(txtdraw, false);
    TextDrawSetProportional(txtdraw, true);
    TextDrawSetShadow(txtdraw, 1);
    return 1;
}

public OnGameModeExit()
{
TextDrawDestroy(text_Top5[0]);
    TextDrawDestroy(text_Top5[1]);
 return 1;
}

//COMMANDS
CMD:tops(playerid, params[])
{
    new playerScores[MAX_PLAYERS][rankingEnum], index;
    for(new i; i != MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
                 playerScores[index][player_Score] = GetPlayerScore(i);
                 playerScores[index++][player_ID] = i;
        }
    }
    GetPlayerHighestScores(playerScores, 0, index);
    new score_Text[256] = "~n~", player_Name[20];
    for(new i; i < 5; ++i)
    {
            if(i < index)
            {
                GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
            }
            else
            {
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, i + 1);
            }
    }
    TextDrawSetString(text_Top5[1], score_Text);
    TextDrawShowForPlayer(playerid, text_Top5[0]);
    TextDrawShowForPlayer(playerid, text_Top5[1]);
    TextDrawShowForPlayer(playerid, txtdraw);
    SendClientMessage(playerid, -1, "{FF3300}This are the top 5 players, use {DBED15}/notops{FFFFFF} stop viewing.");
    return 1;
}

CMD:notops(playerid, params[])
{
    TextDrawHideForPlayer(playerid, text_Top5[0]);
    TextDrawHideForPlayer(playerid, text_Top5[1]);
    TextDrawHideForPlayer(playerid, txtdraw);
    return 1;
}

//STOCK
stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
    new
        tempLeft = left,
        tempRight = right,
        pivot = array[(left + right) / 2][player_Score],
        tempVar
    ;
    while(tempLeft <= tempRight)
    {
        while(array[tempLeft][player_Score] > pivot) tempLeft++;
        while(array[tempRight][player_Score] < pivot) tempRight--;

        if(tempLeft <= tempRight)
        {
            tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
            tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
            tempLeft++, tempRight--;
        }
    }
    if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
    if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
I think i didn't miss anything. Please help me with this. Thanksss!
Reply
#2

Someone? Please?
Reply
#3

Please be more specific. I have no idea what you're trying to do.
Reply
#4

What you don't understand.
Reply
#5

Me neither dude, BTW how do you get -103 REP ? Someone reset this poor chaps account lol.
Reply
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Me neither dude, BTW how do you get -103 REP ? Someone reset this poor chaps account lol.
Because i used to beg for -rep.

What i want is to show the information in a dialog instead of textdraws. Get it?
Reply
#7

He's wanting to change it to where it appears on a DIALOG_STYLE_MSGBOX type of dialog. Can be done with creating a big string (600+ size) and strcmp.
Reply
#8

pawn Код:
for(new i; i < 5; ++i)
    {
            if(i < index)
            {
                GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
            }
            else
            {
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, i + 1);
            }
    }
    ShowPlayerDialog(playerid, ID DIALOG, DIALOG_STYLE_MSGBOX, "Top Players", score_Text, "OK", "");
    return 1;
}
Reply
#9

Quote:
Originally Posted by Loox
Посмотреть сообщение
pawn Код:
for(new i; i < 5; ++i)
    {
            if(i < index)
            {
                GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
            }
            else
            {
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, i + 1);
            }
    }
    ShowPlayerDialog(playerid, ID DIALOG, DIALOG_STYLE_MSGBOX, "Top Players", score_Text, "OK", "");
    return 1;
}
So, i replace the whole code with that?
Reply
#10

lol..

Just this part, like this:

pawn Код:
enum rankingEnum
{
    player_Score,
    player_ID
}

//COMMANDS
CMD:tops(playerid, params[])
{
    new playerScores[MAX_PLAYERS][rankingEnum], index;
    for(new i; i != MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
                 playerScores[index][player_Score] = GetPlayerScore(i);
                 playerScores[index++][player_ID] = i;
        }
    }
    GetPlayerHighestScores(playerScores, 0, index);
    new score_Text[256] = "~n~", player_Name[20];
    for(new i; i < 5; ++i)
    {
            if(i < index)
            {
                GetPlayerName(playerScores[i][player_ID], player_Name, sizeof(player_Name));
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~w~%s - ~r~%d", score_Text, i + 1, player_Name, playerScores[i][player_Score]);
            }
            else
            {
                format(score_Text, sizeof(score_Text), "%s~n~~b~%d. ~r~N/A", score_Text, i + 1);
            }
    }
    ShowPlayerDialog(playerid, ID DIALOG, DIALOG_STYLE_MSGBOX, "Top Players", score_Text, "OK", "");
    return 1;
}

//STOCK
stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
    new
        tempLeft = left,
        tempRight = right,
        pivot = array[(left + right) / 2][player_Score],
        tempVar
    ;
    while(tempLeft <= tempRight)
    {
        while(array[tempLeft][player_Score] > pivot) tempLeft++;
        while(array[tempRight][player_Score] < pivot) tempRight--;

        if(tempLeft <= tempRight)
        {
            tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
            tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
            tempLeft++, tempRight--;
        }
    }
    if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
    if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)