Dialog Not Showing Due to Stock
#1

Hey Guys,
I am making a Dialog MDC System and it works fine without having it get a string from a stock.
Can someone please let me know what is happening.

The line using the stock is:
pawn Код:
format(string, sizeof(string), "Name: %s, Age: 21, Current Charges: %s", inputtext, GetCharges(i));
And here is the stock:
pawn Код:
stock GetCharges(playerid)
{
    new string[256];
    for(new i = 0; i < 7; i++)
    {
        if(!isempty(g_PlayerInfo[playerid][pCharges][i]))
        {
            format(string, sizeof(string), "Charge %d: %s\n", i, g_PlayerInfo[playerid][pCharges][i]);
        }
        else if(isempty(g_PlayerInfo[playerid][pCharges][i]))
        {
            format(string, sizeof(string), "No Charge\n", i, g_PlayerInfo[playerid][pCharges][i]);
        }
    }
    return string;
}
And pCharges is like pCharges[6] under the PlayerInfo.
And I try to add pCharges[6][128] but it returns error 001: expected token: "}", but found "["
Reply
#2

you need a string to store your charges in. IE:

pawn Код:
stock GetCharges(playerid, charges[])
{
    for(new i = 0; i < 7; i++)
    {
        if(!isempty(g_PlayerInfo[playerid][pCharges][i]))
        {
            format(charges, sizeof(charges), "Charge %d: %s\n", i, g_PlayerInfo[playerid][pCharges][i]);
        }
        else if(isempty(g_PlayerInfo[playerid][pCharges][i]))
        {
            format(charges, sizeof(charges), "No Charge\n", i, g_PlayerInfo[playerid][pCharges][i]);
        }
    }
    return 1;
}
Then you need:

pawn Код:
new Charges[100];//pick a size that works, 100 is probably too small
format(string, sizeof(string), "Name: %s, Age: 21, Current Charges: %s", inputtext, GetCharges(i, charges));
Reply
#3

You can't have a 2D array inside a 2D enum.

pawn Код:
static g_Charges[MAX_PLAYERS][7][128];
Reply
#4

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
You can't have a 2D array inside a 2D enum.

pawn Код:
static g_Charges[MAX_PLAYERS][7][128];
Thankyou Emmet_
+REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)