Problem with command
#1

I make vehicle system on my server (MySQL) and i have one problem with command.

Код:
COMMAND:v(playerid, params[])
{
	new str[100];
	format(str, sizeof(str), "SELECT `Name` FROM `Vehicles` WHERE `Owner` = '%s'", PlayerName(playerid));
	mysql_query(str);
	mysql_store_result();
	
	if(mysql_num_rows())
	{
		new vName = mysql_fetch_int();
		format(str, sizeof(str), "%s\n", vName);
		ShowPlayerDialog(playerid, 123, DIALOG_STYLE_LIST, "Vehicles", str, "OK", "Cancel");
		
	}
	mysql_free_result();
	return 1;
}
This command doesn't work. What's wrong?
Reply
#2

mysql_fetch_int retrieves an integer and you're using "%s" which is for strings.
Reply
#3

I understand. But how i download Vehicle Name from Vehicles (as a string) and assigned to ShowPlayerDialog?
Reply
#4

pawn Код:
// Global
new
    VehicleNames[ 212 ][ ] =
    {
        { "Landstalker" }, { "Bravura" }, { "Buffalo" }, { "Linerunner" }, { "Perrenial" }, { "Sentinel" }, { "Dumper" }, { "Firetruck" }, { "Trashmaster" }, { "Stretch" },
        { "Manana" }, { "Infernus" }, { "Voodoo" }, { "Pony" }, { "Mule" }, { "Cheetah" }, { "Ambulance" }, { "Leviathan" }, { "Moonbeam" }, { "Esperanto" }, { "Taxi" },
        { "Washington" }, { "Bobcat" }, { "Mr Whoopee" }, { "BF Injection" }, { "Hunter" }, { "Premier" }, { "Enforcer" }, { "Securicar" }, { "Banshee" }, { "Predator" }, { "Bus" },
        { "Rhino" }, { "Barracks" }, { "Hotknife" }, { "Trailer 1" }, { "Previon" }, { "Coach" }, { "Cabbie" }, { "Stallion" }, { "Rumpo" }, { "RC Bandit" }, { "Romero" }, { "Packer" },
        { "Monster" }, { "Admiral" }, { "Squalo" }, { "Seasparrow" }, { "Pizzaboy" }, { "Tram" }, { "Trailer 2" }, { "Turismo" }, { "Speeder" }, { "Reefer" }, { "Tropic" }, { "Flatbed" },
        { "Yankee" }, { "Caddy" }, { "Solair" }, { "Berkley's RC Van" }, { "Skimmer" }, { "PCJ-600" }, { "Faggio" }, { "Freeway" }, { "RC Baron" }, { "RC Raider" }, { "Glendale" }, { "Oceanic" },
        { "Sanchez" }, { "Sparrow" }, { "Patriot" }, { "Quad" }, { "Coastguard" }, { "Dinghy" }, { "Hermes" }, { "Sabre" }, { "Rustler" }, { "ZR-350" }, { "Walton" }, { "Regina" }, { "Comet" },
        { "BMX" }, { "Burrito" }, { "Camper" }, { "Marquis" }, { "Baggage" }, { "Dozer" }, { "Maverick" }, { "News Chopper" }, { "Rancher" }, { "FBI Rancher" }, { "Virgo" }, { "Greenwood" },
        { "Jetmax" }, { "Hotring" }, { "Sandking" }, { "Blista Compact" }, { "Police Maverick" }, { "Boxville" }, { "Benson" }, { "Mesa" }, { "RC Goblin" }, { "Hotring Racer A" },
        { "Hotring Racer B" }, { "Bloodring Banger" }, { "Rancher" }, { "Super GT" }, { "Elegant" }, { "Journey" }, { "Bike" }, { "Mountain Bike" }, { "Beagle" }, { "Cropdust" }, { "Stunt" },
        { "Tanker" }, { "Roadtrain" }, { "Nebula" }, { "Majestic" }, { "Buccaneer" }, { "Shamal" }, { "Hydra" }, { "FCR-900" }, { "NRG-500" }, { "HPV1000" }, { "Cement Truck" }, { "Tow Truck" },
        { "Fortune" }, { "Cadrona" }, { "FBI Truck" }, { "Willard" }, { "Forklift" }, { "Tractor" }, { "Combine" }, { "Feltzer" }, { "Remington" }, { "Slamvan" }, { "Blade" }, { "Freight" },
        { "Streak" }, { "Vortex" }, { "Vincent" }, { "Bullet" }, { "Clover" }, { "Sadler" }, { "Firetruck LA" }, { "Hustler" }, { "Intruder" }, { "Primo" }, { "Cargobob" }, { "Tampa" }, { "Sunrise" }, { "Merit" },
        { "Utility" }, { "Nevada" }, { "Yosemite" }, { "Windsor" }, { "Monster A" }, { "Monster B" }, { "Uranus" }, { "Jester" }, { "Sultan" }, { "Stratum" }, { "Elegy" }, { "Raindance" }, { "RC Tiger" },
        { "Flash" }, { "Tahoma" }, { "Savanna" }, { "Bandito" }, { "Freight Flat" }, { "Streak Carriage" }, { "Kart" }, { "Mower" }, { "Duneride" }, { "Sweeper" }, { "Broadway" }, { "Tornado" }, { "AT-400" },
        { "DFT-30" }, { "Huntley" }, { "Stafford" }, { "BF-400" }, { "Newsvan" }, { "Tug" }, { "Trailer 3" }, { "Emperor" }, { "Wayfarer" }, { "Euros" }, { "Hotdog" }, { "Club" }, { "Freight Carriage" },
        { "Trailer 3" }, { "Andromada" }, { "Dodo" }, { "RC Cam" }, { "Launch" }, { "Police Car (LSPD)" }, { "Police Car (SFPD)" }, { "Police Car (LVPD)" }, { "Police Ranger" }, { "Picador" }, { "S.W.A.T. Van" },
        { "Alpha" }, { "Phoenix" }, { "Glendale" }, { "Sadler" }, { "Luggage Trailer A" }, { "Luggage Trailer B" }, { "Stair Trailer" }, { "Boxville" }, { "Farm Plow" }, { "Utility Trailer" }
    }
;

stock GetVehicleName(vehicleid)
{
    format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return String;
}

// at the code;
format(str, sizeof(str), "%s\n", GetVehicleName(vName));
Reply
#5

Are you trying to do something like:
pawn Код:
CMD:v(playerid, params[])
{
    new
        iQuery[128]
    ;
    format(iQuery, sizeof(iQuery), "SELECT `Name` FROM `Vehicles` WHERE `Owner` = '%s'", PlayerName(playerid));
    mysql_query(iQuery);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        while(mysql_retrieve_row())
        {
            new
                iVeh[12],
                iStr[128]
            ;
            mysql_fetch_field_row(iVeh, "Name");
            format(iStr, sizeof(iStr), "%s%s\n", iStr, iVeh);
        }
        ShowPlayerDialog(playerid, 123, DIALOG_STYLE_LIST, "Vehicles", iStr, "OK", "Cancel");
    }
    mysql_free_result();
    return 1;
}
?
Reply
#6

Thanks, but this didn't working :/. Displays a blank dialog.
Reply
#7

I'm pretty sure this code works fine. Is there any row in your database ?
Reply
#8

Fail, this works! Thanks!
Reply
#9

How to show vehicle name on next dialog? I should create new arrays and save the data to it?
Reply
#10

how to check which vehicle player chooses?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)