ZCMD & STRCAT: Why this code don't work? -
DarkLouis - 09.06.2015
Hi all, I did:
PHP код:
CMD:vmenu(playerid, params[])
{
new
finale[400],
veicolo_1[200],
veicolo_2[200],
veicolo_3[200];
new
id = PlayerInfo[playerid][IDVeicolo],
id2 = PlayerInfo[playerid][IDVeicolo2],
id3 = PlayerInfo[playerid][IDVeicolo3];
if(id == 0) veicolo_1 = "Slot libero\n";
else if(id != 0)
{
format(veicolo_1, sizeof(veicolo_1), "%s - (FC 0%d LV)\n", GetVehicleName( id ), id);
strcat(finale, veicolo_1, sizeof(finale));
}
if(id2 == 0) veicolo_2 = "Slot libero\n";
else if(id2 != 0)
{
format(veicolo_2, sizeof(veicolo_2), "%s - (FC 0%d LV)\n", GetVehicleName( id2 ), id2);
strcat(finale, veicolo_2, sizeof(finale));
}
if(id3 == 0) veicolo_3 = "Slot libero\n";
else if(id3 != 0)
{
format(veicolo_3, sizeof(veicolo_3), "%s - (FC 0%d LV)\n", GetVehicleName( id3 ), id3);
strcat(finale, veicolo_3, sizeof(finale));
}
ShowPlayerDialog(playerid, DIALOG_VMENU, DIALOG_STYLE_LIST, "Menщ veicolo", finale, "Seleziona", "Esci");
return 1;
}
In the game when I type /vmenu, it show me: ERROR UNKOWN COMMAND.
Why?
Re: ZCMD & STRCAT: Why this code don't work? -
Ritzy2K - 09.06.2015
why dont u use sscanf?
edit: oh nevermind. wait
Re: ZCMD & STRCAT: Why this code don't work? -
DarkLouis - 09.06.2015
How? I have to show 3 vehicles in that dialog.
Re: ZCMD & STRCAT: Why this code don't work? -
Konstantinos - 09.06.2015
Load crashdetect plugin and compile with -d3 flag (
https://github.com/Zeex/samp-plugin-...ith-debug-info) because I'm pretty sure a run time error 4 is what causes your problem and more specific, this function: GetVehicleName.
You can prevent it for now using this:
PHP код:
CMD:vmenu(playerid, params[])
{
new finale[150], id[3];
id[0] = PlayerInfo[playerid][IDVeicolo],
id[1] = PlayerInfo[playerid][IDVeicolo2],
id[2] = PlayerInfo[playerid][IDVeicolo3];
for (new i; i != sizeof (id); ++i)
{
if (!id[i] || !GetVehicleModel(id[i])) strcat(finale, "Slot libero\n", sizeof (finale));
else format(finale, sizeof(finale), "%s - (FC 0%d LV)\n", GetVehicleName(id[i]), id[i]);
}
ShowPlayerDialog(playerid, DIALOG_VMENU, DIALOG_STYLE_LIST, "Menщ veicolo", finale, "Seleziona", "Esci");
return 1;
}
but fixing the function is recommended so it won't happen in other places as well.
Re: ZCMD & STRCAT: Why this code don't work? -
DarkLouis - 09.06.2015
I tried without GetVehicleName and It work.. the problem was GetVehicleName.
Ah, Kostantinos.. thank you..