| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069 |
- //
- // Model Selection using previews. For SA-MP 0.3x and above.
- // - D0erfler 2013
- // - Kye 2013
- //
- // Version 1.1 R2
- /*Functions to be used
- LoadModelSelectionMenu(f_name[])
- HideModelSelectionMenu(playerid)
- ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
- ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
- */
- // Callbacks
- forward OnPlayerModelSelection(playerid, response, listid, modelid);
- forward OnPlayerModelSelectionEx(playerid, response, extraid, modelid);
- new BuyingVeh[MAX_PLAYERS];
- new VehicleNames2[212][] = {
- "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perennial", "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", "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", "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","Tractor","Combine","Feltzer","Remington",
- "Slamvan", "Blade", "Freight", "Streak","Vortex","Vincent","Bullet","Clover",
- "Sadler", "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa",
- "Sunrise", "Merit", "Utility Truck", "Nevada", "Yosemite", "Windsor", "Monster",
- "Monster","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RCTiger",
- "Flash","Tahoma","Savanna", "Bandito", "Freight", "Trailer", "Kart", "Mower",
- "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley",
- "Stafford", "BF-400", "Newsvan","Tug","Trailer","Emperor","Wayfarer","Euros",
- "Hotdog", "Club", "Trailer", "Trailer","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","Luggage Trailer","Stair Trailer", "Boxville", "Farm Plow",
- "Utility Trailer"
- };
- enum DEALERSHIP
- {
- cCarModel,
- cCarPrice
- }
- new DonateVehicles[][DEALERSHIP] = {
- {481, 12000},
- {509, 12000},
- {477, 425000},
- {468, 55000},
- {521, 100000},
- {541, 555999},
- {429, 560000}
- };
- new VehiclePrices[][DEALERSHIP] = {
- {462, 11999},
- {525, 19500},
- {543, 21000},
- {473, 26000},
- {463, 30500},
- {440, 31000},
- {532, 35500},
- {600, 35999},
- {491, 35999},
- {410, 35999},
- {516, 35999},
- {418, 36000},
- {586, 36000},
- {467, 36500},
- {547, 39500},
- {401, 41500},
- {549, 41999},
- {436, 41999},
- {420, 45500},
- {517, 45999},
- {589, 45999},
- {518, 45999},
- {527, 45999},
- {551, 45999},
- {439, 45999},
- {445, 46000},
- {478, 46000},
- {492, 48999},
- {422, 51000},
- {529, 51500},
- {405, 52500},
- {466, 52999},
- {546, 53999},
- {540, 55500},
- {474, 55999},
- {526, 55999},
- {500, 56000},
- {483, 56000},
- {545, 56000},
- {419, 56781},
- {561, 56999},
- {459, 61000},
- {421, 61500},
- {458, 61500},
- {550, 61999},
- {576, 62500},
- {412, 64500},
- {438, 65500},
- {533, 65999},
- {534, 65999},
- {585, 65999},
- {507, 65999},
- {554, 66000},
- {567, 66500},
- {536, 66500},
- {599, 66500},
- {575, 66999},
- {479, 71400},
- {489, 71750},
- {431, 76000},
- {523, 76000},
- {575, 76500},
- {542, 76500},
- {413, 80000},
- {496, 80299},
- {535, 80999},
- {508, 81800},
- {426, 86500},
- {404, 86500},
- {562, 92999},
- {580, 95999},
- {482, 96500},
- {566, 100500},
- {587, 101000},
- {423, 101500},
- {588, 101500},
- {559, 105999},
- {579, 106500},
- {400, 109999},
- {453, 121000},
- {402, 126000},
- {558, 126000},
- {480, 126500},
- {408, 126500},
- {602, 151000},
- {565, 155999},
- {555, 186000},
- {484, 232200},
- {430, 246000},
- {409, 251000},
- {560, 276000},
- {454, 300999},
- {603, 345000},
- {415, 456999},
- {446, 501000},
- {563, 1001000},
- {417, 1001000},
- {487, 2551000},
- {593, 3501000},
- {481, 12000},
- {509, 12000},
- {477, 425000},
- {468, 55000},
- {521, 100000},
- {541, 555999},
- {429, 560000}
- };
- // settings static lists
- #define mS_TOTAL_ITEMS 1000 // Max amount of items from all lists
- #define mS_TOTAL_LISTS 20 // Max amount of lists
- #define mS_TOTAL_ROT_ZOOM 100 // Max amount of items using extra information like zoom or rotations
- // settings dynamic per player lists
- #define mS_CUSTOM_MAX_ITEMS 20
- new gCustomList[MAX_PLAYERS][mS_CUSTOM_MAX_ITEMS];
- #define mS_INVALID_LISTID mS_TOTAL_LISTS
- #define mS_CUSTOM_LISTID (mS_TOTAL_LISTS+1)
- #define mS_NEXT_TEXT "Next"
- #define mS_PREV_TEXT "Prev"
- #define mS_CANCEL_TEXT "Cancel"
- #define mS_SELECTION_ITEMS 21
- #define mS_ITEMS_PER_LINE 7
- #define mS_DIALOG_BASE_X 75.0
- #define mS_DIALOG_BASE_Y 130.0
- #define mS_DIALOG_WIDTH 550.0
- #define mS_DIALOG_HEIGHT 180.0
- #define mS_SPRITE_DIM_X 60.0
- #define mS_SPRITE_DIM_Y 70.0
- new PlayerText:gCurrentPageTextDrawId[MAX_PLAYERS];
- new PlayerText:gHeaderTextDrawId[MAX_PLAYERS];
- new PlayerText:gBackgroundTextDrawId[MAX_PLAYERS];
- new PlayerText:gNextButtonTextDrawId[MAX_PLAYERS];
- new PlayerText:gPrevButtonTextDrawId[MAX_PLAYERS];
- new PlayerText:gCancelButtonTextDrawId[MAX_PLAYERS];
- new PlayerText:gVehicleName[MAX_PLAYERS][mS_SELECTION_ITEMS];
- new PlayerText:gSelectionItems[MAX_PLAYERS][mS_SELECTION_ITEMS];
- new gSelectionItemsTag[MAX_PLAYERS][mS_SELECTION_ITEMS];
- new gItemAt[MAX_PLAYERS];
- #define mS_LIST_START 0
- #define mS_LIST_END 1
- new gLists[mS_TOTAL_LISTS][2]; // list information start/end index
- #define mS_ITEM_MODEL 0
- #define mS_ITEM_ROT_ZOOM_ID 1
- new gItemList[mS_TOTAL_ITEMS][2];
- new Float:gRotZoom[mS_TOTAL_ROT_ZOOM][4]; // Array for saving rotation and zoom info
- new gItemAmount = 0; // Amount of items used
- new gListAmount = 0; // Amount of lists used
- new gRotZoomAmount = 0; // Amount of Rotation/Zoom informations used
- //------------------------------------------------
- stock mS_GetNumberOfPages(ListID)
- {
- new ItemAmount = mS_GetAmountOfListItems(ListID);
- if((ItemAmount >= mS_SELECTION_ITEMS) && (ItemAmount % mS_SELECTION_ITEMS) == 0)
- {
- return (ItemAmount / mS_SELECTION_ITEMS);
- }
- else return (ItemAmount / mS_SELECTION_ITEMS) + 1;
- }
- //------------------------------------------------
- stock mS_GetNumberOfPagesEx(playerid)
- {
- new ItemAmount = mS_GetAmountOfListItemsEx(playerid);
- if((ItemAmount >= mS_SELECTION_ITEMS) && (ItemAmount % mS_SELECTION_ITEMS) == 0)
- {
- return (ItemAmount / mS_SELECTION_ITEMS);
- }
- else return (ItemAmount / mS_SELECTION_ITEMS) + 1;
- }
- //------------------------------------------------
- stock mS_GetAmountOfListItems(ListID)
- {
- return (gLists[ListID][mS_LIST_END] - gLists[ListID][mS_LIST_START])+1;
- }
- //------------------------------------------------
- stock mS_GetAmountOfListItemsEx(playerid)
- {
- return GetPVarInt(playerid, "mS_custom_item_amount");
- }
- //------------------------------------------------
- stock mS_GetPlayerCurrentListID(playerid)
- {
- if(GetPVarInt(playerid, "mS_list_active") == 1) return GetPVarInt(playerid, "mS_list_id");
- else return mS_INVALID_LISTID;
- }
- //------------------------------------------------
- stock PlayerText:mS_CreateCurrentPageTextDraw(playerid, Float:Xpos, Float:Ypos)
- {
- new PlayerText:txtInit;
- txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, "0/0");
- PlayerTextDrawUseBox(playerid, txtInit, 0);
- PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
- PlayerTextDrawFont(playerid, txtInit, 1);
- PlayerTextDrawSetShadow(playerid, txtInit, 0);
- PlayerTextDrawSetOutline(playerid, txtInit, 1);
- PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
- PlayerTextDrawShow(playerid, txtInit);
- return txtInit;
- }
- //------------------------------------------------
- // Creates a button textdraw and returns the textdraw ID.
- stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
- {
- new PlayerText:txtInit;
- txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, button_text);
- PlayerTextDrawUseBox(playerid, txtInit, 1);
- PlayerTextDrawBoxColor(playerid, txtInit, 0x000000FF);
- PlayerTextDrawBackgroundColor(playerid, txtInit, 0x000000FF);
- PlayerTextDrawLetterSize(playerid, txtInit, 0.4, 1.1);
- PlayerTextDrawFont(playerid, txtInit, 1);
- PlayerTextDrawSetShadow(playerid, txtInit, 0); // no shadow
- PlayerTextDrawSetOutline(playerid, txtInit, 0);
- PlayerTextDrawColor(playerid, txtInit, 0x4A5A6BFF);
- PlayerTextDrawSetSelectable(playerid, txtInit, 1);
- PlayerTextDrawAlignment(playerid, txtInit, 2);
- PlayerTextDrawTextSize(playerid, txtInit, Height, Width); // The width and height are reversed for centering.. something the game does <g>
- PlayerTextDrawShow(playerid, txtInit);
- return txtInit;
- }
-
- //------------------------------------------------
- forward IsADonateModel(model);
- public IsADonateModel(model)
- {
- for(new i = 0; i < sizeof(DonateVehicles); i++)
- if(DonateVehicles[i][cCarModel] == model)
- return true;
- return false;
- }
-
- stock PlayerText:CreateVehicleName(playerid, model, Float:Xpos, Float:Ypos, Float:Width, Float:Height, vehiclename[], vehicleprice)
- {
- new PlayerText:txtInit;
- new str[128];
- if(IsADonateModel(model))
- format(str, sizeof(str), "%s~n~$%d~n~~n~~n~~n~~n~~y~[SPECIAL]", vehiclename, vehicleprice);
- else
- format(str, sizeof(str), "%s~n~$%d", vehiclename, vehicleprice);
- txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, str);
- PlayerTextDrawBackgroundColor(playerid, txtInit, 0x000000FF);
- PlayerTextDrawLetterSize(playerid, txtInit, 0.3, 1.0);
- PlayerTextDrawFont(playerid, txtInit, 1);
- PlayerTextDrawSetShadow(playerid, txtInit, 1); // no shadow
- PlayerTextDrawSetOutline(playerid, txtInit, 1);
- PlayerTextDrawColor(playerid, txtInit, 0xC0C0C0FF);
- PlayerTextDrawTextSize(playerid, txtInit, Height, Width); // The width and height are reversed for centering.. something the game does <g>
- PlayerTextDrawShow(playerid, txtInit);
- return txtInit;
- }
-
-
- //------------------------------------------------
- stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
- {
- new PlayerText:txtInit;
- txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
- PlayerTextDrawUseBox(playerid, txtInit, 0);
- PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
- PlayerTextDrawFont(playerid, txtInit, 0);
- PlayerTextDrawSetShadow(playerid, txtInit, 0);
- PlayerTextDrawSetOutline(playerid, txtInit, 1);
- PlayerTextDrawColor(playerid, txtInit, 0xACCBF1FF);
- PlayerTextDrawShow(playerid, txtInit);
- return txtInit;
- }
- stock PlayerText:CreateHeaderBuyableText(playerid, Float:Xpos, Float:Ypos, header_text[])
- {
- new PlayerText:txtInit;
- txtInit = CreatePlayerTextDraw(playerid, Xpos, Ypos, header_text);
- PlayerTextDrawUseBox(playerid, txtInit, 0);
- PlayerTextDrawLetterSize(playerid, txtInit, 1.25, 3.0);
- PlayerTextDrawFont(playerid, txtInit, 3);
- PlayerTextDrawSetShadow(playerid, txtInit, 1);
- PlayerTextDrawSetOutline(playerid, txtInit, 1);
- PlayerTextDrawColor(playerid, txtInit, 0x00FF00FF);
- PlayerTextDrawShow(playerid, txtInit);
- return txtInit;
- }
- //------------------------------------------------
- stock PlayerText:mS_CreatePlayerBGTextDraw(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, bgcolor)
- {
- new PlayerText:txtBackground = CreatePlayerTextDraw(playerid, Xpos, Ypos," ~n~"); // enough space for everyone
- PlayerTextDrawUseBox(playerid, txtBackground, 1);
- PlayerTextDrawBoxColor(playerid, txtBackground, bgcolor);
- PlayerTextDrawLetterSize(playerid, txtBackground, 5.0, 5.0);
- PlayerTextDrawFont(playerid, txtBackground, 0);
- PlayerTextDrawSetShadow(playerid, txtBackground, 0);
- PlayerTextDrawSetOutline(playerid, txtBackground, 0);
- PlayerTextDrawColor(playerid, txtBackground,0x000000FF);
- PlayerTextDrawTextSize(playerid, txtBackground, Width, Height);
- PlayerTextDrawBackgroundColor(playerid, txtBackground, bgcolor);
- PlayerTextDrawShow(playerid, txtBackground);
- return txtBackground;
- }
- //------------------------------------------------
- // Creates a model preview sprite
- stock PlayerText:mS_CreateMPTextDraw(playerid, modelindex, Float:Xpos, Float:Ypos, Float:Xrot, Float:Yrot, Float:Zrot, Float:mZoom, Float:width, Float:height, bgcolor)
- {
- new PlayerText:txtPlayerSprite = CreatePlayerTextDraw(playerid, Xpos, Ypos, ""); // it has to be set with SetText later
- PlayerTextDrawFont(playerid, txtPlayerSprite, TEXT_DRAW_FONT_MODEL_PREVIEW);
- PlayerTextDrawColor(playerid, txtPlayerSprite, 0xFFFFFFFF);
- PlayerTextDrawBackgroundColor(playerid, txtPlayerSprite, bgcolor);
- PlayerTextDrawTextSize(playerid, txtPlayerSprite, width, height); // Text size is the Width:Height
- PlayerTextDrawSetPreviewModel(playerid, txtPlayerSprite, modelindex);
- PlayerTextDrawSetPreviewRot(playerid,txtPlayerSprite, Xrot, Yrot, Zrot, mZoom);
- PlayerTextDrawSetSelectable(playerid, txtPlayerSprite, 1);
- PlayerTextDrawShow(playerid,txtPlayerSprite);
- return txtPlayerSprite;
- }
- //------------------------------------------------
- stock mS_DestroyPlayerMPs(playerid)
- {
- new x=0;
- while(x != mS_SELECTION_ITEMS) {
- if(gSelectionItems[playerid][x] != PlayerText:INVALID_TEXT_DRAW) {
- PlayerTextDrawDestroy(playerid, gSelectionItems[playerid][x]);
- gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
- if(BuyingVeh[playerid] == 1)
- {
- if(gVehicleName[playerid][x] != PlayerText:INVALID_TEXT_DRAW)
- {
- PlayerTextDrawDestroy(playerid, gVehicleName[playerid][x]);
- gVehicleName[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
- }
- }
- }
- x++;
- }
- }
- //------------------------------------------------
- stock mS_ShowPlayerMPs(playerid)
- {
- new bgcolor = GetPVarInt(playerid, "mS_previewBGcolor");
- new x=0;
- new Float:BaseX = mS_DIALOG_BASE_X;
- new Float:BaseY = mS_DIALOG_BASE_Y - (mS_SPRITE_DIM_Y * 0.33); // down a bit
- new linetracker = 0;
-
- new mS_listID = mS_GetPlayerCurrentListID(playerid);
- if(mS_listID == mS_CUSTOM_LISTID)
- {
- new itemat = (GetPVarInt(playerid, "mS_list_page") * mS_SELECTION_ITEMS);
- new Float:rotzoom[4];
- rotzoom[0] = GetPVarFloat(playerid, "mS_custom_Xrot");
- rotzoom[1] = GetPVarFloat(playerid, "mS_custom_Yrot");
- rotzoom[2] = GetPVarFloat(playerid, "mS_custom_Zrot");
- rotzoom[3] = GetPVarFloat(playerid, "mS_custom_Zoom");
- new itemamount = mS_GetAmountOfListItemsEx(playerid);
- // Destroy any previous ones created
- mS_DestroyPlayerMPs(playerid);
- while(x != mS_SELECTION_ITEMS && itemat < (itemamount)) {
- if(linetracker == 0) {
- BaseX = mS_DIALOG_BASE_X + 25.0; // in a bit from the box
- BaseY += mS_SPRITE_DIM_Y + 1.0; // move on the Y for the next line
- }
- gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gCustomList[playerid][itemat], BaseX, BaseY, rotzoom[0], rotzoom[1], rotzoom[2], rotzoom[3], mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
- gSelectionItemsTag[playerid][x] = gCustomList[playerid][itemat];
- BaseX += mS_SPRITE_DIM_X + 1.0; // move on the X for the next sprite
- linetracker++;
- if(linetracker == mS_ITEMS_PER_LINE) linetracker = 0;
- itemat++;
- x++;
- }
- }
- else
- {
- new itemat = (gLists[mS_listID][mS_LIST_START] + (GetPVarInt(playerid, "mS_list_page") * mS_SELECTION_ITEMS));
-
- // Destroy any previous ones created
- mS_DestroyPlayerMPs(playerid);
- while(x != mS_SELECTION_ITEMS && itemat < (gLists[mS_listID][mS_LIST_END]+1)) {
- if(linetracker == 0) {
- BaseX = mS_DIALOG_BASE_X + 25.0; // in a bit from the box
- BaseY += mS_SPRITE_DIM_Y + 1.0; // move on the Y for the next line
- }
- new rzID = gItemList[itemat][mS_ITEM_ROT_ZOOM_ID]; // avoid long line
- if(rzID > -1) gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gItemList[itemat][mS_ITEM_MODEL], BaseX, BaseY, gRotZoom[rzID][0], gRotZoom[rzID][1], gRotZoom[rzID][2], gRotZoom[rzID][3], mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
- else gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gItemList[itemat][mS_ITEM_MODEL], BaseX, BaseY, 0.0, 0.0, 0.0, 1.0, mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
- gSelectionItemsTag[playerid][x] = gItemList[itemat][mS_ITEM_MODEL];
- BaseX += mS_SPRITE_DIM_X + 1.0; // move on the X for the next sprite
- linetracker++;
- if(linetracker == mS_ITEMS_PER_LINE) linetracker = 0;
- itemat++;
- x++;
- }
- }
- }
- stock ShowPlayerBuyable(playerid)
- {
- new bgcolor = GetPVarInt(playerid, "mS_previewBGcolor");
- new x=0;
- new Float:BaseX = mS_DIALOG_BASE_X;
- new Float:BaseY = mS_DIALOG_BASE_Y - (mS_SPRITE_DIM_Y * 0.33); // down a bit
- new linetracker = 0;
-
- new mS_listID = mS_GetPlayerCurrentListID(playerid);
- if(mS_listID == mS_CUSTOM_LISTID)
- {
- new itemat = (GetPVarInt(playerid, "mS_list_page") * mS_SELECTION_ITEMS);
- new Float:rotzoom[4];
- rotzoom[0] = GetPVarFloat(playerid, "mS_custom_Xrot");
- rotzoom[1] = GetPVarFloat(playerid, "mS_custom_Yrot");
- rotzoom[2] = GetPVarFloat(playerid, "mS_custom_Zrot");
- rotzoom[3] = GetPVarFloat(playerid, "mS_custom_Zoom");
- new itemamount = mS_GetAmountOfListItemsEx(playerid);
- // Destroy any previous ones created
- mS_DestroyPlayerMPs(playerid);
- while(x != mS_SELECTION_ITEMS && itemat < (itemamount)) {
- if(linetracker == 0) {
- BaseX = mS_DIALOG_BASE_X + 25.0; // in a bit from the box
- BaseY += mS_SPRITE_DIM_Y + 1.0; // move on the Y for the next line
- }
- gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gCustomList[playerid][itemat], BaseX, BaseY, rotzoom[0], rotzoom[1], rotzoom[2], rotzoom[3], mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
- gSelectionItemsTag[playerid][x] = gCustomList[playerid][itemat];
- BaseX += mS_SPRITE_DIM_X + 1.0; // move on the X for the next sprite
- linetracker++;
- if(linetracker == mS_ITEMS_PER_LINE) linetracker = 0;
- itemat++;
- x++;
- }
- }
- else
- {
- new itemat = (gLists[mS_listID][mS_LIST_START] + (GetPVarInt(playerid, "mS_list_page") * mS_SELECTION_ITEMS));
-
- // Destroy any previous ones created
- mS_DestroyPlayerMPs(playerid);
- while(x != mS_SELECTION_ITEMS && itemat < (gLists[mS_listID][mS_LIST_END]+1)) {
- if(linetracker == 0) {
- BaseX = mS_DIALOG_BASE_X + 25.0; // in a bit from the box
- BaseY += mS_SPRITE_DIM_Y + 1.0; // move on the Y for the next line
- }
- new rzID = gItemList[itemat][mS_ITEM_ROT_ZOOM_ID]; // avoid long line
- if(rzID > -1) gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gItemList[itemat][mS_ITEM_MODEL], BaseX, BaseY, gRotZoom[rzID][0], gRotZoom[rzID][1], gRotZoom[rzID][2], gRotZoom[rzID][3], mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
- else gSelectionItems[playerid][x] = mS_CreateMPTextDraw(playerid, gItemList[itemat][mS_ITEM_MODEL], BaseX, BaseY, 0.0, 0.0, 0.0, 1.0, mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, bgcolor);
-
- gVehicleName[playerid][x] = CreateVehicleName(playerid, gItemList[itemat][mS_ITEM_MODEL], BaseX, BaseY, mS_SPRITE_DIM_X, mS_SPRITE_DIM_Y, VehicleNames2[gItemList[itemat][mS_ITEM_MODEL]-400], GetVehiclePrice2(gItemList[itemat][mS_ITEM_MODEL]));
-
- gSelectionItemsTag[playerid][x] = gItemList[itemat][mS_ITEM_MODEL];
- BaseX += mS_SPRITE_DIM_X + 1.0; // move on the X for the next sprite
- linetracker++;
- if(linetracker == mS_ITEMS_PER_LINE) linetracker = 0;
- itemat++;
- x++;
- }
- }
- }
- stock GetVehiclePrice2(model)
- {
- for(new i = 0; i < sizeof(VehiclePrices); i++)
- {
- if(model == VehiclePrices[i][cCarModel])
- return VehiclePrices[i][cCarPrice];
- }
- return 0;
- }
- //------------------------------------------------
- stock mS_UpdatePageTextDraw(playerid)
- {
- new PageText[64+1];
- new listID = mS_GetPlayerCurrentListID(playerid);
- if(listID == mS_CUSTOM_LISTID)
- {
- format(PageText, 64, "%d/%d", GetPVarInt(playerid,"mS_list_page") + 1, mS_GetNumberOfPagesEx(playerid));
- PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
- }
- else
- {
- format(PageText, 64, "%d/%d", GetPVarInt(playerid,"mS_list_page") + 1, mS_GetNumberOfPages(listID));
- PlayerTextDrawSetString(playerid, gCurrentPageTextDrawId[playerid], PageText);
- }
- }
- //------------------------------------------------
- stock ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
- {
- if(!(0 <= ListID < mS_TOTAL_LISTS && gLists[ListID][mS_LIST_START] != gLists[ListID][mS_LIST_END])) return 0;
- mS_DestroySelectionMenu(playerid);
- SetPVarInt(playerid, "mS_list_page", 0);
- SetPVarInt(playerid, "mS_list_id", ListID);
- SetPVarInt(playerid, "mS_list_active", 1);
- SetPVarInt(playerid, "mS_list_time", GetTickCount());
- gBackgroundTextDrawId[playerid] = mS_CreatePlayerBGTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y + 20.0, mS_DIALOG_WIDTH, mS_DIALOG_HEIGHT, dialogBGcolor);
- gHeaderTextDrawId[playerid] = mS_CreatePlayerHeaderTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y, header_text);
- gCurrentPageTextDrawId[playerid] = mS_CreateCurrentPageTextDraw(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y + 15.0);
- gNextButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_NEXT_TEXT);
- gPrevButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 90.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_PREV_TEXT);
- gCancelButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 150.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_CANCEL_TEXT);
-
- SetPVarInt(playerid, "mS_previewBGcolor", previewBGcolor);
- mS_ShowPlayerMPs(playerid);
- mS_UpdatePageTextDraw(playerid);
-
- SelectTextDraw(playerid, tdSelectionColor);
- return 1;
- }
- stock ShowModelSelectionMenu2(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
- {
- if(!(0 <= ListID < mS_TOTAL_LISTS && gLists[ListID][mS_LIST_START] != gLists[ListID][mS_LIST_END])) return 0;
- mS_DestroySelectionMenu(playerid);
- SetPVarInt(playerid, "mS_list_page", 0);
- SetPVarInt(playerid, "mS_list_id", ListID);
- SetPVarInt(playerid, "mS_list_active", 1);
- SetPVarInt(playerid, "mS_list_time", GetTickCount());
- gBackgroundTextDrawId[playerid] = mS_CreatePlayerBGTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y + 20.0, mS_DIALOG_WIDTH, mS_DIALOG_HEIGHT, dialogBGcolor);
- gHeaderTextDrawId[playerid] = CreateHeaderBuyableText(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y, header_text);
- gCurrentPageTextDrawId[playerid] = mS_CreateCurrentPageTextDraw(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y + 15.0);
- gNextButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_NEXT_TEXT);
- gPrevButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 90.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_PREV_TEXT);
- gCancelButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 150.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_CANCEL_TEXT);
- BuyingVeh[playerid] = 1;
- SetPVarInt(playerid, "mS_previewBGcolor", previewBGcolor);
- ShowPlayerBuyable(playerid);
- mS_UpdatePageTextDraw(playerid);
-
- SelectTextDraw(playerid, tdSelectionColor);
- return 1;
- }
- //------------------------------------------------------------
- stock ShowModelSelectionMenuEx(playerid, items_array[], item_amount, header_text[], extraid, Float:Xrot = 0.0, Float:Yrot = 0.0, Float:Zrot = 0.0, Float:mZoom = 1.0, dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
- {
- mS_DestroySelectionMenu(playerid);
- if(item_amount > mS_CUSTOM_MAX_ITEMS)
- {
- item_amount = mS_CUSTOM_MAX_ITEMS;
- print("-mSelection- WARNING: Too many items given to \"ShowModelSelectionMenuEx\", increase \"mS_CUSTOM_MAX_ITEMS\" to fix this");
- }
- if(item_amount > 0)
- {
- for(new i=0;i<item_amount;i++)
- {
- gCustomList[playerid][i] = items_array[i];
- }
- SetPVarInt(playerid, "mS_list_page", 0);
- SetPVarInt(playerid, "mS_list_id", mS_CUSTOM_LISTID);
- SetPVarInt(playerid, "mS_list_active", 1);
- SetPVarInt(playerid, "mS_list_time", GetTickCount());
-
- SetPVarInt(playerid, "mS_custom_item_amount", item_amount);
- SetPVarFloat(playerid, "mS_custom_Xrot", Xrot);
- SetPVarFloat(playerid, "mS_custom_Yrot", Yrot);
- SetPVarFloat(playerid, "mS_custom_Zrot", Zrot);
- SetPVarFloat(playerid, "mS_custom_Zoom", mZoom);
- SetPVarInt(playerid, "mS_custom_extraid", extraid);
-
- gBackgroundTextDrawId[playerid] = mS_CreatePlayerBGTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y + 20.0, mS_DIALOG_WIDTH, mS_DIALOG_HEIGHT, dialogBGcolor);
- gHeaderTextDrawId[playerid] = mS_CreatePlayerHeaderTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y, header_text);
- gCurrentPageTextDrawId[playerid] = mS_CreateCurrentPageTextDraw(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y + 15.0);
- gNextButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_NEXT_TEXT);
- gPrevButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 90.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_PREV_TEXT);
- gCancelButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 150.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_CANCEL_TEXT);
- SetPVarInt(playerid, "mS_previewBGcolor", previewBGcolor);
- mS_ShowPlayerMPs(playerid);
- mS_UpdatePageTextDraw(playerid);
-
- SelectTextDraw(playerid, tdSelectionColor);
- return 1;
- }
- return 0;
- }
- //------------------------------------------------
- stock HideModelSelectionMenu(playerid)
- {
- mS_DestroySelectionMenu(playerid);
- SetPVarInt(playerid, "mS_ignore_next_esc", 1);
- CancelSelectTextDraw(playerid);
- return 1;
- }
- //------------------------------------------------
- stock mS_DestroySelectionMenu(playerid)
- {
- if(GetPVarInt(playerid, "mS_list_active") == 1)
- {
- if(mS_GetPlayerCurrentListID(playerid) == mS_CUSTOM_LISTID)
- {
- DeletePVar(playerid, "mS_custom_Xrot");
- DeletePVar(playerid, "mS_custom_Yrot");
- DeletePVar(playerid, "mS_custom_Zrot");
- DeletePVar(playerid, "mS_custom_Zoom");
- DeletePVar(playerid, "mS_custom_extraid");
- DeletePVar(playerid, "mS_custom_item_amount");
- }
- DeletePVar(playerid, "mS_list_time");
- SetPVarInt(playerid, "mS_list_active", 0);
- mS_DestroyPlayerMPs(playerid);
- PlayerTextDrawDestroy(playerid, gHeaderTextDrawId[playerid]);
- PlayerTextDrawDestroy(playerid, gBackgroundTextDrawId[playerid]);
- PlayerTextDrawDestroy(playerid, gCurrentPageTextDrawId[playerid]);
- PlayerTextDrawDestroy(playerid, gNextButtonTextDrawId[playerid]);
- PlayerTextDrawDestroy(playerid, gPrevButtonTextDrawId[playerid]);
- PlayerTextDrawDestroy(playerid, gCancelButtonTextDrawId[playerid]);
- gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gCancelButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- }
- }
- //------------------------------------------------
- public OnPlayerConnect(playerid)
- {
- // Init all of the textdraw related globals
- gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- gCancelButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
- for(new x=0; x < mS_SELECTION_ITEMS; x++) {
- gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
- }
-
- for(new x=0; x < mS_SELECTION_ITEMS; x++) {
- gVehicleName[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
- }
-
- gItemAt[playerid] = 0;
-
- return CallLocalFunction("MP_OPC", "i", playerid);
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect MP_OPC
- forward MP_OPC(playerid);
- //-------------------------------------------
- // Even though only Player* textdraws are used in this script,
- // OnPlayerClickTextDraw is still required to handle ESC
- public OnPlayerClickTextDraw(playerid, Text:clickedid)
- {
- if(GetPVarInt(playerid, "mS_ignore_next_esc") == 1) {
- SetPVarInt(playerid, "mS_ignore_next_esc", 0);
- return CallLocalFunction("MP_OPCTD", "ii", playerid, _:clickedid);
- }
- if(GetPVarInt(playerid, "mS_list_active") == 0) return CallLocalFunction("MP_OPCTD", "ii", playerid, _:clickedid);
- // Handle: They cancelled (with ESC)
- if(clickedid == Text:INVALID_TEXT_DRAW) {
- new listid = mS_GetPlayerCurrentListID(playerid);
- if(listid == mS_CUSTOM_LISTID)
- {
- new extraid = GetPVarInt(playerid, "mS_custom_extraid");
- mS_DestroySelectionMenu(playerid);
- CallLocalFunction("OnPlayerModelSelectionEx", "dddd", playerid, 0, extraid, -1);
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- else
- {
- mS_DestroySelectionMenu(playerid);
- CallLocalFunction("OnPlayerModelSelection", "dddd", playerid, 0, listid, -1);
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- return 1;
- }
-
- return CallLocalFunction("MP_OPCTD", "ii", playerid, _:clickedid);
- }
- #if defined _ALS_OnPlayerClickTextDraw
- #undef OnPlayerClickTextDraw
- #else
- #define _ALS_OnPlayerClickTextDraw
- #endif
- #define OnPlayerClickTextDraw MP_OPCTD
- forward MP_OPCTD(playerid, Text:clickedid);
- //------------------------------------------------
- public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
- {
- if(GetPVarInt(playerid, "mS_list_active") == 0 || (GetTickCount()-GetPVarInt(playerid, "mS_list_time")) < 200 /* Disable instant selection */) return CallLocalFunction("MP_OPCPTD", "ii", playerid, _:playertextid);
- new curpage = GetPVarInt(playerid, "mS_list_page");
-
- // Handle: cancel button
- if(playertextid == gCancelButtonTextDrawId[playerid]) {
- new listID = mS_GetPlayerCurrentListID(playerid);
- if(listID == mS_CUSTOM_LISTID)
- {
- new extraid = GetPVarInt(playerid, "mS_custom_extraid");
- HideModelSelectionMenu(playerid);
- CallLocalFunction("OnPlayerModelSelectionEx", "dddd", playerid, 0, extraid, -1);
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- else
- {
- HideModelSelectionMenu(playerid);
- CallLocalFunction("OnPlayerModelSelection", "dddd", playerid, 0, listID, -1);
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- return 1;
- }
-
- // Handle: next button
- if(playertextid == gNextButtonTextDrawId[playerid]) {
- new listID = mS_GetPlayerCurrentListID(playerid);
- if(listID == mS_CUSTOM_LISTID)
- {
- if(curpage < (mS_GetNumberOfPagesEx(playerid) - 1)) {
- SetPVarInt(playerid, "mS_list_page", curpage + 1);
- if(BuyingVeh[playerid] == 1)
- {
- for(new x=0; x < mS_SELECTION_ITEMS; x++)
- {
- PlayerTextDrawDestroy(playerid, gVehicleName[playerid][x]);
- }
- ShowPlayerBuyable(playerid);
- }
- else
- {
- mS_ShowPlayerMPs(playerid);
- }
- mS_UpdatePageTextDraw(playerid);
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- } else {
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- }
- else
- {
- if(curpage < (mS_GetNumberOfPages(listID) - 1)) {
- SetPVarInt(playerid, "mS_list_page", curpage + 1);
- if(BuyingVeh[playerid] == 1)
- {
- for(new x=0; x < mS_SELECTION_ITEMS; x++)
- {
- PlayerTextDrawDestroy(playerid, gVehicleName[playerid][x]);
- }
- ShowPlayerBuyable(playerid);
- }
- else
- {
- mS_ShowPlayerMPs(playerid);
- }
- mS_UpdatePageTextDraw(playerid);
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- } else {
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- }
- return 1;
- }
-
- // Handle: previous button
- if(playertextid == gPrevButtonTextDrawId[playerid]) {
- if(curpage > 0) {
- SetPVarInt(playerid, "mS_list_page", curpage - 1);
- if(BuyingVeh[playerid] == 1)
- {
- for(new x=0; x < mS_SELECTION_ITEMS; x++)
- {
- PlayerTextDrawDestroy(playerid, gVehicleName[playerid][x]);
- }
- ShowPlayerBuyable(playerid);
- }
- else
- {
- mS_ShowPlayerMPs(playerid);
- }
- mS_UpdatePageTextDraw(playerid);
- PlayerPlaySound(playerid, 1084, 0.0, 0.0, 0.0);
- } else {
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- }
- return 1;
- }
-
- // Search in the array of textdraws used for the items
- new x=0;
- while(x != mS_SELECTION_ITEMS) {
- if(playertextid == gSelectionItems[playerid][x]) {
- new listID = mS_GetPlayerCurrentListID(playerid);
- if(listID == mS_CUSTOM_LISTID)
- {
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- new item_id = gSelectionItemsTag[playerid][x];
- new extraid = GetPVarInt(playerid, "mS_custom_extraid");
- HideModelSelectionMenu(playerid);
- CallLocalFunction("OnPlayerModelSelectionEx", "dddd", playerid, 1, extraid, item_id);
- return 1;
- }
- else
- {
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- new item_id = gSelectionItemsTag[playerid][x];
- HideModelSelectionMenu(playerid);
- if(BuyingVeh[playerid] == 1)
- {
- BuyingVeh[playerid] = 0;
- }
- CallLocalFunction("OnPlayerModelSelection", "dddd", playerid, 1, listID, item_id);
- return 1;
- }
- }
- x++;
- }
-
- return CallLocalFunction("MP_OPCPTD", "ii", playerid, _:playertextid);
- }
- #if defined _ALS_OnPlayerClickPlayerTD
- #undef OnPlayerClickPlayerTextDraw
- #else
- #define _ALS_OnPlayerClickPlayerTD
- #endif
- #define OnPlayerClickPlayerTextDraw MP_OPCPTD
- forward MP_OPCPTD(playerid, PlayerText:playertextid);
- //------------------------------------------------------------------
- stock LoadModelSelectionMenu(f_name[])
- {
- new File:f, str[75];
- format(str, sizeof(str), "%s", f_name);
- f = fopen(str, io_read);
- if( !f ) {
- printf("-mSelection- WARNING: Failed to load list: \"%s\"", f_name);
- return mS_INVALID_LISTID;
- }
-
- if(gListAmount >= mS_TOTAL_LISTS)
- {
- printf("-mSelection- WARNING: Reached maximum amount of lists, increase \"mS_TOTAL_LISTS\"", f_name);
- return mS_INVALID_LISTID;
- }
- new tmp_ItemAmount = gItemAmount; // copy value if loading fails
-
-
- new line[128], idxx;
- while(fread(f,line,sizeof(line),false))
- {
- if(tmp_ItemAmount >= mS_TOTAL_ITEMS)
- {
- printf("-mSelection- WARNING: Reached maximum amount of items, increase \"mS_TOTAL_ITEMS\"", f_name);
- break;
- }
- idxx = 0;
- if(!line[0]) continue;
- new mID = strval( mS_strtok(line,idxx) );
- if(0 <= mID < 20000)
- {
- gItemList[tmp_ItemAmount][mS_ITEM_MODEL] = mID;
-
- new tmp_mS_strtok[20];
- new Float:mRotation[3], Float:mZoom = 1.0;
- new bool:useRotation = false;
-
- tmp_mS_strtok = mS_strtok(line,idxx);
- if(tmp_mS_strtok[0]) {
- useRotation = true;
- mRotation[0] = floatstr(tmp_mS_strtok);
- }
- tmp_mS_strtok = mS_strtok(line,idxx);
- if(tmp_mS_strtok[0]) {
- useRotation = true;
- mRotation[1] = floatstr(tmp_mS_strtok);
- }
- tmp_mS_strtok = mS_strtok(line,idxx);
- if(tmp_mS_strtok[0]) {
- useRotation = true;
- mRotation[2] = floatstr(tmp_mS_strtok);
- }
- tmp_mS_strtok = mS_strtok(line,idxx);
- if(tmp_mS_strtok[0]) {
- useRotation = true;
- mZoom = floatstr(tmp_mS_strtok);
- }
- if(useRotation)
- {
- new bool:foundRotZoom = false;
- for(new i=0; i < gRotZoomAmount; i++)
- {
- if(gRotZoom[i][0] == mRotation[0] && gRotZoom[i][1] == mRotation[1] && gRotZoom[i][2] == mRotation[2] && gRotZoom[i][3] == mZoom)
- {
- foundRotZoom = true;
- gItemList[tmp_ItemAmount][mS_ITEM_ROT_ZOOM_ID] = i;
- 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);
- }
- printf("-mSelection- WARNING: No Items found in file: %s", f_name);
- return mS_INVALID_LISTID;
- }
-
-
-
- stock mS_strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
|