22.11.2014, 10:43
(
Last edited by buburuzu19; 22/11/2014 at 06:12 PM.
)
FIXED!
CMD:myvehicles(playerid,params[])
{
new string[800];
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel1] - 400]);
format(string, sizeof(string), "%s%s\n", string, VehicleNames[playerVariables[playerid][pCarModel2] - 400]);
format(string, sizeof(string), "%s%s\n", string, VehicleNames[playerVariables[playerid][pCarModel3] - 400]);
format(string, sizeof(string), "%s%s\n", string, VehicleNames[playerVariables[playerid][pCarModel4] - 400]);
ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_LIST, "Your personal vehicles", string, "Ok", "Close");
return 1;
}
pawn Code:
|
CMD:myvehicles(playerid,params[])
{
new sstring[/*Specify size here*/], string[/*Specify size here*/];
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel1] - 400]);
strcat(sstring, string);
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel2] - 400]);
strcat(sstring, string);
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel3] - 400]);
strcat(sstring, string);
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel4] - 400]);
strcat(sstring, string);
ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_LIST, "Your personal vehicles", sstring, "Ok", "Close");
return 1;
}
You are reformatting the same string over and over again.
Format the string and use strcat to add them up to each other. Like this: pawn Code:
|
CMD:myvehicles(playerid,params[])
{
new string[50];
format(string,sizeof(string),"%s\n%s\n%s\n%s",VehicleNames[playerVariables[playerid][pCarModel1] - 400]
,VehicleNames[playerVariables[playerid][pCarModel2] - 400]
,VehicleNames[playerVariables[playerid][pCarModel3] - 400]
,VehicleNames[playerVariables[playerid][pCarModel4] - 400])
ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_LIST, "Your personal vehicles", string, "Ok", "Close");
return 1;
}
Why would you use 800 cells? That's way too much and you only need around 30 cells because the max cars you can have are 4 and lets say every car takes around 6-8 cells, approximately 30, let's make it 50 now you can change it later.
pawn Code:
Question: When you type /myvehicles does the dialog show and what's in it is empty or what? |
printf("%i %i %i",playerVariables[playerid][pCarModel2],playerVariables[playerid][pCarModel3],playerVariables[playerid][pCarModel4]);
Try this code below, and just modify the messages.
pawn Код:
|
CMD:myvehicles(playerid,params[])
{
new sstring[10000], string[10000];
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel1] - 400]);
strcat(sstring, string);
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel2] - 400]);
strcat(sstring, string);
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel3] - 400]);
strcat(sstring, string);
format(string, sizeof(string), "%s\n", VehicleNames[playerVariables[playerid][pCarModel4] - 400]);
strcat(sstring, string);
printf("%i %i %i %i",playerVariables[playerid][pCarModel1],playerVariables[playerid][pCarModel2],playerVariables[playerid][pCarModel3],playerVariables[playerid][pCarModel4]);
ShowPlayerDialog(playerid, 5000, DIALOG_STYLE_LIST, "Your personal vehicles", sstring, "Ok", "Close");
return 1;
}