PDA

View Full Version : car id mysql +rep


iBots
22/04/2015, 08:27 PM
i have made a system for cars,and this system saves them by the vehicle id in game to the database id,but when creating a new car,how can i know which id from the database is not used?

MRSAS
22/04/2015, 08:58 PM
This Is Your Help Code:

#define FILTERSCRIPT

#include <a_samp>
#include <mselection>
#include <mysql>
#include <YSI\y_iterate>
#include <zcmd>

#undef mS_NEXT_TEXT
#undef mS_PREV_TEXT
#undef mS_CANCEL_TEXT

#define SQL_HOST "Type here your hostname"
#define SQL_USR "Type here your username"
#define SQL_PSWRD "Type here your password"
#define SQL_DB "Type here your database"

#define SQL_TABLE "elements"
#define SQL_TYPE "type"
#define SQL_MODEL "model"
#define SQL_CARS "vehicle"
#define SQL_SKINS "skin"

#define mS_NEXT_TEXT "Next"
#define mS_PREV_TEXT "Previous"
#define mS_CANCEL_TEXT "Cancel"
#define UNABLE_TO_CONNECT "There is issue in trying to connect with database!\nServer must be turn off!"
#define TABLE_WAS_ADDED "Table `"#SQL_TABLE"` was added!"
#define VEHICLE_SELECTION_CANCEL "Vehicle selection has been canceled by you!"
#define SKIN_SELECTION_CANCEL "Skin selection has been canceled by you!"
#define VEHICLE_SELECTED "Vehicle was chosen!"
#define SKIN_SELECTED "Skin was chosen!"
#define SELECT_SKIN "Select skin"
#define VEHICLE_SELECT_METHOD "Select the method of vehicle selection"
#define SELECT_BY_CLICK "Selection by clicking on the vehicle image\n"
#define SELECT_BY_DIALOG "Selection by clicking and select vehicle from dialog list\n"
#define SELECT_BY_INPUT "Selection by write vehicle name in dialog input menu"
#define SELECT "Select"
#define CANCEL "Cancel"
#define CLOSE "Close"
#define EMPTY ""
#define BAD_VEHICLE_NAME "Bad vehicle name!"
#define VEHICLE_TYPE_SELECT "Select category of vehicle"
#define CAR_LIST "Airplanes\nHelicopters\nMotorcycles\nBicycles\nCon vertibles\nIndustrial\nLowriders\nOff-Road\nPublic\nSaloon\nSport\nWagon\nBoats\nUnique"
#define SELECT_VEHICLE "Select vehicle"
#define BACK "Back"
#define ENTERING_NAME "Entering the name of the vehicle"
#define ENTER_NAME_IN_FIELD_BELOW "Enter the name of the vehicle in the box below"
#define OKAY "Okay"
#define COMMAND_IS_ONLY_FOR_ADMIN "This command is available only for admin!"
#define CARS_CREATED_BY_V "Cars made by using the /v command has been removed."
#define SKIN_COMMAND CMD:skin(playerid)
#define VEHICLE_COMMAND CMD:v(playerid, params[])
#define RESPAWN_COMMAND CMD:respawn(playerid)

// #define ONLY_FOR_ADMIN

#if !defined mysql_format_ex
#define mysql_format_ex(%1,%2) format(QueryString, sizeof(QueryString), %1, %2), mysql_query(QueryString)
#endif

#if !defined function
#define function%0(%1) forward%0(%1); public%0(%1)
#endif

new bool:Commanded[MAX_VEHICLES];
new MySQL:hMYSQL;
new QueryString[500];
new vehiclelist = mS_INVALID_LISTID;
new skinlist = mS_INVALID_LISTID;
new gVehicleNames[212][] =
{
"Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "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", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
"Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy",
"Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Harley", "RC Baron", "RC Raider", "Glendale", "Oceanic",
"Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR3 50", "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", "Hotring Racer", "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", "Traktor",
"Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover", "Sadler",
"Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor",
"Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna",
"Bandito", "Freight", "Trailer", "Kart", "Mower", "Duneride", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley",
"Stafford", "BF-400", "Newsvan", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Trailer", "Trailer",
"Andromeda", "Dodo", "RC Cam", "Launch", "Radiowoz", "Radiowoz", "Radiowoz", "Radiowoz", "Picador", "S.W.A.T. Van",
"Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer", "Luggage Trailer", "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
};

enum
{
DIALOG_VEHICLES_CATEGORY = 0,
DIALOG_VEHICLES_PLANES,
DIALOG_VEHICLES_HELICOPTERS,
DIALOG_VEHICLES_MOTORCYCLES,
DIALOG_VEHICLES_BIKES,
DIALOG_VEHICLES_CABRIOS,
DIALOG_VEHICLES_INDUSTRIALS,
DIALOG_VEHICLES_LOWRIDERS,
DIALOG_VEHICLES_OFF_ROAD,
DIALOG_VEHICLES_PUBLIC,
DIALOG_VEHICLES_SALOON,
DIALOG_VEHICLES_SPORT,
DIALOG_VEHICLES_WAGONS,
DIALOG_VEHICLES_BOATS,
DIALOG_VEHICLES_UNIQUE,
DIALOG_VEHICLES_SELECTOR,
DIALOG_VEHICLES_INPUT,
};

// Stocki:
function Respawning_Vehicles(vehicleid) // by Maktab
{
RespawnUnusedVehicles();
SendClientMessage(vehicleid, -1, #CARS_CREATED_BY_V);
return 1;
}

stock RespawnUnusedVehicles()
{
new UsedVeh[MAX_VEHICLES] = {false, ...};

foreach(Player, playerid)
UsedVeh[GetPlayerVehicleID(playerid)] = true;

for(new vehicleid = 1; vehicleid != MAX_VEHICLES; vehicleid++)
{
if(UsedVeh[vehicleid]) continue;
if(Commanded[vehicleid]) return DestroyVehicle(vehicleid), Commanded[vehicleid] = false;
SetVehicleToRespawn(vehicleid);
}
return 1;
}

stock CreatePlayerVehicle(playerid, modelid)
{
new vehicle, Float:X, Float:Y, Float:Z, Float:angle;
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
vehicle = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicle, X, Y, Z);
GetVehicleZAngle(vehicle, angle);
DestroyVehicle(vehicle);
}
else
{
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, angle);
}
vehicle = AddStaticVehicle(modelid, X, Y, Z + 1, angle, -1, -1);
LinkVehicleToInterior(vehicle, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(vehicle, GetPlayerVirtualWorld(playerid));
SetVehicleNumberPlate(vehicle, PlayerName(playerid));
PutPlayerInVehicle(playerid, vehicle, 0);
Commanded[vehicle] = true;
return 1;
}

stock GetVehicleModelIdByName(vehiclename[])
{
for(new i = 0; i < 211; i++)
if(strfind(gVehicleNames[i], vehiclename, true) != -1) return i + 400;
return -1;
}

stock mysql_fetch_field_int(field[])
{
new tmp_str[30];
mysql_fetch_field(field, tmp_str);
return strval(tmp_str);
}

stock Float: mysql_fetch_field_float(field[])
{
new tmp_str[60];
mysql_fetch_field(field, tmp_str);
return floatstr(tmp_str);
}

stock LoadModelSelectionMenuEx(base_name[], list_type[])
{
mysql_format_ex("SELECT * FROM %s WHERE "#SQL_TYPE" = '%s'", base_name, list_type);
mysql_store_result();
if(!mysql_num_rows())
{
printf("-mSelection- WARNING: Failed to load models with type %s", list_type);
return mS_INVALID_LISTID;
}

if(gListAmount >= mS_TOTAL_LISTS)
{
printf("-mSelection- WARNING: Reached maximum amount of lists, increase \"mS_TOTAL_LISTS\"");
return mS_INVALID_LISTID;
}
new tmp_ItemAmount = gItemAmount; // copy value if loading fails

for(new i; i < mysql_num_rows(); i++)
{
mysql_data_seek(i);
mysql_fetch_row_data();
if(tmp_ItemAmount >= mS_TOTAL_ITEMS)
{
printf("-mSelection- WARNING: Reached maximum amount of items, increase \"mS_TOTAL_ITEMS\"");
break;
}
new mID = mysql_fetch_field_int(SQL_MODEL);
if(0 <= mID < 20000)
{
gItemList[tmp_ItemAmount][mS_ITEM_MODEL] = mID;
new Float:mRotation[3], Float:mZoom = 1.0;
new bool:useRotation = false;

if(useRotation)
{
new bool:foundRotZoom = false;
for(new val = 0; val < gRotZoomAmount; val++)
{
if(gRotZoom[val][0] == mRotation[0] && gRotZoom[val][1] == mRotation[1] && gRotZoom[val][2] == mRotation[2] && gRotZoom[val][3] == mZoom)
{
foundRotZoom = true;
gItemList[tmp_ItemAmount][mS_ITEM_ROT_ZOOM_ID] = val;
break;
}
}
if(gRotZoomAmount < mS_TOTAL_ROT_ZOOM)
{
if(!foundRotZoom)
{
gRotZoom[gRotZoomAmount][0] = mRotation[0];
gRotZoom[gRotZoomAmount][1] = mRotation[1];
gRotZoom[gRotZoomAmount][2] = mRotation[2];
gRotZoom[gRotZoomAmount][3] = mZoom;
gItemList[tmp_ItemAmount][mS_ITEM_ROT_ZOOM_ID] = gRotZoomAmount;
gRotZoomAmount++;
}
}
else print("-mSelection- WARNING: Not able to save rotation/zoom information. Reached maximum rotation/zoom information count. Increase '#define mS_TOTAL_ROT_ZOOM' to fix the issue");
}
else gItemList[tmp_ItemAmount][mS_ITEM_ROT_ZOOM_ID] = -1;
tmp_ItemAmount++;
}
}
if(tmp_ItemAmount > gItemAmount) // any models loaded ?
{
gLists[gListAmount][mS_LIST_START] = gItemAmount;
gItemAmount = tmp_ItemAmount; // copy back
gLists[gListAmount][mS_LIST_END] = (gItemAmount-1);
gListAmount++;
return (gListAmount-1);
}
return mS_INVALID_LISTID;
}

stock str_del_free_space(string[], _char = ' ')
{
new len = strlen (string);
if(len)
{
new begin = -1, end = len;
while(string[++begin] == _char){}
if(string[begin] == EOS)
{
string [0] = 0;
return 1;
}
while(string[--end] == _char){}
strmid(string, string, begin, end+1, len+1);
}
return 1;
}

stock PlayerName(p)
{
new N[MAX_PLAYER_NAME];
GetPlayerName(p, N, sizeof(N));
return N;
}

public OnFilterScriptInit()
{
hMYSQL = mysql_init(1);
new mHandle = mysql_connect(SQL_HOST, SQL_USR, SQL_PSWRD, SQL_DB, hMYSQL, 1);
if(!mHandle) return printf(#UNABLE_TO_CONNECT), SendRconCommand("exit");

new string_[240];
strcat(string_, "CREATE TABLE IF NOT EXISTS "#SQL_TABLE"");
strcat(string_, "(");
strcat(string_, "`"#SQL_TYPE"` varchar(60) DEFAULT NULL,");
strcat(string_, "`"#SQL_MODEL"` int(11) NOT NULL");
strcat(string_, ") ENGINE = MyISAM DEFAULT CHARSET = latin1;");
mysql_query(string_), printf(#TABLE_WAS_ADDED);

skinlist = LoadModelSelectionMenuEx(#SQL_TABLE, #SQL_SKINS);
vehiclelist = LoadModelSelectionMenuEx(#SQL_TABLE, #SQL_CARS);

SetTimer("Respawning_Vehicles", 15 * 60 * 1000, true);
return 1;
}

public OnPlayerModelSelection(playerid, response, listid, modelid)
{
if(listid == vehiclelist)
{
if(!response) return SendClientMessage(playerid, 0xFF0000FF, #VEHICLE_SELECTION_CANCEL);
SendClientMessage(playerid, 0xFF0000FF, #VEHICLE_SELECTED);
CreatePlayerVehicle(playerid, modelid);
}
else if(listid == skinlist)
{
if(!response) return SendClientMessage(playerid, 0xFF0000FF, #SKIN_SELECTION_CANCEL);
SendClientMessage(playerid, 0xFF0000FF, SKIN_SELECTED);
SetPlayerSkin(playerid, modelid);
}
return 1;
}

SKIN_COMMAND
{
ShowModelSelectionMenu(playerid, skinlist, #SELECT_SKIN);
return 1;
}

VEHICLE_COMMAND
{
str_del_free_space(params);
if(isnull(params)) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_SELECTOR, DIALOG_STYLE_LIST, #VEHICLE_SELECT_METHOD, #SELECT_BY_CLICK #SELECT_BY_DIALOG #SELECT_BY_INPUT, #SELECT, #EMPTY);
if(GetVehicleModelIdByName(params) != -1) CreatePlayerVehicle(playerid, GetVehicleModelIdByName(params));
else return SendClientMessage(playerid, -1, #BAD_VEHICLE_NAME);
return 1;
}

RESPAWN_COMMAND
{
#if defined ONLY_FOR_ADMIN
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, #COMMAND_IS_ONLY_FOR_ADMIN);
#endif
SendClientMessage(playerid, -1, #CARS_CREATED_BY_V);
RespawnUnusedVehicles();
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_VEHICLES_PLANES:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 460);
case 1: CreatePlayerVehicle(playerid, 476);
case 2: CreatePlayerVehicle(playerid, 511);
case 3: CreatePlayerVehicle(playerid, 512);
case 4: CreatePlayerVehicle(playerid, 513);
case 5: CreatePlayerVehicle(playerid, 519);
case 6: CreatePlayerVehicle(playerid, 520);
case 7: CreatePlayerVehicle(playerid, 553);
case 8: CreatePlayerVehicle(playerid, 577);
case 9: CreatePlayerVehicle(playerid, 592);
case 10: CreatePlayerVehicle(playerid, 593);
}
}
case DIALOG_VEHICLES_HELICOPTERS:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 417);
case 1: CreatePlayerVehicle(playerid, 425);
case 2: CreatePlayerVehicle(playerid, 469);
case 3: CreatePlayerVehicle(playerid, 447);
case 4: CreatePlayerVehicle(playerid, 487);
case 5: CreatePlayerVehicle(playerid, 488);
case 6: CreatePlayerVehicle(playerid, 497);
case 7: CreatePlayerVehicle(playerid, 548);
case 8: CreatePlayerVehicle(playerid, 563);
}
}
case DIALOG_VEHICLES_MOTORCYCLES:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 448);
case 1: CreatePlayerVehicle(playerid, 461);
case 2: CreatePlayerVehicle(playerid, 462);
case 3: CreatePlayerVehicle(playerid, 463);
case 4: CreatePlayerVehicle(playerid, 468);
case 5: CreatePlayerVehicle(playerid, 471);
case 6: CreatePlayerVehicle(playerid, 521);
case 7: CreatePlayerVehicle(playerid, 522);
case 8: CreatePlayerVehicle(playerid, 523);
case 9: CreatePlayerVehicle(playerid, 581);
case 10: CreatePlayerVehicle(playerid, 586);
}
}
case DIALOG_VEHICLES_BIKES:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 481);
case 1: CreatePlayerVehicle(playerid, 509);
case 2: CreatePlayerVehicle(playerid, 510);
}
}
case DIALOG_VEHICLES_CABRIOS:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 439);
case 1: CreatePlayerVehicle(playerid, 480);
case 2: CreatePlayerVehicle(playerid, 533);
case 3: CreatePlayerVehicle(playerid, 555);
}
}
case DIALOG_VEHICLES_INDUSTRIALS:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 499);
case 1: CreatePlayerVehicle(playerid, 422);
case 2: CreatePlayerVehicle(playerid, 482);
case 3: CreatePlayerVehicle(playerid, 498);
case 4: CreatePlayerVehicle(playerid, 609);
case 5: CreatePlayerVehicle(playerid, 524);
case 6: CreatePlayerVehicle(playerid, 578);
case 7: CreatePlayerVehicle(playerid, 455);
case 8: CreatePlayerVehicle(playerid, 403);
case 9: CreatePlayerVehicle(playerid, 414);
case 10: CreatePlayerVehicle(playerid, 582);
case 11: CreatePlayerVehicle(playerid, 443);
case 12: CreatePlayerVehicle(playerid, 514);
case 13: CreatePlayerVehicle(playerid, 600);
case 14: CreatePlayerVehicle(playerid, 413);
case 15: CreatePlayerVehicle(playerid, 515);
case 16: CreatePlayerVehicle(playerid, 440);
case 17: CreatePlayerVehicle(playerid, 543);
case 18: CreatePlayerVehicle(playerid, 605);
case 19: CreatePlayerVehicle(playerid, 459);
case 20: CreatePlayerVehicle(playerid, 531);
case 21: CreatePlayerVehicle(playerid, 408);
case 22: CreatePlayerVehicle(playerid, 552);
case 23: CreatePlayerVehicle(playerid, 478);
case 24: CreatePlayerVehicle(playerid, 456);
case 25: CreatePlayerVehicle(playerid, 554);
}
}
case DIALOG_VEHICLES_LOWRIDERS:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 412);
case 1: CreatePlayerVehicle(playerid, 534);
case 2: CreatePlayerVehicle(playerid, 535);
case 3: CreatePlayerVehicle(playerid, 536);
case 4: CreatePlayerVehicle(playerid, 566);
case 5: CreatePlayerVehicle(playerid, 567);
case 6: CreatePlayerVehicle(playerid, 575);
case 7: CreatePlayerVehicle(playerid, 576);
}
}
case DIALOG_VEHICLES_OFF_ROAD:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 400);
case 1: CreatePlayerVehicle(playerid, 424);
case 2: CreatePlayerVehicle(playerid, 444);
case 3: CreatePlayerVehicle(playerid, 470);
case 4: CreatePlayerVehicle(playerid, 489);
case 5: CreatePlayerVehicle(playerid, 495);
case 6: CreatePlayerVehicle(playerid, 500);
case 7: CreatePlayerVehicle(playerid, 505);
case 8: CreatePlayerVehicle(playerid, 556);
case 9: CreatePlayerVehicle(playerid, 557);
case 10: CreatePlayerVehicle(playerid, 568);
case 11: CreatePlayerVehicle(playerid, 573);
case 12: CreatePlayerVehicle(playerid, 579);
}
}
case DIALOG_VEHICLES_PUBLIC:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 407);
case 1: CreatePlayerVehicle(playerid, 416);
case 2: CreatePlayerVehicle(playerid, 420);
case 3: CreatePlayerVehicle(playerid, 427);
case 4: CreatePlayerVehicle(playerid, 431);
case 5: CreatePlayerVehicle(playerid, 432);
case 6: CreatePlayerVehicle(playerid, 433);
case 7: CreatePlayerVehicle(playerid, 437);
case 8: CreatePlayerVehicle(playerid, 438);
case 9: CreatePlayerVehicle(playerid, 490);
case 10: CreatePlayerVehicle(playerid, 528);
case 11: CreatePlayerVehicle(playerid, 544);
case 12: CreatePlayerVehicle(playerid, 596);
case 13: CreatePlayerVehicle(playerid, 597);
case 14: CreatePlayerVehicle(playerid, 598);
case 15: CreatePlayerVehicle(playerid, 599);
case 16: CreatePlayerVehicle(playerid, 601);
}
}
case DIALOG_VEHICLES_SALOON:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 445);
case 1: CreatePlayerVehicle(playerid, 504);
case 2: CreatePlayerVehicle(playerid, 401);
case 3: CreatePlayerVehicle(playerid, 518);
case 4: CreatePlayerVehicle(playerid, 527);
case 5: CreatePlayerVehicle(playerid, 542);
case 6: CreatePlayerVehicle(playerid, 507);
case 7: CreatePlayerVehicle(playerid, 562);
case 8: CreatePlayerVehicle(playerid, 585);
case 9: CreatePlayerVehicle(playerid, 419);
case 10: CreatePlayerVehicle(playerid, 526);
case 11: CreatePlayerVehicle(playerid, 604);
case 12: CreatePlayerVehicle(playerid, 466);
case 13: CreatePlayerVehicle(playerid, 492);
case 14: CreatePlayerVehicle(playerid, 474);
case 15: CreatePlayerVehicle(playerid, 546);
case 16: CreatePlayerVehicle(playerid, 517);
case 17: CreatePlayerVehicle(playerid, 410);
case 18: CreatePlayerVehicle(playerid, 551);
case 19: CreatePlayerVehicle(playerid, 516);
case 20: CreatePlayerVehicle(playerid, 467);
case 21: CreatePlayerVehicle(playerid, 426);
case 22: CreatePlayerVehicle(playerid, 436);
case 23: CreatePlayerVehicle(playerid, 547);
case 24: CreatePlayerVehicle(playerid, 405);
case 25: CreatePlayerVehicle(playerid, 580);
case 26: CreatePlayerVehicle(playerid, 560);
case 27: CreatePlayerVehicle(playerid, 550);
case 28: CreatePlayerVehicle(playerid, 549);
case 29: CreatePlayerVehicle(playerid, 540);
case 30: CreatePlayerVehicle(playerid, 491);
case 31: CreatePlayerVehicle(playerid, 529);
case 32: CreatePlayerVehicle(playerid, 421);
}
}
case DIALOG_VEHICLES_SPORT:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 402);
case 1: CreatePlayerVehicle(playerid, 411);
case 2: CreatePlayerVehicle(playerid, 415);
case 3: CreatePlayerVehicle(playerid, 429);
case 4: CreatePlayerVehicle(playerid, 451);
case 5: CreatePlayerVehicle(playerid, 475);
case 6: CreatePlayerVehicle(playerid, 477);
case 7: CreatePlayerVehicle(playerid, 494);
case 8: CreatePlayerVehicle(playerid, 496);
case 9: CreatePlayerVehicle(playerid, 502);
case 10: CreatePlayerVehicle(playerid, 503);
case 11: CreatePlayerVehicle(playerid, 506);
case 12: CreatePlayerVehicle(playerid, 541);
case 13: CreatePlayerVehicle(playerid, 558);
case 14: CreatePlayerVehicle(playerid, 559);
case 15: CreatePlayerVehicle(playerid, 565);
case 16: CreatePlayerVehicle(playerid, 587);
case 17: CreatePlayerVehicle(playerid, 589);
case 18: CreatePlayerVehicle(playerid, 602);
case 19: CreatePlayerVehicle(playerid, 603);
}
}
case DIALOG_VEHICLES_WAGONS:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 404);
case 1: CreatePlayerVehicle(playerid, 418);
case 2: CreatePlayerVehicle(playerid, 458);
case 3: CreatePlayerVehicle(playerid, 479);
case 4: CreatePlayerVehicle(playerid, 561);
}
}
case DIALOG_VEHICLES_BOATS:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 430);
case 1: CreatePlayerVehicle(playerid, 446);
case 2: CreatePlayerVehicle(playerid, 452);
case 3: CreatePlayerVehicle(playerid, 453);
case 4: CreatePlayerVehicle(playerid, 454);
case 5: CreatePlayerVehicle(playerid, 472);
case 6: CreatePlayerVehicle(playerid, 473);
case 7: CreatePlayerVehicle(playerid, 484);
case 8: CreatePlayerVehicle(playerid, 493);
case 9: CreatePlayerVehicle(playerid, 595);
}
}
case DIALOG_VEHICLES_UNIQUE:
{
if(!response) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
switch(listitem)
{
case 0: CreatePlayerVehicle(playerid, 485);
case 1: CreatePlayerVehicle(playerid, 457);
case 2: CreatePlayerVehicle(playerid, 483);
case 3: CreatePlayerVehicle(playerid, 508);
case 4: CreatePlayerVehicle(playerid, 532);
case 5: CreatePlayerVehicle(playerid, 486);
case 6: CreatePlayerVehicle(playerid, 406);
case 7: CreatePlayerVehicle(playerid, 530);
case 8: CreatePlayerVehicle(playerid, 434);
case 9: CreatePlayerVehicle(playerid, 545);
case 10: CreatePlayerVehicle(playerid, 588);
case 11: CreatePlayerVehicle(playerid, 571);
case 12: CreatePlayerVehicle(playerid, 572);
case 13: CreatePlayerVehicle(playerid, 423);
case 14: CreatePlayerVehicle(playerid, 442);
case 15: CreatePlayerVehicle(playerid, 428);
case 16: CreatePlayerVehicle(playerid, 409);
case 17: CreatePlayerVehicle(playerid, 574);
case 18: CreatePlayerVehicle(playerid, 525);
case 19: CreatePlayerVehicle(playerid, 583);
case 20: CreatePlayerVehicle(playerid, 539);
}
}
case DIALOG_VEHICLES_CATEGORY:
{
if(!response) return 0;
switch(listitem)
{
case 0: ShowPlayerDialog(playerid, DIALOG_VEHICLES_PLANES, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Skimmer\nRustler\nBeagle\nCropduster\nStuntplane\n Shamal\nHydra\nNevada\nAT400\nAndromada\nDodo", #SELECT, #BACK);
case 1: ShowPlayerDialog(playerid, DIALOG_VEHICLES_HELICOPTERS, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Leviathan\nHunter\nSparrow\nSeasparrow\nMaverick\n SAN News Maverick\nPolice Maverick\nCargobob\nRaindance", #SELECT, #BACK);
case 2: ShowPlayerDialog(playerid, DIALOG_VEHICLES_MOTORCYCLES, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Pizzaboy\nPCJ-600\nFaggio\nFreeway\nSanchez\nQuad\nFCR-900\nNRG-500\nHPV1000\nBF-400\nWayfarer", #SELECT, #BACK);
case 3: ShowPlayerDialog(playerid, DIALOG_VEHICLES_BIKES, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "BMX\nBike\nMountain Bike", #SELECT, #BACK);
case 4: ShowPlayerDialog(playerid, DIALOG_VEHICLES_CABRIOS, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Stallion\nComet\nFeltzer", #SELECT, #BACK);
case 5: ShowPlayerDialog(playerid, DIALOG_VEHICLES_INDUSTRIALS, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Benson\nBobcat\nBurrito\nBoxville\nBoxburg\nCement Truck\nDFT-30\nFlatbed\nLinerunner\nMule\nNewsvan\nPacker\nTa nker\nPicador\nPony\nRoadtrain\nRumpo\nSadler\nSad ler Shit\nTopfun\nTractor\nTrashmaster\nUtility Van\nWalton\nYankee\nYosemite", #SELECT, #BACK);
case 6: ShowPlayerDialog(playerid, DIALOG_VEHICLES_LOWRIDERS, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Voodoo\nRemington\nSlamvan\nBlade\nTahoma\nSawanna \nBroadway", #SELECT, #BACK);
case 7: ShowPlayerDialog(playerid, DIALOG_VEHICLES_OFF_ROAD, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Landstalker\nBF Injection\nMonster A\nPatriot\nRancher A\nSandking\nMesa\nRancher B\nMonster B\nMonster C\nBandito\nDune\nHuntley", #SELECT, #BACK);
case 8: ShowPlayerDialog(playerid, DIALOG_VEHICLES_PUBLIC, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Firetruck\nAmbulance\nTaxi\nEnforcer\nBus\nRhino\n Barracks\nCoach\nCabbie\nFBI Rancher\nFBI Truck\nFiretruck LA\nPolice Car (LSPD)\nPolice Car (SFPD)\nPolice Car (LVPD)\nPolice Ranger\nS.W.A.T", #SELECT, #BACK);
case 9: ShowPlayerDialog(playerid, DIALOG_VEHICLES_SALOON, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Admiral\nBloodring Banger\nBravura\nBuccaneer\nCadrona\nClover\nElega nt\nElegy\nEmperor\nEsperanto\nFortune\nGlendale Shit\nGlendale\nGreendwood\nHermes\nIntruder\nMaje stic\nManana\nMerit\nNebula\nOceanic\nPremier\nPre vion\nPrimo\nSentinel\nStafford\nSultan\nSunrise\n Tampa\nVincent\nVirgo\nWillard\nWashington", #SELECT, #BACK);
case 10: ShowPlayerDialog(playerid, DIALOG_VEHICLES_SPORT, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Buffalo\nInfernus\nCheetah\nBanshee\nTurismo\nSabr e\nZR-350\nHotring Racer A\nBlista Compact\nHotring Racer B\nHotring Racer C\nSuper GT\nBullet\nUranus\nJester\nFlash\nEuros\nClub\nAl pha\nPhoenix", #SELECT, #BACK);
case 11: ShowPlayerDialog(playerid, DIALOG_VEHICLES_WAGONS, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Perenniel\nMoonbeam\nSolair\nRegina\nStratum", #SELECT, #BACK);
case 12: ShowPlayerDialog(playerid, DIALOG_VEHICLES_BOATS, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Predator\nSquallo\nSpeeder\nReefer\nTropic\nCoastg uard\nDinghy\nMarquis\nJetmax\nLaunch", #SELECT, #BACK);
case 13: ShowPlayerDialog(playerid, DIALOG_VEHICLES_UNIQUE, DIALOG_STYLE_LIST, #SELECT_VEHICLE, "Baggage\nCaddy\nCamper A\nCamper B\nCombine Harvester\nDozer\nDumper\nForklift\nHotknife\nHust ler\nHotdog\nKart\nMower\nMr.Whoopee\nRomero\nSecu ricar\nStretch\nSweeper\nTowtruck\nTug\nVortex", #SELECT, #BACK);
}
}
case DIALOG_VEHICLES_SELECTOR:
{
if(!response) return 0;
switch(listitem)
{
case 0: ShowModelSelectionMenu(playerid, vehiclelist, #SELECT_VEHICLE);
case 1: ShowPlayerDialog(playerid, DIALOG_VEHICLES_CATEGORY, DIALOG_STYLE_LIST, #VEHICLE_TYPE_SELECT, #CAR_LIST, #SELECT, #CLOSE);
case 2: ShowPlayerDialog(playerid, DIALOG_VEHICLES_INPUT, DIALOG_STYLE_INPUT, #ENTERING_NAME, #ENTER_NAME_IN_FIELD_BELOW, #OKAY, #CLOSE);
}
}
case DIALOG_VEHICLES_INPUT:
{
str_del_free_space(inputtext);
if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_VEHICLES_SELECTOR, DIALOG_STYLE_LIST, #VEHICLE_SELECT_METHOD, #SELECT_BY_CLICK #SELECT_BY_DIALOG #SELECT_BY_INPUT, #SELECT, #EMPTY);
else if(GetVehicleModelIdByName(inputtext) != -1) CreatePlayerVehicle(playerid, GetVehicleModelIdByName(inputtext));
else return SendClientMessage(playerid, -1, #BAD_VEHICLE_NAME);
}
}
return 1;
}

public OnFilterScriptExit()
{
mysql_close(hMYSQL);
return 1;
}

Sithis
22/04/2015, 09:53 PM
Set the ID column to use Auto Increment (A_I). In your insert query set value as NULL. The database server will then use the next available id.