├── .gitattributes ├── pawn.json ├── README.md ├── .editorconfig └── MenuStore.inc /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /pawn.json: -------------------------------------------------------------------------------- 1 | { 2 | "user": "Coystark", 3 | "repo": "MenuStore", 4 | "contributors":[ 5 | "STGPrince" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MenuStore 2 | This include allows you to create many types of stores using Textdraws. 3 | 4 | ![MenuStore](https://i.imgur.com/gH1k6t4.jpg) 5 | 6 | Doc 7 | https://sampforum.blast.hk/showthread.php?tid=644913 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | # Matches multiple files with brace expansion notation 8 | [*.inc] 9 | charset = utf-8 10 | indent_style = tab 11 | indent_size = 4 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /MenuStore.inc: -------------------------------------------------------------------------------- 1 | /* 2 | MenuStore - Version 4.2 3 | Created by CaioTJF 4 | */ 5 | 6 | 7 | /* 8 | You can NOT change 9 | */ 10 | 11 | #define MS_MAX_ITEMS_PER_PAGE 6 12 | #define MS_MAX_ITEMS_CART 4 13 | #define MSTORE_INVALID_ITEM_ID -1 14 | #define MS_MAX_SIZE_DESCRIPTION 7.5 15 | 16 | /* 17 | You can change 18 | */ 19 | 20 | #define MS_MAX_ITEMS (MS_MAX_ITEMS_PER_PAGE*5) // --> Limit of 5 Pages 21 | #define MS_DEFAULT_MONEY_SIGN "$" 22 | #define MS_DEFAULT_CONFIRM "Buy" 23 | 24 | #define MS_COLOR_SELECT_TD 0xffffffFF 25 | #define MS_COLOR_TEXT_MAIN 0xffffffFF 26 | 27 | #define MS_COLOR_BACKGROUND_1 0x00000080 28 | #define MS_COLOR_BACKGROUND_2 0x2c2c2cAA 29 | #define MS_COLOR_BACKGROUND_ITEM 0x3e3e3eFF 30 | #define MS_COLOR_BACKGROUND_ITEMSELECTED 0xffffff50 31 | #define MS_COLOR_BACKGROUND_CONFIRM 0x5eaf3aFF 32 | #define MS_COLOR_BACKGROUND_MODEL 0xffffff50 33 | 34 | #define MS_COLOR_CART_REMOVEITEM 0xcc30a0aFF 35 | #define MS_COLOR_CART_BACKGROUND_ITEM MS_COLOR_BACKGROUND_ITEM 36 | 37 | #define MS_COLOR_DESCRIPTION_NAMEITEM MS_COLOR_TEXT_MAIN 38 | #define MS_COLOR_DESCRIPTION_TEXT 0xffffffAA 39 | #define MS_COLOR_DESCRIPTION_BACKGROUND_1 MS_COLOR_BACKGROUND_1 40 | #define MS_COLOR_DESCRIPTION_BACKGROUND_2 MS_COLOR_BACKGROUND_2 41 | #define MS_COLOR_DESCRIPTION_BACKGROUND_MODEL 0xffffff50 42 | 43 | #define MS_COLOR_TITLE_DIALOG "{ffffff}" 44 | #define MS_COLOR_TEXT_DIALOG "{ffffff}" 45 | 46 | #define MS_MSG_TITLE_DIALOG "Choose quantity" 47 | #define MS_MSG_DIALOG "Enter the quantity you want to buy" 48 | 49 | #define MS_WORD_LIMIT "Limit" 50 | #define MS_WORD_CLOSE "Close" 51 | #define MS_WORD_TOTAL "Total" 52 | #define MS_WORD_GO "Go" 53 | #define MS_WORD_CANCEL "Cancel" 54 | #define MS_WORD_CART "Cart" 55 | 56 | #define MS_INTERVAL_DOUBLECLICK 300 57 | #define DIALOG_MSTORE 23132 58 | 59 | //------------------------------------------- 60 | 61 | #if !defined isnull 62 | #define isnull(%1) \ 63 | ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1])))) 64 | #endif 65 | 66 | #define STORE:%0(%1) \ 67 | forward store_%0(%1); public store_%0(%1) 68 | 69 | #define Store:%0(%1) \ 70 | STORE:%0(%1) 71 | 72 | #define MenuStore_Show(%0,%1, \ 73 | MenuStore_Open(%0, #%1, 74 | 75 | enum enum_ms_Items 76 | { 77 | ms_ItemID, 78 | ms_ItemModel, 79 | ms_ItemPrice, 80 | ms_ItemStack, 81 | ms_ItemName[32 char], 82 | ms_ItemDescription[256 char], 83 | Float:ms_ItemDescriptionBonus, 84 | bool:ms_ItemLineJump, 85 | Float:ms_ItemPreviewRot[4] 86 | } 87 | 88 | static ms_Items[MAX_PLAYERS][MS_MAX_ITEMS][enum_ms_Items]; 89 | 90 | enum enum_ms_Info 91 | { 92 | ms_TotalItems, 93 | ms_CurrentPage, 94 | bool:ms_IsOpen, 95 | ms_StoreID[32], 96 | ms_MoneySign[32], 97 | ms_DoubleClick, 98 | ms_DoubleClickRow, 99 | ms_Selected, 100 | bool:ms_ToggleControll 101 | } 102 | 103 | static ms_Info[MAX_PLAYERS][enum_ms_Info]; 104 | 105 | enum enum_ms_Cart 106 | { 107 | ms_Cart_ItemID[MS_MAX_ITEMS_CART], 108 | ms_Cart_ItemPrice[MS_MAX_ITEMS_CART], 109 | ms_Cart_ItemAmount[MS_MAX_ITEMS_CART] 110 | 111 | } 112 | 113 | static ms_Cart[MAX_PLAYERS][enum_ms_Cart]; 114 | 115 | static ms_String[256]; 116 | 117 | // -- Global Textdraws 118 | 119 | static Text:ms_TD_Backgrounds[2] = {Text:INVALID_TEXT_DRAW, ...}; 120 | static Text:ms_TD_Next = Text:INVALID_TEXT_DRAW; 121 | static Text:ms_TD_Previous = Text:INVALID_TEXT_DRAW; 122 | 123 | static Text:ms_TD_Cart_Backgrounds[2] = {Text:INVALID_TEXT_DRAW, ...}; 124 | static Text:ms_TD_Cart_BackgroundConfirm = Text:INVALID_TEXT_DRAW; 125 | static Text:ms_TD_Cart_CartName = Text:INVALID_TEXT_DRAW; 126 | 127 | // -- Player Textdraws 128 | 129 | static PlayerText:ms_TD_ItemName[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE]; 130 | static PlayerText:ms_TD_ItemPrice[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE]; 131 | static PlayerText:ms_TD_ItemModel[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE]; 132 | static PlayerText:ms_TD_ItemBackground[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE]; 133 | static PlayerText:ms_TD_StoreName[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; 134 | static PlayerText:ms_TD_Pagination[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; 135 | static PlayerText:ms_TD_DescriptionItemName[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; 136 | static PlayerText:ms_TD_DescriptionItemText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; 137 | static PlayerText:ms_TD_DescriptionItemModel[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; 138 | static PlayerText:ms_TD_DescriptionBackground[MAX_PLAYERS][2]; 139 | 140 | static PlayerText:ms_TD_Cart_ItemBackground[MAX_PLAYERS][MS_MAX_ITEMS_CART]; 141 | static PlayerText:ms_TD_Cart_ItemName[MAX_PLAYERS][MS_MAX_ITEMS_CART]; 142 | static PlayerText:ms_TD_Cart_ItemClose[MAX_PLAYERS][MS_MAX_ITEMS_CART]; 143 | static PlayerText:ms_TD_Cart_BuyName[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; 144 | static PlayerText:ms_TD_Cart_Total[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; 145 | 146 | forward PlayerText:CreatePlayerTextDrawEx(playerid, Float:x, Float:y, const text[], Float:size_x, Float:size_y, Float:textsize_x, Float:textsize_y, align, color, usebox, boxcolor, shadow, outline, bg_color, font, proportional, model = 0, Float:preview_x= 0.0, Float:preview_y = 0.0, Float:preview_z = 0.0, Float:preview_zoom = 1.0, selectable = 0); 147 | forward Text:CreateTextDrawEx(Float:x, Float:y, const text[], Float:size_x, Float:size_y, Float:textsize_x, Float:textsize_y, align, color, usebox, boxcolor, shadow, outline, bg_color, font, proportional, model = 0, Float:preview_x = 0.0, Float:preview_y = 0.0, Float:preview_z = 0.0, Float:preview_zoom = 0.0, selectable = 0); 148 | 149 | //------------------------------------------- 150 | 151 | public OnGameModeInit() 152 | { 153 | ms_TD_Backgrounds[0] = CreateTextDrawEx(145.500000, 130.499969, "box", 154 | 0.000000, 30.198539, 155 | 322.000000, 0.000000, 156 | 1, 157 | -1, 158 | 1, 159 | MS_COLOR_BACKGROUND_1, 160 | 0, 161 | 0, 162 | 255, 163 | 1, 164 | 1); 165 | 166 | ms_TD_Backgrounds[1] = CreateTextDrawEx(153.000000, 149.383575, "box", 167 | 0.000000, 26.226503, 168 | 315.000000, 0.000000, 169 | 1, 170 | -1, 171 | 1, 172 | MS_COLOR_BACKGROUND_2, 173 | 0, 174 | 0, 175 | 255, 176 | 1, 177 | 1); 178 | 179 | ms_TD_Next = CreateTextDrawEx(251.485229, 390.033355, "ld_beat:right", 180 | 0.000000, 0.000000, 181 | 11.000000, 13.000000, 182 | 1, 183 | MS_COLOR_TEXT_MAIN, 184 | 0, 185 | 0, 186 | 0, 187 | 0, 188 | 255, 189 | 4, 190 | 1, 191 | 0, 192 | 0.0, 0.0, 0.0, 0.0, 193 | 1); 194 | 195 | ms_TD_Previous = CreateTextDrawEx(201.945220, 390.033355, "ld_beat:left", 196 | 0.000000, 0.000000, 197 | 11.000000, 13.000000, 198 | 1, 199 | MS_COLOR_TEXT_MAIN, 200 | 0, 201 | 0, 202 | 0, 203 | 0, 204 | 255, 205 | 4, 206 | 1, 207 | 0, 208 | 0.0, 0.0, 0.0, 0.0, 209 | 1); 210 | 211 | ms_TD_Cart_Backgrounds[0] = CreateTextDrawEx(333.201141, 271.666656, "box", 212 | 0.000000, 14.450012, 213 | 516.000000, 0.000000, 214 | 1, 215 | -1, 216 | 1, 217 | MS_COLOR_BACKGROUND_1, 218 | 0, 219 | 0, 220 | 255, 221 | 1, 222 | 1); 223 | 224 | ms_TD_Cart_Backgrounds[1] = CreateTextDrawEx(341.000000, 290.133575, "box", 225 | 0.000000, 10.134258, 226 | 508.000000, 0.000000, 227 | 1, 228 | -1, 229 | 1, 230 | MS_COLOR_BACKGROUND_2, 231 | 0, 232 | 0, 233 | 255, 234 | 1, 235 | 1); 236 | 237 | ms_TD_Cart_BackgroundConfirm = CreateTextDrawEx(444.899230, 390.233489, "box", 238 | 0.000000, 0.850001, 239 | 507.701690, 15.000000, 240 | 1, 241 | -1, 242 | 1, 243 | MS_COLOR_BACKGROUND_CONFIRM, 244 | 0, 245 | 0, 246 | 255, 247 | 1, 248 | 1, 249 | 0, 250 | 0.0, 0.0, 0.0, 0.0, 251 | 1); 252 | 253 | ms_TD_Cart_CartName = CreateTextDrawEx(339.143798, 270.733520, MS_WORD_CART, 254 | 0.310357, 1.434998, 255 | 508.000000, 0.0, 256 | 1, 257 | MS_COLOR_TEXT_MAIN, 258 | 1, 259 | 0xffffff00, 260 | 0, 261 | 0, 262 | 255, 263 | 2, 264 | 1); 265 | 266 | #if defined MS_OnGameModeInit 267 | return MS_OnGameModeInit(); 268 | #else 269 | return 1; 270 | #endif 271 | } 272 | 273 | #if defined _ALS_OnGameModeInit 274 | #undef OnGameModeInit 275 | #else 276 | #define _ALS_OnGameModeInit 277 | #endif 278 | #define OnGameModeInit MS_OnGameModeInit 279 | 280 | #if defined MS_OnGameModeInit 281 | forward MS_OnGameModeInit(); 282 | #endif 283 | 284 | //------------------------------------------- 285 | 286 | public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid) 287 | { 288 | if(ms_Info[playerid][ms_ToggleControll]) 289 | { 290 | for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++) 291 | { 292 | if(playertextid == ms_TD_ItemBackground[playerid][i]) 293 | { 294 | new index = i+(MS_MAX_ITEMS_PER_PAGE * (ms_Info[playerid][ms_CurrentPage] - 1)); 295 | 296 | // --> Doubleclick 297 | if((GetTickCount() - ms_Info[playerid][ms_DoubleClick]) < MS_INTERVAL_DOUBLECLICK && ms_Info[playerid][ms_DoubleClickRow] == i) 298 | { 299 | 300 | if(ms_Items[playerid][index][ms_ItemStack] > 1) 301 | { 302 | MenuStore_ToggleControll(playerid, false); 303 | MenuStore_SelectRow(playerid, i); 304 | format(ms_String, sizeof(ms_String), ""#MS_COLOR_TEXT_DIALOG""#MS_MSG_DIALOG" ("#MS_WORD_LIMIT": %d)", ms_Items[playerid][index][ms_ItemStack]); 305 | ShowPlayerDialog(playerid, DIALOG_MSTORE, DIALOG_STYLE_INPUT, ""#MS_COLOR_TITLE_DIALOG""#MS_MSG_TITLE_DIALOG":", ms_String, MS_WORD_GO, MS_WORD_CANCEL); 306 | } 307 | else 308 | { 309 | MenuStore_AddToCart(playerid, ms_Items[playerid][index][ms_ItemID], ms_Items[playerid][index][ms_ItemPrice], ms_Items[playerid][index][ms_ItemStack]); 310 | MenuStore_UnselectRow(playerid); 311 | MenuStore_CloseDescription(playerid); 312 | } 313 | 314 | ms_Info[playerid][ms_DoubleClickRow] = -1; 315 | ms_Info[playerid][ms_DoubleClick] = 0; 316 | return true; 317 | } 318 | else 319 | { 320 | ms_Info[playerid][ms_DoubleClickRow] = i; 321 | ms_Info[playerid][ms_DoubleClick] = GetTickCount(); 322 | } 323 | 324 | if(ms_Info[playerid][ms_Selected] == i) 325 | { 326 | MenuStore_UnselectRow(playerid); 327 | MenuStore_CloseDescription(playerid); 328 | return true; 329 | } 330 | else if(ms_Info[playerid][ms_Selected] != -1) 331 | MenuStore_UnselectRow(playerid); 332 | 333 | MenuStore_SelectRow(playerid, i); 334 | MenuStore_OpenDescription(playerid, index); 335 | return true; 336 | } 337 | } 338 | 339 | for(new row = 0; row < MS_MAX_ITEMS_CART; row++) 340 | { 341 | if(playertextid == ms_TD_Cart_ItemBackground[playerid][row]) 342 | { 343 | MenuStore_RemoveFromCart(playerid, row); 344 | return true; 345 | } 346 | } 347 | } 348 | 349 | #if defined MS_OnPlayerClickPlayerTD 350 | return MS_OnPlayerClickPlayerTD(playerid, playertextid); 351 | #else 352 | return 1; 353 | #endif 354 | } 355 | 356 | 357 | #if defined _ALS_OnPlayerClickPlayerTD 358 | #undef OnPlayerClickPlayerTextDraw 359 | #else 360 | #define _ALS_OnPlayerClickPlayerTD 361 | #endif 362 | #define OnPlayerClickPlayerTextDraw MS_OnPlayerClickPlayerTD 363 | 364 | #if defined MS_OnPlayerClickPlayerTD 365 | forward MS_OnPlayerClickPlayerTD(playerid, PlayerText:playertextid); 366 | #endif 367 | 368 | //------------------------------------------- 369 | 370 | public OnPlayerClickTextDraw(playerid, Text:clickedid) 371 | { 372 | if(clickedid == Text:INVALID_TEXT_DRAW && MenuStore_IsOpen(playerid) && ms_Info[playerid][ms_ToggleControll]) 373 | { 374 | new storeid[32] = "store_"; 375 | strcat(storeid, ms_Info[playerid][ms_StoreID]); 376 | CallLocalFunction(storeid, "iiiiiis", playerid, false, MSTORE_INVALID_ITEM_ID, 0, 0, 0, "N/A"); 377 | MenuStore_Close(playerid); 378 | return true; 379 | } 380 | else if(clickedid == Text:INVALID_TEXT_DRAW && !ms_Info[playerid][ms_ToggleControll]) 381 | { 382 | SelectTextDraw(playerid, MS_COLOR_SELECT_TD); 383 | return true; 384 | } 385 | 386 | if(ms_Info[playerid][ms_ToggleControll]) 387 | { 388 | if(clickedid == ms_TD_Next) 389 | { 390 | if(ms_Info[playerid][ms_CurrentPage] < MenuStore_GetNumbersOfPage(playerid)) 391 | { 392 | ms_Info[playerid][ms_CurrentPage]++; 393 | MenuStore_SetPage(playerid, ms_Info[playerid][ms_CurrentPage]); 394 | MenuStore_UnselectRow(playerid); 395 | return true; 396 | } 397 | } 398 | 399 | if(clickedid == ms_TD_Previous) 400 | { 401 | if(ms_Info[playerid][ms_CurrentPage] > 1) 402 | { 403 | ms_Info[playerid][ms_CurrentPage]--; 404 | MenuStore_SetPage(playerid, ms_Info[playerid][ms_CurrentPage]); 405 | MenuStore_UnselectRow(playerid); 406 | return true; 407 | } 408 | } 409 | 410 | if(clickedid == ms_TD_Cart_BackgroundConfirm) 411 | { 412 | if(MenuStore_GetTotalItemsInCart(playerid) != 0) 413 | { 414 | new storeid[32] = "store_", itemid; 415 | strcat(storeid, ms_Info[playerid][ms_StoreID]); 416 | 417 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 418 | { 419 | itemid = ms_Cart[playerid][ms_Cart_ItemID][i]; 420 | if(itemid != MSTORE_INVALID_ITEM_ID) 421 | { 422 | CallLocalFunction(storeid, "iiiiiis", playerid, true, itemid, MenuStore_GetItemModelByID(playerid, itemid), (ms_Cart[playerid][ms_Cart_ItemPrice][i] * ms_Cart[playerid][ms_Cart_ItemAmount][i]), ms_Cart[playerid][ms_Cart_ItemAmount][i], MenuStore_GetItemNameByID(playerid, itemid)); 423 | } 424 | } 425 | 426 | MenuStore_Close(playerid); 427 | } 428 | return true; 429 | } 430 | } 431 | 432 | #if defined MS_OnPlayerClickTextDraw 433 | return MS_OnPlayerClickTextDraw(playerid, clickedid); 434 | #else 435 | return 1; 436 | #endif 437 | } 438 | 439 | 440 | #if defined _ALS_OnPlayerClickTextDraw 441 | #undef OnPlayerClickTextDraw 442 | #else 443 | #define _ALS_OnPlayerClickTextDraw 444 | #endif 445 | #define OnPlayerClickTextDraw MS_OnPlayerClickTextDraw 446 | 447 | #if defined MS_OnPlayerClickTextDraw 448 | forward MS_OnPlayerClickTextDraw(playerid, Text:clickedid); 449 | #endif 450 | 451 | //------------------------------------------- 452 | 453 | public OnPlayerConnect(playerid) 454 | { 455 | for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++) 456 | { 457 | ms_TD_ItemName[playerid][i] = PlayerText:INVALID_TEXT_DRAW; 458 | ms_TD_ItemPrice[playerid][i] = PlayerText:INVALID_TEXT_DRAW; 459 | ms_TD_ItemModel[playerid][i] = PlayerText:INVALID_TEXT_DRAW; 460 | ms_TD_ItemBackground[playerid][i] = PlayerText:INVALID_TEXT_DRAW; 461 | } 462 | 463 | ms_TD_StoreName[playerid] = PlayerText:INVALID_TEXT_DRAW; 464 | 465 | ms_TD_DescriptionItemName[playerid] = PlayerText:INVALID_TEXT_DRAW; 466 | ms_TD_DescriptionItemText[playerid] = PlayerText:INVALID_TEXT_DRAW; 467 | ms_TD_DescriptionItemModel[playerid] = PlayerText:INVALID_TEXT_DRAW; 468 | ms_TD_DescriptionBackground[playerid][0] = PlayerText:INVALID_TEXT_DRAW; 469 | ms_TD_DescriptionBackground[playerid][1] = PlayerText:INVALID_TEXT_DRAW; 470 | 471 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 472 | { 473 | ms_TD_Cart_ItemBackground[playerid][i] = PlayerText:INVALID_TEXT_DRAW; 474 | ms_TD_Cart_ItemName[playerid][i] = PlayerText:INVALID_TEXT_DRAW; 475 | ms_TD_Cart_ItemClose[playerid][i] = PlayerText:INVALID_TEXT_DRAW; 476 | } 477 | 478 | ms_TD_Cart_BuyName[playerid] = PlayerText:INVALID_TEXT_DRAW; 479 | ms_TD_Cart_Total[playerid] = PlayerText:INVALID_TEXT_DRAW; 480 | 481 | MenuStore_ResetVariables(playerid); 482 | 483 | #if defined MS_OnPlayerConnect 484 | return MS_OnPlayerConnect(playerid); 485 | #else 486 | return 1; 487 | #endif 488 | } 489 | 490 | #if defined _ALS_OnPlayerConnect 491 | #undef OnPlayerConnect 492 | #else 493 | #define _ALS_OnPlayerConnect 494 | #endif 495 | #define OnPlayerConnect MS_OnPlayerConnect 496 | 497 | #if defined MS_OnPlayerConnect 498 | forward MS_OnPlayerConnect(playerid); 499 | #endif 500 | 501 | //------------------------------------------- 502 | 503 | public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 504 | { 505 | if(dialogid == DIALOG_MSTORE) 506 | { 507 | MenuStore_ToggleControll(playerid, true); 508 | MenuStore_CloseDescription(playerid); 509 | 510 | if(!response || ms_Info[playerid][ms_Selected] == -1 || isnull(inputtext)) 511 | { 512 | MenuStore_UnselectRow(playerid); 513 | return true; 514 | } 515 | 516 | new index = ms_Info[playerid][ms_Selected]+(MS_MAX_ITEMS_PER_PAGE * (ms_Info[playerid][ms_CurrentPage] - 1)); 517 | MenuStore_UnselectRow(playerid); 518 | 519 | if(strval(inputtext) < 1 || strval(inputtext) > ms_Items[playerid][index][ms_ItemStack]) 520 | return true; 521 | 522 | MenuStore_AddToCart(playerid, ms_Items[playerid][index][ms_ItemID], ms_Items[playerid][index][ms_ItemPrice], strval(inputtext)); 523 | return true; 524 | } 525 | 526 | #if defined MS_OnDialogResponse 527 | return MS_OnDialogResponse(playerid, dialogid, response, listitem, inputtext); 528 | #else 529 | return 1; 530 | #endif 531 | } 532 | 533 | #if defined _ALS_OnDialogResponse 534 | #undef OnDialogResponse 535 | #else 536 | #define _ALS_OnDialogResponse 537 | #endif 538 | #define OnDialogResponse MS_OnDialogResponse 539 | 540 | #if defined MS_OnDialogResponse 541 | forward MS_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]); 542 | #endif 543 | 544 | //------------------------------------------- 545 | 546 | stock MenuStore_SetPage(playerid, pageid) 547 | { 548 | new Float:ms_Item_Name_Base_X = 190.000000, 549 | Float:ms_Item_Name_Base_Y = 153.933349, 550 | Float:ms_Item_Price_Base_X = 311.100158, 551 | Float:ms_Item_Price_Base_Y = 173.217605, 552 | Float:ms_Item_Model_Base_X = 158.699859, 553 | Float:ms_Item_Model_Base_Y = 156.116775, 554 | Float:ms_Item_Background_Base_X = 158.000000, 555 | Float:ms_Item_Background_Base_Y = 155.200027, 556 | lane_break = 0, 557 | Float:padding = 39.0, 558 | start_index, end_index, 559 | current_row = -1; 560 | 561 | start_index = MS_MAX_ITEMS_PER_PAGE * (pageid - 1); 562 | end_index = start_index + MS_MAX_ITEMS_PER_PAGE; 563 | 564 | if (ms_Info[playerid][ms_TotalItems] % end_index == ms_Info[playerid][ms_TotalItems]) { 565 | end_index = start_index + ms_Info[playerid][ms_TotalItems] % MS_MAX_ITEMS_PER_PAGE; 566 | } 567 | 568 | // Remove any previous 569 | for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++) 570 | { 571 | RemovePlayerTD(playerid, ms_TD_ItemBackground[playerid][i]); 572 | RemovePlayerTD(playerid, ms_TD_ItemName[playerid][i]); 573 | RemovePlayerTD(playerid, ms_TD_ItemPrice[playerid][i]); 574 | RemovePlayerTD(playerid, ms_TD_ItemModel[playerid][i]); 575 | } 576 | 577 | RemovePlayerTD(playerid, ms_TD_Pagination[playerid]); 578 | 579 | // Write 580 | for(new i = start_index; i < end_index; i++) 581 | { 582 | current_row++; 583 | 584 | if(lane_break != 0) 585 | { 586 | ms_Item_Name_Base_Y += padding; 587 | ms_Item_Price_Base_Y += padding; 588 | ms_Item_Model_Base_Y += padding; 589 | ms_Item_Background_Base_Y += padding; 590 | } 591 | 592 | ms_TD_ItemBackground[playerid][current_row] = CreatePlayerTextDrawEx(playerid, ms_Item_Background_Base_X, ms_Item_Background_Base_Y, "box", 593 | 0.000000, 3.299997, 594 | 311.000000, 22.000000, 595 | 1, 596 | -1, 597 | 1, 598 | MS_COLOR_BACKGROUND_ITEM, 599 | 0, 600 | 0, 601 | 255, 602 | 1, 603 | 1, 604 | 0, 605 | 0.0, 0.0, 0.0, 1.0, 606 | 1); 607 | 608 | ms_TD_ItemName[playerid][current_row] = CreatePlayerTextDrawEx(playerid, ms_Item_Name_Base_X, ms_Item_Name_Base_Y, ms_Items[playerid][i][ms_ItemName][0], 609 | 0.231024, 1.198331, 610 | 310.000000, 0.0, 611 | 1, 612 | MS_COLOR_TEXT_MAIN, 613 | 1, 614 | 0xffffff00, 615 | 0, 616 | 0, 617 | 255, 618 | 2, 619 | 1); 620 | 621 | format(ms_String, sizeof(ms_String), "%s%d", ms_Info[playerid][ms_MoneySign], ms_Items[playerid][i][ms_ItemPrice]); 622 | ms_TD_ItemPrice[playerid][current_row] = CreatePlayerTextDrawEx(playerid, ms_Item_Price_Base_X, ms_Item_Price_Base_Y, ms_String, 623 | 0.283500, 1.227498, 624 | 0.0, 0.0, 625 | 3, 626 | MS_COLOR_TEXT_MAIN, 627 | 0, 628 | 0, 629 | 0, 630 | 0, 631 | 255, 632 | 2, 633 | 1); 634 | 635 | ms_TD_ItemModel[playerid][current_row] = CreatePlayerTextDrawEx(playerid, ms_Item_Model_Base_X, ms_Item_Model_Base_Y, "", 636 | 0.000000, 0.000000, 637 | 29.000000, 28.000000, 638 | 1, 639 | -1, 640 | 0, 641 | 0, 642 | 0, 643 | 0, 644 | MS_COLOR_BACKGROUND_MODEL, 645 | 5, 646 | 0, 647 | ms_Items[playerid][i][ms_ItemModel], 648 | ms_Items[playerid][i][ms_ItemPreviewRot][0], ms_Items[playerid][i][ms_ItemPreviewRot][1], ms_Items[playerid][i][ms_ItemPreviewRot][2], ms_Items[playerid][i][ms_ItemPreviewRot][3]); 649 | 650 | lane_break++; 651 | 652 | PlayerTextDrawShow(playerid, ms_TD_ItemBackground[playerid][current_row]); 653 | PlayerTextDrawShow(playerid, ms_TD_ItemName[playerid][current_row]); 654 | PlayerTextDrawShow(playerid, ms_TD_ItemPrice[playerid][current_row]); 655 | PlayerTextDrawShow(playerid, ms_TD_ItemModel[playerid][current_row]); 656 | } 657 | 658 | if(ms_Info[playerid][ms_TotalItems] > MS_MAX_ITEMS_PER_PAGE) 659 | { 660 | format(ms_String, sizeof(ms_String), "%d/%d", pageid, MenuStore_GetNumbersOfPage(playerid)); 661 | ms_TD_Pagination[playerid] = CreatePlayerTextDrawEx(playerid, 232.255233, 388.983795, ms_String, 662 | 0.318008, 1.454166, 663 | 0.0, 0.0, 664 | 2, 665 | MS_COLOR_TEXT_MAIN, 666 | 0, 667 | 0, 668 | 0, 669 | 0, 670 | 255, 671 | 2, 672 | 1); 673 | 674 | PlayerTextDrawShow(playerid, ms_TD_Pagination[playerid]); 675 | } 676 | } 677 | 678 | 679 | stock MenuStore_GetNumbersOfPage(playerid) 680 | { 681 | if((ms_Info[playerid][ms_TotalItems] >= MS_MAX_ITEMS_PER_PAGE) && (ms_Info[playerid][ms_TotalItems] % MS_MAX_ITEMS_PER_PAGE) == 0) 682 | { 683 | return (ms_Info[playerid][ms_TotalItems] / MS_MAX_ITEMS_PER_PAGE); 684 | } 685 | else return (ms_Info[playerid][ms_TotalItems] / MS_MAX_ITEMS_PER_PAGE) + 1; 686 | } 687 | 688 | stock MenuStore_GetTotalItemsInCart(playerid) 689 | { 690 | static count; 691 | count = 0; 692 | 693 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 694 | if(ms_Cart[playerid][ms_Cart_ItemID][i] != MSTORE_INVALID_ITEM_ID) 695 | count++; 696 | 697 | return count; 698 | } 699 | 700 | stock MenuStore_GetCartTotalValue(playerid) 701 | { 702 | static count; 703 | count = 0; 704 | 705 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 706 | if(ms_Cart[playerid][ms_Cart_ItemID][i] != MSTORE_INVALID_ITEM_ID) 707 | count += (ms_Cart[playerid][ms_Cart_ItemPrice][i]*ms_Cart[playerid][ms_Cart_ItemAmount][i]); 708 | 709 | return count; 710 | } 711 | 712 | stock MenuStore_AddToCart(playerid, itemid, price, amount) 713 | { 714 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 715 | { 716 | if(ms_Cart[playerid][ms_Cart_ItemID][i] == MSTORE_INVALID_ITEM_ID) 717 | { 718 | ms_Cart[playerid][ms_Cart_ItemID][i] = itemid; 719 | ms_Cart[playerid][ms_Cart_ItemPrice][i] = price; 720 | ms_Cart[playerid][ms_Cart_ItemAmount][i] = amount; 721 | 722 | MenuStore_CreateCartRow(playerid, i); 723 | MenuStore_UpdateCartTotalValue(playerid); 724 | break; 725 | } 726 | } 727 | } 728 | 729 | stock MenuStore_RemoveFromCart(playerid, row) 730 | { 731 | ms_Cart[playerid][ms_Cart_ItemID][row] = MSTORE_INVALID_ITEM_ID; 732 | ms_Cart[playerid][ms_Cart_ItemPrice][row] = 0; 733 | ms_Cart[playerid][ms_Cart_ItemAmount][row] = 0; 734 | 735 | MenuStore_UpdateCartTotalValue(playerid); 736 | MenuStore_SortCart(playerid); 737 | } 738 | 739 | 740 | stock MenuStore_SortCart(playerid) 741 | { 742 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 743 | { 744 | if(ms_Cart[playerid][ms_Cart_ItemID][i] == MSTORE_INVALID_ITEM_ID) 745 | { 746 | for(new x = i; x < MS_MAX_ITEMS_CART; x++) 747 | { 748 | if(ms_Cart[playerid][ms_Cart_ItemID][x] != MSTORE_INVALID_ITEM_ID) 749 | { 750 | ms_Cart[playerid][ms_Cart_ItemID][i] = ms_Cart[playerid][ms_Cart_ItemID][x]; 751 | ms_Cart[playerid][ms_Cart_ItemPrice][i] = ms_Cart[playerid][ms_Cart_ItemPrice][x]; 752 | ms_Cart[playerid][ms_Cart_ItemAmount][i] = ms_Cart[playerid][ms_Cart_ItemAmount][x]; 753 | 754 | ms_Cart[playerid][ms_Cart_ItemID][x] = MSTORE_INVALID_ITEM_ID; 755 | ms_Cart[playerid][ms_Cart_ItemPrice][x] = 0; 756 | ms_Cart[playerid][ms_Cart_ItemAmount][x] = 0; 757 | break; 758 | } 759 | } 760 | } 761 | } 762 | 763 | MenuStore_UpdateCart(playerid); 764 | } 765 | 766 | stock MenuStore_GetItemNameByID(playerid, id) 767 | { 768 | format(ms_String, sizeof(ms_String), "N/A"); 769 | 770 | for(new i = 0; i < MS_MAX_ITEMS; i++) 771 | { 772 | if(ms_Items[playerid][i][ms_ItemID] == id) 773 | { 774 | strunpack(ms_String, ms_Items[playerid][i][ms_ItemName]); 775 | return ms_String; 776 | } 777 | } 778 | 779 | return ms_String; 780 | } 781 | 782 | stock MenuStore_GetItemModelByID(playerid, id) 783 | { 784 | for(new i = 0; i < MS_MAX_ITEMS; i++) 785 | { 786 | if(ms_Items[playerid][i][ms_ItemID] == id) 787 | { 788 | return ms_Items[playerid][i][ms_ItemModel]; 789 | } 790 | } 791 | 792 | return 0; 793 | } 794 | 795 | stock MenuStore_CreateCartRow(playerid, row) 796 | { 797 | new Float:ms_Cart_Item_Background_Base_Y = 293.883270, 798 | Float:ms_Cart_Item_ItemName_Base_Y = 294.566619, 799 | Float:ms_Cart_Item_ItemClose_Base_Y = 293.683410, 800 | Float:padding = 23.0; 801 | 802 | if(row > 0) 803 | { 804 | ms_Cart_Item_Background_Base_Y += (padding*row); 805 | ms_Cart_Item_ItemName_Base_Y += (padding*row); 806 | ms_Cart_Item_ItemClose_Base_Y += (padding*row); 807 | } 808 | 809 | ms_TD_Cart_ItemBackground[playerid][row] = CreatePlayerTextDrawEx(playerid, 344.000000, ms_Cart_Item_Background_Base_Y, "box", 810 | 0.000000, 1.550000, 811 | 505.000000, 15.000000, 812 | 1, 813 | -1, 814 | 1, 815 | MS_COLOR_CART_BACKGROUND_ITEM, 816 | 0, 817 | 0, 818 | 255, 819 | 1, 820 | 1, 821 | 0, 822 | 0.0, 0.0, 0.0, 1.0, 823 | 1); 824 | 825 | format(ms_String, sizeof(ms_String), "%dx_%s", ms_Cart[playerid][ms_Cart_ItemAmount][row], MenuStore_GetItemNameByID(playerid, ms_Cart[playerid][ms_Cart_ItemID][row])); 826 | ms_TD_Cart_ItemName[playerid][row] = CreatePlayerTextDrawEx(playerid, 345.200073, ms_Cart_Item_ItemName_Base_Y, ms_String, 827 | 0.210997, 1.169996, 828 | 506.000000, 0.0, 829 | 1, 830 | MS_COLOR_TEXT_MAIN, 831 | 1, 832 | 0xffffff00, 833 | 0, 834 | 0, 835 | 255, 836 | 2, 837 | 1); 838 | 839 | ms_TD_Cart_ItemClose[playerid][row] = CreatePlayerTextDrawEx(playerid, 501.965087, ms_Cart_Item_ItemClose_Base_Y, "X", 840 | 0.387349, 1.546665, 841 | 0.0, 0.0, 842 | 3, 843 | MS_COLOR_CART_REMOVEITEM, 844 | 0, 845 | 0, 846 | 0, 847 | 0, 848 | 255, 849 | 1, 850 | 1); 851 | 852 | PlayerTextDrawShow(playerid, ms_TD_Cart_ItemBackground[playerid][row]); 853 | PlayerTextDrawShow(playerid, ms_TD_Cart_ItemName[playerid][row]); 854 | PlayerTextDrawShow(playerid, ms_TD_Cart_ItemClose[playerid][row]); 855 | } 856 | 857 | stock MenuStore_RemoveCartRows(playerid) 858 | { 859 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 860 | { 861 | RemovePlayerTD(playerid, ms_TD_Cart_ItemBackground[playerid][i]); 862 | RemovePlayerTD(playerid, ms_TD_Cart_ItemName[playerid][i]); 863 | RemovePlayerTD(playerid, ms_TD_Cart_ItemClose[playerid][i]); 864 | } 865 | } 866 | 867 | stock MenuStore_UpdateCartTotalValue(playerid) 868 | { 869 | format(ms_String, sizeof(ms_String), ""#MS_WORD_TOTAL": %s%d", ms_Info[playerid][ms_MoneySign], MenuStore_GetCartTotalValue(playerid)); 870 | PlayerTextDrawSetString(playerid, ms_TD_Cart_Total[playerid], ms_String); 871 | } 872 | 873 | stock MenuStore_UpdateCart(playerid) 874 | { 875 | // Remove any previous 876 | MenuStore_RemoveCartRows(playerid); 877 | 878 | // Write 879 | for(new row = 0; row < MS_MAX_ITEMS_CART; row++) 880 | { 881 | if(ms_Cart[playerid][ms_Cart_ItemID][row] != MSTORE_INVALID_ITEM_ID) 882 | { 883 | MenuStore_CreateCartRow(playerid, row); 884 | } 885 | } 886 | } 887 | 888 | stock MenuStore_AddItem(playerid, itemid, modelid, const name[], price, const description[] = EOS, Float:description_size = 0.0, bool:description_line_jump = true, stack = 1, Float:rotX = 0.0, Float:rotY = 0.0, Float:rotZ = 0.0, Float:zoom = 1.0) 889 | { 890 | for(new i = 0; i < MS_MAX_ITEMS; i++) 891 | if(ms_Items[playerid][i][ms_ItemID] == itemid) 892 | return false; 893 | 894 | for(new i = 0; i < MS_MAX_ITEMS; i++) 895 | { 896 | if(ms_Items[playerid][i][ms_ItemID] == MSTORE_INVALID_ITEM_ID) 897 | { 898 | ms_Items[playerid][i][ms_ItemID] = itemid; 899 | ms_Items[playerid][i][ms_ItemModel] = modelid; 900 | ms_Items[playerid][i][ms_ItemPrice] = price; 901 | ms_Items[playerid][i][ms_ItemStack] = stack; 902 | 903 | strpack(ms_Items[playerid][i][ms_ItemName], name, 32 char); 904 | strpack(ms_Items[playerid][i][ms_ItemDescription], description, 256 char); 905 | 906 | if(description_size > MS_MAX_SIZE_DESCRIPTION) { 907 | ms_Items[playerid][i][ms_ItemDescriptionBonus] = MS_MAX_SIZE_DESCRIPTION; 908 | } 909 | else { 910 | ms_Items[playerid][i][ms_ItemDescriptionBonus] = description_size; 911 | } 912 | 913 | ms_Items[playerid][i][ms_ItemLineJump] = description_line_jump; 914 | 915 | ms_Items[playerid][i][ms_ItemPreviewRot][0] = rotX; 916 | ms_Items[playerid][i][ms_ItemPreviewRot][1] = rotY; 917 | ms_Items[playerid][i][ms_ItemPreviewRot][2] = rotZ; 918 | ms_Items[playerid][i][ms_ItemPreviewRot][3] = zoom; 919 | 920 | ms_Info[playerid][ms_TotalItems]++; 921 | break; 922 | } 923 | } 924 | 925 | return true; 926 | } 927 | 928 | 929 | stock MenuStore_Open(playerid, const menuid[], const store_name[], const money_sign[] = MS_DEFAULT_MONEY_SIGN, const button_confirm[] = MS_DEFAULT_CONFIRM) 930 | { 931 | if(MenuStore_IsOpen(playerid)) 932 | return false; 933 | 934 | SelectTextDraw(playerid, MS_COLOR_SELECT_TD); 935 | ms_Info[playerid][ms_IsOpen] = true; 936 | format(ms_Info[playerid][ms_MoneySign], 32, money_sign); 937 | format(ms_Info[playerid][ms_StoreID], 32, menuid); 938 | 939 | TextDrawShowForPlayer(playerid, ms_TD_Backgrounds[0]); 940 | TextDrawShowForPlayer(playerid, ms_TD_Backgrounds[1]); 941 | 942 | ms_TD_StoreName[playerid] = CreatePlayerTextDrawEx(playerid, 150.843780, 129.850082, store_name, 943 | 0.310358, 1.434999, 944 | 315.000000, 0.0, 945 | 1, 946 | MS_COLOR_TEXT_MAIN, 947 | 1, 948 | 0, 949 | 0, 950 | 0, 951 | 255, 952 | 2, 953 | 1); 954 | 955 | if(ms_Info[playerid][ms_TotalItems] > MS_MAX_ITEMS_PER_PAGE) 956 | { 957 | TextDrawShowForPlayer(playerid, ms_TD_Previous); 958 | TextDrawShowForPlayer(playerid, ms_TD_Next); 959 | } 960 | 961 | PlayerTextDrawShow(playerid, ms_TD_StoreName[playerid]); 962 | 963 | // Cart 964 | 965 | format(ms_String, sizeof(ms_String), ""#MS_WORD_TOTAL": %s0", ms_Info[playerid][ms_MoneySign]); 966 | ms_TD_Cart_Total[playerid] = CreatePlayerTextDrawEx(playerid, 339.200012, 386.949951, ms_String, 967 | 0.219999, 1.331665, 968 | 437.000000, 0.0, 969 | 1, 970 | MS_COLOR_TEXT_MAIN, 971 | 1, 972 | 0xffffff00, 973 | 0, 974 | 0, 975 | 255, 976 | 2, 977 | 1); 978 | 979 | ms_TD_Cart_BuyName[playerid] = CreatePlayerTextDrawEx(playerid, 476.000152, 386.683441, button_confirm, 980 | 0.282000, 1.442499, 981 | 0.000000, 61.000000, 982 | 2, 983 | MS_COLOR_TEXT_MAIN, 984 | 1, 985 | 0xffffff00, 986 | 0, 987 | 0, 988 | 255, 989 | 2, 990 | 1); 991 | 992 | TextDrawShowForPlayer(playerid, ms_TD_Cart_Backgrounds[0]); 993 | TextDrawShowForPlayer(playerid, ms_TD_Cart_Backgrounds[1]); 994 | TextDrawShowForPlayer(playerid, ms_TD_Cart_BackgroundConfirm); 995 | TextDrawShowForPlayer(playerid, ms_TD_Cart_CartName); 996 | 997 | PlayerTextDrawShow(playerid, ms_TD_Cart_BuyName[playerid]); 998 | PlayerTextDrawShow(playerid, ms_TD_Cart_Total[playerid]); 999 | 1000 | ms_Info[playerid][ms_CurrentPage] = 1; 1001 | MenuStore_SetPage(playerid, ms_Info[playerid][ms_CurrentPage]); 1002 | return true; 1003 | } 1004 | 1005 | stock MenuStore_Close(playerid) 1006 | { 1007 | MenuStore_ResetVariables(playerid); 1008 | 1009 | CancelSelectTextDraw(playerid); 1010 | MenuStore_UnselectRow(playerid); 1011 | MenuStore_CloseDescription(playerid); 1012 | 1013 | TextDrawHideForPlayer(playerid, ms_TD_Backgrounds[0]); 1014 | TextDrawHideForPlayer(playerid, ms_TD_Backgrounds[1]); 1015 | TextDrawHideForPlayer(playerid, ms_TD_Previous); 1016 | TextDrawHideForPlayer(playerid, ms_TD_Next); 1017 | 1018 | RemovePlayerTD(playerid, ms_TD_StoreName[playerid]); 1019 | 1020 | // Cart TextDraws 1021 | 1022 | TextDrawHideForPlayer(playerid, ms_TD_Cart_Backgrounds[0]); 1023 | TextDrawHideForPlayer(playerid, ms_TD_Cart_Backgrounds[1]); 1024 | TextDrawHideForPlayer(playerid, ms_TD_Cart_BackgroundConfirm); 1025 | TextDrawHideForPlayer(playerid, ms_TD_Cart_CartName); 1026 | 1027 | RemovePlayerTD(playerid, ms_TD_Cart_BuyName[playerid]); 1028 | RemovePlayerTD(playerid, ms_TD_Cart_Total[playerid]); 1029 | 1030 | for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++) 1031 | { 1032 | RemovePlayerTD(playerid, ms_TD_ItemBackground[playerid][i]); 1033 | RemovePlayerTD(playerid, ms_TD_ItemName[playerid][i]); 1034 | RemovePlayerTD(playerid, ms_TD_ItemPrice[playerid][i]); 1035 | RemovePlayerTD(playerid, ms_TD_ItemModel[playerid][i]); 1036 | } 1037 | 1038 | RemovePlayerTD(playerid, ms_TD_Pagination[playerid]); 1039 | 1040 | MenuStore_RemoveCartRows(playerid); 1041 | 1042 | } 1043 | 1044 | stock MenuStore_IsOpen(playerid) 1045 | return ms_Info[playerid][ms_IsOpen]; 1046 | 1047 | 1048 | stock MenuStore_SelectRow(playerid, row) 1049 | { 1050 | ms_Info[playerid][ms_Selected] = row; 1051 | 1052 | PlayerTextDrawBoxColor(playerid, ms_TD_ItemBackground[playerid][row], MS_COLOR_BACKGROUND_ITEMSELECTED); 1053 | PlayerTextDrawHide(playerid, ms_TD_ItemBackground[playerid][row]); 1054 | PlayerTextDrawShow(playerid, ms_TD_ItemBackground[playerid][row]); 1055 | } 1056 | 1057 | stock MenuStore_UnselectRow(playerid) 1058 | { 1059 | if(ms_Info[playerid][ms_Selected] != -1) 1060 | { 1061 | new row = ms_Info[playerid][ms_Selected]; 1062 | PlayerTextDrawBoxColor(playerid, ms_TD_ItemBackground[playerid][row], MS_COLOR_BACKGROUND_ITEM); 1063 | PlayerTextDrawHide(playerid, ms_TD_ItemBackground[playerid][row]); 1064 | PlayerTextDrawShow(playerid, ms_TD_ItemBackground[playerid][row]); 1065 | } 1066 | 1067 | ms_Info[playerid][ms_Selected] = -1; 1068 | } 1069 | 1070 | stock MenuStore_ToggleControll(playerid, bool:toggle) 1071 | return ms_Info[playerid][ms_ToggleControll] = toggle; 1072 | 1073 | 1074 | stock MenuStore_OpenDescription(playerid, index) 1075 | { 1076 | if(ms_Info[playerid][ms_Selected] == -1) 1077 | return false; 1078 | 1079 | if(ms_TD_DescriptionItemModel[playerid] == PlayerText:INVALID_TEXT_DRAW) 1080 | { 1081 | ms_TD_DescriptionBackground[playerid][0] = CreatePlayerTextDrawEx(playerid, 333.100463, 130.980590, "box", 1082 | 0.000000, (6.630985+ms_Items[playerid][index][ms_ItemDescriptionBonus]), 1083 | 516.000000, 0.000000, 1084 | 1, 1085 | -1, 1086 | 1, 1087 | MS_COLOR_DESCRIPTION_BACKGROUND_1, 1088 | 0, 1089 | 0, 1090 | 255, 1091 | 1, 1092 | 1); 1093 | 1094 | ms_TD_DescriptionBackground[playerid][1] = CreatePlayerTextDrawEx(playerid, 335.215118, 133.416717, "box", 1095 | 0.000000, (6.111274+ms_Items[playerid][index][ms_ItemDescriptionBonus]), 1096 | 514.000000, 0.000000, 1097 | 1, 1098 | -1, 1099 | 1, 1100 | MS_COLOR_DESCRIPTION_BACKGROUND_2, 1101 | 0, 1102 | 0, 1103 | 255, 1104 | 1, 1105 | 1); 1106 | 1107 | ms_TD_DescriptionItemName[playerid] = CreatePlayerTextDrawEx(playerid, 336.807769, 134.333419, ms_Items[playerid][index][ms_ItemName], 1108 | 0.225572, 1.349166, 1109 | 514.000000, 0.0, 1110 | 1, 1111 | MS_COLOR_DESCRIPTION_NAMEITEM, 1112 | 1, 1113 | 0xffffff00, 1114 | 0, 1115 | 0, 1116 | 255, 1117 | 2, 1118 | 1); 1119 | 1120 | new Float:description_text_size_y = 460.000000, 1121 | Float:description_text_size_x = 0.000000; 1122 | 1123 | if(!ms_Items[playerid][index][ms_ItemLineJump]) 1124 | description_text_size_y = 513.000000; 1125 | 1126 | ms_TD_DescriptionItemText[playerid] = CreatePlayerTextDrawEx(playerid, 336.981842, 147.783721, ms_Items[playerid][index][ms_ItemDescription], 1127 | 0.199804, 1.098332, 1128 | description_text_size_y, description_text_size_x, 1129 | 1, 1130 | MS_COLOR_DESCRIPTION_TEXT, 1131 | 1, 1132 | 0xffffff00, 1133 | 0, 1134 | 0, 1135 | 255, 1136 | 2, 1137 | 1); 1138 | 1139 | ms_TD_DescriptionItemModel[playerid] = CreatePlayerTextDrawEx(playerid, 460.658721, 135.700027, "", 1140 | 0.000000, 0.000000, 1141 | 52.000000, 51.000000, 1142 | 1, 1143 | -1, 1144 | 0, 1145 | 0, 1146 | 0, 1147 | 0, 1148 | MS_COLOR_DESCRIPTION_BACKGROUND_MODEL, 1149 | 5, 1150 | 0, 1151 | ms_Items[playerid][index][ms_ItemModel], 1152 | ms_Items[playerid][index][ms_ItemPreviewRot][0], ms_Items[playerid][index][ms_ItemPreviewRot][1], ms_Items[playerid][index][ms_ItemPreviewRot][2], ms_Items[playerid][index][ms_ItemPreviewRot][3]); 1153 | } 1154 | else 1155 | { 1156 | PlayerTextDrawHide(playerid, ms_TD_DescriptionItemName[playerid]); 1157 | PlayerTextDrawHide(playerid, ms_TD_DescriptionItemText[playerid]); 1158 | PlayerTextDrawHide(playerid, ms_TD_DescriptionItemModel[playerid]); 1159 | 1160 | PlayerTextDrawSetPreviewModel(playerid, ms_TD_DescriptionItemModel[playerid], ms_Items[playerid][index][ms_ItemModel]); 1161 | PlayerTextDrawSetPreviewRot(playerid, ms_TD_DescriptionItemModel[playerid], ms_Items[playerid][index][ms_ItemPreviewRot][0], ms_Items[playerid][index][ms_ItemPreviewRot][1], ms_Items[playerid][index][ms_ItemPreviewRot][2], ms_Items[playerid][index][ms_ItemPreviewRot][3]); 1162 | 1163 | PlayerTextDrawSetString(playerid, ms_TD_DescriptionItemName[playerid], ms_Items[playerid][index][ms_ItemName][0]); 1164 | PlayerTextDrawSetString(playerid, ms_TD_DescriptionItemText[playerid], ms_Items[playerid][index][ms_ItemDescription][0]); 1165 | 1166 | new Float:description_text_size_y = 460.000000, 1167 | Float:description_text_size_x = 0.000000; 1168 | 1169 | if(!ms_Items[playerid][index][ms_ItemLineJump]) 1170 | description_text_size_y = 513.000000; 1171 | 1172 | PlayerTextDrawTextSize(playerid, ms_TD_DescriptionItemText[playerid], description_text_size_y, description_text_size_x); 1173 | 1174 | PlayerTextDrawLetterSize(playerid, ms_TD_DescriptionBackground[playerid][0], 0.000000, (6.630985+ms_Items[playerid][index][ms_ItemDescriptionBonus])); 1175 | PlayerTextDrawLetterSize(playerid, ms_TD_DescriptionBackground[playerid][1], 0.000000, (6.111274+ms_Items[playerid][index][ms_ItemDescriptionBonus])); 1176 | } 1177 | 1178 | PlayerTextDrawShow(playerid, ms_TD_DescriptionBackground[playerid][0]); 1179 | PlayerTextDrawShow(playerid, ms_TD_DescriptionBackground[playerid][1]); 1180 | PlayerTextDrawShow(playerid, ms_TD_DescriptionItemName[playerid]); 1181 | PlayerTextDrawShow(playerid, ms_TD_DescriptionItemText[playerid]); 1182 | PlayerTextDrawShow(playerid, ms_TD_DescriptionItemModel[playerid]); 1183 | return true; 1184 | } 1185 | 1186 | stock MenuStore_CloseDescription(playerid) 1187 | { 1188 | RemovePlayerTD(playerid, ms_TD_DescriptionBackground[playerid][0]); 1189 | RemovePlayerTD(playerid, ms_TD_DescriptionBackground[playerid][1]); 1190 | RemovePlayerTD(playerid, ms_TD_DescriptionItemName[playerid]); 1191 | RemovePlayerTD(playerid, ms_TD_DescriptionItemText[playerid]); 1192 | RemovePlayerTD(playerid, ms_TD_DescriptionItemModel[playerid]); 1193 | } 1194 | 1195 | 1196 | stock MenuStore_ResetVariables(playerid) 1197 | { 1198 | for(new i = 0; i < MS_MAX_ITEMS; i++) 1199 | { 1200 | ms_Items[playerid][i][ms_ItemID] = MSTORE_INVALID_ITEM_ID; 1201 | ms_Items[playerid][i][ms_ItemModel] = 0; 1202 | ms_Items[playerid][i][ms_ItemPrice] = 0; 1203 | ms_Items[playerid][i][ms_ItemStack] = 0; 1204 | ms_Items[playerid][i][ms_ItemName][0] = EOS; 1205 | ms_Items[playerid][i][ms_ItemDescription][0] = EOS; 1206 | ms_Items[playerid][i][ms_ItemPreviewRot][0] = ms_Items[playerid][i][ms_ItemPreviewRot][1] = ms_Items[playerid][i][ms_ItemPreviewRot][2] = ms_Items[playerid][i][ms_ItemPreviewRot][3] = 0.0; 1207 | ms_Items[playerid][i][ms_ItemLineJump] = true; 1208 | ms_Items[playerid][i][ms_ItemDescriptionBonus] = 0.0; 1209 | } 1210 | 1211 | for(new i = 0; i < MS_MAX_ITEMS_CART; i++) 1212 | { 1213 | ms_Cart[playerid][ms_Cart_ItemID][i] = MSTORE_INVALID_ITEM_ID; 1214 | ms_Cart[playerid][ms_Cart_ItemPrice][i] = 0; 1215 | ms_Cart[playerid][ms_Cart_ItemAmount][i] = 0; 1216 | } 1217 | 1218 | ms_Info[playerid][ms_TotalItems] = 0; 1219 | ms_Info[playerid][ms_CurrentPage] = 1; 1220 | ms_Info[playerid][ms_IsOpen] = false; 1221 | ms_Info[playerid][ms_StoreID][0] = EOS; 1222 | ms_Info[playerid][ms_MoneySign][0] = EOS; 1223 | ms_Info[playerid][ms_DoubleClickRow] = -1; 1224 | ms_Info[playerid][ms_DoubleClick] = 0; 1225 | ms_Info[playerid][ms_Selected] = -1; 1226 | ms_Info[playerid][ms_ToggleControll] = true; 1227 | } 1228 | 1229 | 1230 | static stock RemovePlayerTD(playerid, &PlayerText:td) 1231 | { 1232 | if(td == PlayerText:INVALID_TEXT_DRAW) 1233 | return false; 1234 | 1235 | PlayerTextDrawHide(playerid, td); 1236 | PlayerTextDrawDestroy(playerid, td); 1237 | td = PlayerText:INVALID_TEXT_DRAW; 1238 | return true; 1239 | } 1240 | 1241 | static stock PlayerText:CreatePlayerTextDrawEx(playerid, Float:x, Float:y, const text[], 1242 | Float:size_x, Float:size_y, 1243 | Float:textsize_x, Float:textsize_y, 1244 | align, 1245 | color, 1246 | usebox, 1247 | boxcolor, 1248 | shadow, 1249 | outline, 1250 | bg_color, 1251 | font, 1252 | proportional, 1253 | model = 0, 1254 | Float:preview_x= 0.0, Float:preview_y = 0.0, Float:preview_z = 0.0, Float:preview_zoom = 1.0, 1255 | selectable = 0) 1256 | { 1257 | new PlayerText:td; 1258 | td = CreatePlayerTextDraw(playerid, x, y, text); 1259 | PlayerTextDrawLetterSize(playerid, td, size_x, size_y); 1260 | PlayerTextDrawTextSize(playerid, td, textsize_x, textsize_y); 1261 | PlayerTextDrawAlignment(playerid, td, align); 1262 | PlayerTextDrawColor(playerid, td, color); 1263 | PlayerTextDrawUseBox(playerid, td, usebox); 1264 | PlayerTextDrawBoxColor(playerid, td, boxcolor); 1265 | PlayerTextDrawSetShadow(playerid, td, shadow); 1266 | PlayerTextDrawSetOutline(playerid, td, outline); 1267 | PlayerTextDrawBackgroundColor(playerid, td, bg_color); 1268 | PlayerTextDrawFont(playerid, td, font); 1269 | PlayerTextDrawSetProportional(playerid, td, proportional); 1270 | PlayerTextDrawSetPreviewModel(playerid, td, model); 1271 | PlayerTextDrawSetPreviewRot(playerid, td, preview_x, preview_y, preview_z, preview_zoom); 1272 | PlayerTextDrawSetSelectable(playerid, td, selectable); 1273 | return td; 1274 | } 1275 | 1276 | static stock Text:CreateTextDrawEx(Float:x, Float:y, const text[], 1277 | Float:size_x, Float:size_y, 1278 | Float:textsize_x, Float:textsize_y, 1279 | align, 1280 | color, 1281 | usebox, 1282 | boxcolor, 1283 | shadow, 1284 | outline, 1285 | bg_color, 1286 | font, 1287 | proportional, 1288 | model = 0, 1289 | Float:preview_x = 0.0, Float:preview_y = 0.0, Float:preview_z = 0.0, Float:preview_zoom = 0.0, 1290 | selectable = 0) 1291 | { 1292 | new Text:td; 1293 | td = TextDrawCreate(x, y, text); 1294 | TextDrawLetterSize(td, size_x, size_y); 1295 | TextDrawTextSize(td, textsize_x, textsize_y); 1296 | TextDrawAlignment(td, align); 1297 | TextDrawColor(td, color); 1298 | TextDrawUseBox(td, usebox); 1299 | TextDrawBoxColor(td, boxcolor); 1300 | TextDrawSetShadow(td, shadow); 1301 | TextDrawSetOutline(td, outline); 1302 | TextDrawBackgroundColor(td, bg_color); 1303 | TextDrawFont(td, font); 1304 | TextDrawSetProportional(td, proportional); 1305 | TextDrawSetPreviewModel(td, model); 1306 | TextDrawSetPreviewRot(td, preview_x, preview_y, preview_z, preview_zoom); 1307 | TextDrawSetSelectable(td, selectable); 1308 | return td; 1309 | } 1310 | --------------------------------------------------------------------------------