SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/05/2019, 09:59 PM   #1
OuDayas
Big Clucker
 
Join Date: Jan 2019
Posts: 86
Reputation: 0
Default vehicle menu half work

Hi guy, Im making a vehicle menu for players for taking some info about their vehicles, like position, fuel, open/close the bonnet/boot etc. Im using MySQL.
I want to set that code for open/close bonnet and boot, lock/unlock doors, interact with the vehicle inventory (weapon slot, drugs slot, armour slot).
For now the code should show me my vehicles (max 5 per player), but it show me only 1 vehicle, why?
Can anyone help me with that?
I wrote that, and i getting mad for understand what is the problem
pawn Code:
enum PlayerMenuinfo
{
    SQLID, ID,
    Model,
    VehicleName[128],
    Float:PosX,
    Float:PosY,
    Float:PosZ,
    Locked
};
new PlayerVMenu[MAX_PLAYERS][PlayerMenuinfo];

CMD:vmenu(playerid, params[])
{
    new QueryVeh[256], string[256], string2[256];
    mysql_format(g_SQL, QueryVeh, sizeof(QueryVeh), "SELECT * FROM `servervehicles` WHERE `Owner` = '%e'", Player[playerid][Name]);
    new Cache:result = mysql_query(g_SQL, QueryVeh);
    if(!cache_num_rows())
    {
        cache_delete(result);
        SendClientMessage(playerid, 0xFF0000FF,"[ERRORE]: Non hai ancora nessun veicolo");
        return 1;
    }
    for(new i,j = cache_num_rows(); i< j; i++)
    {
        cache_get_value_int(i,"SQLID", PlayerVMenu[i][SQLID]); // modello
        cache_get_value_int(i,"Model", PlayerVMenu[i][Model]); // modello
        cache_get_value_float(i,"PosX", PlayerVMenu[i][PosX]); // posizione x
        cache_get_value_float(i,"PosY", PlayerVMenu[i][PosY]); // posizione y
        cache_get_value_float(i,"PosZ", PlayerVMenu[i][PosZ]); // posizione z

        format(PlayerVMenu[i][VehicleName], 128, "%s", VehicleModelName(PlayerVMenu[i][Model]) );
        format(string, sizeof(string), "%d\t%s\n", i, PlayerVMenu[i][VehicleName]);
    }
    format(string2, sizeof(string2), "Sel\tAuto\n%s", string);
   
    Dialog_Show(playerid, PLAYER_VMENU_HOME, DIALOG_STYLE_TABLIST_HEADERS, "Menu veicoli", string2, "Seleziona", "Annulla");
//  cache_delete(result);
    return 1;
}
Dialog:PLAYER_VMENU_HOME(playerid, response, listitem, inputtext[])
{
    if(response)
    {
        PlayerVMenu[playerid][ID] = PlayerVMenu[listitem][SQLID];
        new str[256];
        format(str, sizeof(str),
        "Sel\tInfo\n\
        1.\tApri/chiudi cofano\n\
        2.\tApri/chiudi veicolo\n\
        3.\tMostra posizione del veicolo"
);
        Dialog_Show(playerid, PLAYER_VMENU_SELECTED, DIALOG_STYLE_TABLIST_HEADERS, "Menu veicoli", str, "Seleziona", "Annulla");
        return 1;
    }
    else
    {
        return 1;
    }
}
Dialog:PLAYER_VMENU_SELECTED(playerid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(listitem)
        {
            case 2:
            {
                if (GPS_Marker[playerid] != 0)
                {
                    DestroyDynamicMapIcon(GPS_Marker[playerid]);
                }
                GPS_Marker[playerid] = CreateDynamicMapIcon(PlayerVMenu[listitem][PosX], PlayerVMenu[listitem][PosY], PlayerVMenu[listitem][PosZ], 41, 0, -1, -1, playerid, 100000.0);
                Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, GPS_Marker[playerid], E_STREAMER_STYLE, MAPICON_GLOBAL);
                Streamer_Update(playerid);
                new string[256];
                format(string, sizeof(string), "{FFFFFF}[GPS] La posizione del tuo veicolo (%s) ora visibile sul GPS", PlayerVMenu[listitem][VehicleName]);
                SendClientMessage(playerid, -1, string);
                return 1;
            }
        }
    }
    return 1;
}
OuDayas is offline   Reply With Quote
Old 30/05/2019, 10:21 PM   #2
MisterTickle
Huge Clucker
 
MisterTickle's Avatar
 
Join Date: Jul 2007
Posts: 364
Reputation: 79
Default Re: vehicle menu half work

You keep reformatting the string over and over.

Quote:
format(string, sizeof(string), "%d\t%s\n%s", i, PlayerVMenu[i][VehicleName],string);
This should work.
__________________
MisterTickle is offline   Reply With Quote
Old 30/05/2019, 10:31 PM   #3
jasperschellekens
Gangsta
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Gehenna
Posts: 814
Reputation: 79
Default Re: vehicle menu half work

Use strcat
__________________
Coming soon (5-21-2020):

Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Official Live Beta Release Date: 21th of May, 2020
Discord
jasperschellekens is online now   Reply With Quote
Old 31/05/2019, 12:05 AM   #4
OuDayas
Big Clucker
 
Join Date: Jan 2019
Posts: 86
Reputation: 0
Default Re: vehicle menu half work

Quote:
Originally Posted by MisterTickle View Post
You keep reformatting the string over and over.

This should work.
Oh that work, but on firt dialog if I want select a car, for example in the db there is 2 vehicles with that datas:
SQLID: 1 | Owner: OuDayas | Model: 562
SQLID: 2 | Owner: OuDayas | Model: 410
If i select the first vehicle (the Elegy) and the second dialog for get the position of vehicle the script will select the second vehicle (the manana) and if I select the second vehicle the script take the other
OuDayas is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selling vehicle at half price SalmaN97 Scripting Help 3 04/01/2015 06:06 PM
[FilterScript] [FS]Weapon Menu + Player Menu + Vehicle Menu! [Good For Stunt Server] AlexHitman Filterscripts 4 27/07/2014 08:34 PM
Vehicle menu doesn't work Majava Scripting Help 3 10/10/2012 12:27 PM
Wiered Problem, Half of a command don't work. silvan Help Archive 11 30/01/2010 11:19 AM
Vehicle menu doesn't work. biltong Help Archive 4 25/01/2010 04:31 PM


All times are GMT. The time now is 12:51 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.