ZCMD & STRCAT: Why this code don't work?
#1

Hi all, I did:

PHP код:
CMD:vmenu(playeridparams[])
{
    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 == 0veicolo_1 "Slot libero\n";
     else if(
id != 0)
     {
         
format(veicolo_1sizeof(veicolo_1), "%s - (FC 0%d LV)\n"GetVehicleNameid ), id);
          
strcat(finaleveicolo_1sizeof(finale));
    }
    
    if(
id2 == 0veicolo_2 "Slot libero\n";
    else if(
id2 != 0)
    {
         
format(veicolo_2sizeof(veicolo_2), "%s - (FC 0%d LV)\n"GetVehicleNameid2 ), id2);
         
strcat(finaleveicolo_2sizeof(finale));
    }
    
    if(
id3 == 0veicolo_3 "Slot libero\n";
    else if(
id3 != 0)
    {
        
format(veicolo_3sizeof(veicolo_3), "%s - (FC 0%d LV)\n"GetVehicleNameid3 ), id3);
        
strcat(finaleveicolo_3sizeof(finale));
    }
    
    
ShowPlayerDialog(playeridDIALOG_VMENUDIALOG_STYLE_LIST"Menщ veicolo"finale"Seleziona""Esci");
    return 
1;

In the game when I type /vmenu, it show me: ERROR UNKOWN COMMAND.

Why?
Reply
#2

why dont u use sscanf?

edit: oh nevermind. wait
Reply
#3

How? I have to show 3 vehicles in that dialog.
Reply
#4

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(playeridparams[])
{
    new 
finale[150], id[3];
    
    
id[0] = PlayerInfo[playerid][IDVeicolo],
    
id[1] = PlayerInfo[playerid][IDVeicolo2],
    
id[2] = PlayerInfo[playerid][IDVeicolo3];
    
    for (new 
i!= sizeof (id); ++i)
    {
        if (!
id[i] || !GetVehicleModel(id[i])) strcat(finale"Slot libero\n"sizeof (finale));
        else 
format(finalesizeof(finale), "%s - (FC 0%d LV)\n"GetVehicleName(id[i]), id[i]);
    }
    
    
ShowPlayerDialog(playeridDIALOG_VMENUDIALOG_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.
Reply
#5

I tried without GetVehicleName and It work.. the problem was GetVehicleName.

Ah, Kostantinos.. thank you..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)