SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Includes (https://forum.sa-mp.com/forumdisplay.php?f=83)
-   -   [Include] MenuStore (Build dynamic stores with TextDraws) (https://forum.sa-mp.com/showthread.php?t=644913)

CaioTJF 16/11/2017 03:40 PM

MenuStore (Build dynamic stores with TextDraws)
 
MenuStore.inc

This include allows you to create many types of stores using Textdraws.

Demonstration

https://i.imgur.com/gH1k6t4.jpg

Click on the image to see the video.

Functions

PHP Code:

stock MenuStore_AddItem(playeriditemidmodelidname[], pricedescription[] = EOSFloat:description_size 0.0bool:description_line_jump truestack 1Float:rotX 0.0Float:rotY 0.0Float:rotZ 0.0Float:zoom 1.0

  • "itemid" - Item ID, will serve as "key", each item must have unique ID.
  • "modelid" - Model of the item that will be displayed in the preview.
  • "name" - Item name.
  • "price" - Item price.
  • "description" - Item description.
  • "Float:description_size" - Increase description box, value default is 0.0.
  • "bool:description_line_jump" - Automatic line break or not
  • "stack" - Above 1, the item can be stacked in the cart.
  • "rotX", "rotY", "rotZ" - Preview Rotation.
  • "Float:zoom " - Preview Zoom.

PHP Code:

stock MenuStore_Open(playeridmenuid[], store_name[], money_sign[] = MS_DEFAULT_MONEY_SIGNbutton_confirm[] = MS_DEFAULT_CONFIRM

  • "menuid" - It works just like easyDialog, you can by any name without having to define it.
  • "store_name" - Store name.
  • "money_sign" - Money sign, the default is "$"
  • "button_confirm" - Name of the confirm button, the default value is "Buy".


Code Example

PHP Code:


if(strcmp(cmd"/store"true) == 0)
{
    
MenuStore_AddItem(playerid1342"Granade"500"Throw to explode."200);
    
MenuStore_AddItem(playerid2344"Molotov"500"Throw to set fire to something."200);
    
MenuStore_AddItem(playerid3346"9mm Pistol"500"Pistol with low firepower.");
    
MenuStore_AddItem(playerid4347"Silenced 9mm"500"Pistol with low firepower.");
    
MenuStore_AddItem(playerid5348"Desert Eagle"500"Pistol with high firepower.");
    
MenuStore_AddItem(playerid6349"Shotgun"500"Normal Shotgun.");
    
MenuStore_AddItem(playerid7350"Sawnoff Shotgun"500"Powerfull Shotgun.");
    
MenuStore_AddItem(playerid8351"Combat Shotgun"500"Powerfull Shotgun.");
    
MenuStore_AddItem(playerid9352"Micro SMG"500"Two-handed machine gun.");
    
MenuStore_AddItem(playerid10353"MP5"500"Machine gun.");
    
MenuStore_AddItem(playerid11355"AK-47"500"Powerfull Rifle.");
    
MenuStore_AddItem(playerid12356"M4"500"Powerfull Rifle.");
    
MenuStore_AddItem(playerid13372"Tec-9"500"Powerfull machine gun.");
    
MenuStore_AddItem(playerid14357"Country Rifle"500"Normal Rifle.");
    
MenuStore_AddItem(playerid15358"Sniper Rifle"500"Powerfull Rifle.");
    
MenuStore_Show(playeridWeapon_Shop"Shop Weapons");
    return 
1;
}

Store:Weapon_Shop(playeridresponseitemidmodelidpriceamountitemname[])
{
    if(!
response)
        return 
true;

    if(
GetPlayerMoney(playerid) < price)
        return 
SendClientMessage(playerid, -1"You don't have enough money.");

    if(
amount == 1) {
        
GivePlayerWeapon(playeridGetWeaponIDFromModel(modelid), 200);
    }
    else {
        
GivePlayerWeapon(playeridGetWeaponIDFromModel(modelid), amount);
    }
    
    new 
string[128];
    
format(string128"You bought %dx %s"amountitemname);
    
SendClientMessage(playerid, -1string);
    
    
GivePlayerMoney(playerid, -price);
    return 
true;
}

stock GetWeaponIDFromModel(modelid)
{
    new 
idweapon;
    switch(
modelid)
    {
        case 
331idweapon 1// Brass Knuckles
        
case 333idweapon 2// Golf Club
        
case 334idweapon 3// Nightstick
        
case 335idweapon 4// Knife
        
case 336idweapon 5// Baseball Bat
        
case 337idweapon 6// Shovel
        
case 338idweapon 7// Pool Cue
        
case 339idweapon 8// Katana
           
case 341idweapon 9// Chainsaw
           
case 321idweapon 10// Double-ended Dildo
           
case 325idweapon 14// Flowers
           
case 326idweapon 15// Cane
           
case 342idweapon 16// Grenade
           
case 343idweapon 17// Tear Gas
        
case 344idweapon 18// Molotov Cocktail
        
case 346idweapon 22// 9mm
        
case 347idweapon 23// Silenced 9mm
        
case 348idweapon 24// Desert Eagle
        
case 349idweapon 25// Shotgun
        
case 350idweapon 26// Sawnoff
        
case 351idweapon 27// Combat Shotgun
        
case 352idweapon 28// Micro SMG/Uzi
        
case 353idweapon 29// MP5
        
case 355idweapon 30// AK-47
        
case 356idweapon 31// M4
        
case 372idweapon 32// Tec-9
        
case 357idweapon 33// Country Rifle
        
case 358idweapon 34// Sniper Rifle
        
case 359idweapon 35// RPG
        
case 360idweapon 36// HS Rocket
        
case 361idweapon 37// Flamethrower
        
case 362idweapon 38// Minigun
        
case 363idweapon 39;// Satchel Charge + Detonator
        
case 365idweapon 41// Spraycan
        
case 366idweapon 42// Fire Extinguisher
        
case 367idweapon 43// Camera
    
}
    return 
idweapon;


Download

Github

Sorry for my English, it's not my native language.

Eoussama 16/11/2017 03:44 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
+Rep for the neat design!

Pottus 16/11/2017 03:50 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
You should always use global textdraws where possible there is a lot of player textdraws wasted here plus extra overhead to create them needlessly.

CaioTJF 16/11/2017 04:04 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by Pottus (Post 3956264)
You should always use global textdraws where possible there is a lot of player textdraws wasted here plus extra overhead to create them needlessly.

The include uses 53 Player Textdraws, and they are destroyed when MenuStore_Close () is called.

That is, with the menu open there are still 203 spaces of textdraws.

This will only give you trouble if you create 203 textdraws at the same time WITH the menu open. But maybe I do an update by changing that.

ExTaZZ69 16/11/2017 04:11 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Just convert the static ones to global (that black and gray backgrounds, arrows, etc).

CaioTJF 16/11/2017 04:26 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by ExTaZZ69 (Post 3956274)
Just convert the static ones to global (that black and gray backgrounds, arrows, etc).

Next update I'll do it :)

HydraHumza 16/11/2017 05:29 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Looks promising. Keep up the good work. REP+

CaioTJF 17/11/2017 05:18 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Version 3.0

- Some PlayerTDs have been transformed into GlobalTDs
- Fixed bugs

PT 17/11/2017 06:18 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
I think Pottus will be happy now.

Nice work by the way

Freaksken 17/11/2017 09:39 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Good job!

Xeon™ 17/11/2017 09:57 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Some people doesn't know even what is dynamic (Dynamic mysql connection, dynamic stores, dynamic npc creator)
:picard:

Anyways, the text draws are nice, good job

nG Inverse 17/11/2017 10:06 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by Xeon™ (Post 3956914)
Some people doesn't know even what is dynamic (Dynamic mysql connection, dynamic stores, dynamic npc creator)
:picard:

Anyways, the text draws are nice, good job

This is dynamic. So not sure what you're talking about...

On topic; Great job! I love the design. I will put this to use.

Pottus 18/11/2017 04:53 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by PT (Post 3956783)
I think Pottus will be happy now.

Nice work by the way

It is good practice now his next release he knows what to do :)

4-stars from me it's good.

cuber 18/11/2017 04:58 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Good job!

Xeon™ 19/11/2017 03:59 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by nG Inverse (Post 3956917)
This is dynamic. So not sure what you're talking about...

On topic; Great job! I love the design. I will put this to use.

what the dynamic thing on it? what is dynamic?

DanDRT 19/11/2017 07:58 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
@Xeon - Dude, the definition of dynamic isn't so closed as you think, open your mind and don't be a idiot with the people.

Good job, Caio! +REP

xiaoniao 21/11/2017 01:54 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Very nice design, keep update

CaioTJF 21/11/2017 05:42 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Update 4.0

- Now using strpack in strings
- Now you can increase the size of the description BOX
- Now you can choose whether to automatically break line in the description or not

Exemple

https://i.imgur.com/9xY94OG.jpg

Sellize 01/12/2017 10:10 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
I really, really appreciate this. This is so awesome and it looks great.

Thank you!

edit: server seems to crash after OnPlayerSpawn, any idea why this happens?

edit2: crashdetect log:

Code:

[12:30:53] [debug] Server crashed while executing script.amx
[12:30:53] [debug] AMX backtrace:
[12:30:53] [debug] #0 native CallLocalFunction () [004743b0] from samp-server.exe
[12:30:53] [debug] #1 00008bec in ?? (0x00000000, 0x00001b5b, 0x00000001, 0xffffffff, 0x04d02218, 0x00000001, 0x00000000, 0x00000000, 0x00000014, 0x00000000, ... <1073741813 arguments>) from script.amx
[12:30:53] [debug] #2 00020f58 in public OnDialogResponse (0x00000000, 0x00001b5b, 0x00000001, 0xffffffff, 0x04d02218) from script.amx


Gforcez 01/12/2017 11:08 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by DanDRT (Post 3957832)
@Xeon - Dude, the definition of dynamic isn't so closed as you think, open your mind and don't be a idiot with the people.

Good job, Caio! +REP

Xeon means, you have to recompile and restart the script to change the stores. His definition of dynamic is that you don't have to recompile or restart the server for the stores (in this context) to change, storing the values in a database for example and reading those values whenever you show the shop textdraws.

OT: This looks pretty nice. Good job! This can be very useful and a nice replacement for 'dialog stores'.

CaioTJF 01/12/2017 03:05 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by Sellize (Post 3961814)
I really, really appreciate this. This is so awesome and it looks great.

Thank you!

edit: server seems to crash after OnPlayerSpawn, any idea why this happens?

edit2: crashdetect log:

Code:

[12:30:53] [debug] Server crashed while executing script.amx
[12:30:53] [debug] AMX backtrace:
[12:30:53] [debug] #0 native CallLocalFunction () [004743b0] from samp-server.exe
[12:30:53] [debug] #1 00008bec in ?? (0x00000000, 0x00001b5b, 0x00000001, 0xffffffff, 0x04d02218, 0x00000001, 0x00000000, 0x00000000, 0x00000014, 0x00000000, ... <1073741813 arguments>) from script.amx
[12:30:53] [debug] #2 00020f58 in public OnDialogResponse (0x00000000, 0x00001b5b, 0x00000001, 0xffffffff, 0x04d02218) from script.amx


Thanks for reporting it, fixed.

Version 4.1 (thanks Jelly)

- Fixed crash on OnDialogResponse (CallLocalFunction removed from callbacks)
- Little adjustments

drawax 25/02/2018 06:59 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Hello!


For me it only shows 3 characters of the names and descriptions, why is that? For example it only shows "Gra" or "Mol" etc... Thanks.

GSFBart 01/05/2018 07:00 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by drawax (Post 3997276)
Hello!


For me it only shows 3 characters of the names and descriptions, why is that? For example it only shows "Gra" or "Mol" etc... Thanks.

Replace

PHP Code:

strpack(ms_Items[playerid][i][ms_ItemName], name);
strpack(ms_Items[playerid][i][ms_ItemDescription], description); 

for

PHP Code:

strpack(ms_Items[playerid][i][ms_ItemName], name32 char);
strpack(ms_Items[playerid][i][ms_ItemDescription], description256 char); 


PowerMwK 29/11/2018 09:37 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Maybe a little evolution.

TheLeech 20/01/2019 11:31 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Really nice include love the style of the stores but it does this for me in game?

http://i66.tinypic.com/30sgjg1.jpg

Code:

MenuStore_AddItem(playerid, 1, 2703, "Chicken Burger", 50, "A food item that can be consumed, Heals you +20.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 2, 2769, "Chicken Wrap", 50, "A food item that can be consumed, Heals you +20.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 3, 2768, "Double Chicken Burger", 75, "A food item that can be consumed, Heals you +40.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 4, 2703, "Burger Meal Deal", 100, "A food item that can be consumed, Heals you +60.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 5, 2814, "12inch Pizza", 150, "A food item that can be consumed, Heals you to full health.", 200, true, 0, 0, 2);
                            MenuStore_Show(playerid, Pizza_Shop, "Airport Pizza Stack");

It also doesn't update the total price at the bottom for me, Or take the money away?

CaioTJF 28/01/2019 03:36 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by TheLeech (Post 4078079)
Really nice include love the style of the stores but it does this for me in game?

http://i66.tinypic.com/30sgjg1.jpg

Code:

MenuStore_AddItem(playerid, 1, 2703, "Chicken Burger", 50, "A food item that can be consumed, Heals you +20.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 2, 2769, "Chicken Wrap", 50, "A food item that can be consumed, Heals you +20.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 3, 2768, "Double Chicken Burger", 75, "A food item that can be consumed, Heals you +40.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 4, 2703, "Burger Meal Deal", 100, "A food item that can be consumed, Heals you +60.", 200, true, 0, 0, 2);
                            MenuStore_AddItem(playerid, 5, 2814, "12inch Pizza", 150, "A food item that can be consumed, Heals you to full health.", 200, true, 0, 0, 2);
                            MenuStore_Show(playerid, Pizza_Shop, "Airport Pizza Stack");

It also doesn't update the total price at the bottom for me, Or take the money away?

Check this: https://forum.sa-mp.com/showpost.php...1&postcount=23

If this does not work, remove the strpack function

#Edit

I fixed this problem in the repository.

TheLeech 01/02/2019 07:24 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by CaioTJF (Post 4079546)
Check this: https://forum.sa-mp.com/showpost.php...1&postcount=23

If this does not work, remove the strpack function

#Edit

I fixed this problem in the repository.

Thanks, I'm having a new issue. I've used this because I like the style of menu for vehicle renting and maybe even vehicle buying but upon renting a vehicle it creates 2 vehicles not 1 and I've tried to place if(amount > 1) return 1; to stop it. This is current code.

PHP Code:

Store:RentVehicle(playeridresponseitemidmodelidpriceamountitemname[])
{
    if(!
response)
    {
        
SetPVarInt(playerid,"shopping"0);
        return 
true;
    }

    if(
GetPlayerMoneyEx(playerid) < price)
    {
        
SendClientMessage(playeridCOLOR_ORANGE"Error: You don't have enough money.");
        
SetPVarInt(playerid,"shopping"0);
        return 
true;
    }
        
    new 
vehstring[256];
    new 
sendername[MAX_PLAYER_NAME];
    for(new 
car 0car MAX_VEHICLEScar++)
    {
        if(
rcarInfo[car][Created] == 1)
        {
            if(
strcmp(rcarInfo[car][Owner], sendernametrue) == 0)
            {
                
SendClientMessage(playeridCOLOR_ORANGE"Server: You already rent a car, please use /unrentcar unrent it.");
                
GivePlayerMoneyEx(playerid500);
                return 
1;
            }
        }
    }
    
GetPlayerName(playeridsendernamesizeof(sendername));
    
veh CreateVehicle(modelid1644.9814, -2322.520013.042089.7556000);
    
SetVehicleVirtualWorldveh GetPlayerVirtualWorld(playerid)); // this does NOT return vehicle id.
    
LinkVehicleToInterior(vehGetPlayerInterior(playerid)); // I added this to be be on the safe side.
    
rcarInfo[veh][Created] = 1;
    
//VehicleInfo[veh][vType] = 3;
    
strmid(rcarInfo[veh][Owner], sendername0strlen(sendername), 255);
    
PutPlayerInVehicle(playeridveh0);
    
VehicleInfo[veh][vWindows] = 0;
    
VehicleInfo[veh][vLocked] = 0;
    
    
RemovePlayerMoneyEx(playeridprice);
    
format(string128"You have rented a %s, You will be charged every hour $%i. (Only when online)"itemnameprice);
    
SendClientMessage(playeridCOLOR_ORANGEstring);
    
SendClientMessage(playeridCOLOR_ORANGE"The car will stay until you finish renting it, use /unrentcar to despawn it");
    
SetPVarInt(playerid,"shopping"0);
    return 
true;



JeSuisUnChat 02/02/2019 08:13 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Wow, a good work.

We can't use %s, %d, in MenuStore_AddItem ?

Saddin 02/02/2019 10:53 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
It's nice UI, really useful!

Vallenci 07/02/2019 03:42 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
I can't click textdraw, why?
ver 4.2

Kasichok 07/02/2019 11:55 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
u should return 0 on text draw click callbacks otherwise the callback in other filterscripts wont be called

dannypanda05 08/04/2019 01:52 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
It does not work ):

https://oi1029.photobucket.com/album...pspvqsbemu.png

RenanMsV 08/04/2019 05:18 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
i think this menu should be smaller. about .75 ~ .5 x

Chaprnks 01/04/2020 09:19 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by CaioTJF (Post 3956260)
MenuStore.inc

I seem to have an odd bug to report with this script. When purchasing multiple items, it only processes the first item in the shopping cart. It doesn't process the other items & doesn't add them to the total amount of cash taken from the player.



EDIT:
Fixed it. The issue was calling MenuStore_Close(playerid); on the Store: callback. Looking through the code, i found out that the menu store already closes itself in the include, and doing a double call on Menu_StoreClose caused the issue.

JesterlJoker 26/04/2020 03:10 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
I don't know when you'll go online but hope you check Github, will keep in touch.

CaioTJF 27/04/2020 01:28 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by JesterlJoker (Post 4142077)
I don't know when you'll go online but hope you check Github, will keep in touch.

Done, ty=)

Sasino97 08/05/2020 06:22 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Suggestion:
In MenuStore_AddItem, add an optional data parameter defaulting to 0, in which we can put any value.
For example, in the weapon shop I would put the weapon id in it. In some other kind of shop which reads from a database, I could put the row id from the table in it. Etc...

Quote:

Originally Posted by Pottus (Post 3956264)
You should always use global textdraws where possible there is a lot of player textdraws wasted here plus extra overhead to create them needlessly.

Quote:

Originally Posted by ExTaZZ69 (Post 3956274)
Just convert the static ones to global (that black and gray backgrounds, arrows, etc).

I think there is no need, since the player textdraws are being destroyed as soon as the menu is closed, as it should be.

PrednizoN 12/05/2020 07:01 AM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Code:

C:\Users\celli\Desktop\ww3\pawno\include\wshop.inc(1258) : error 035: argument type mismatch (argument 4)
C:\Users\celli\Desktop\ww3\pawno\include\wshop.inc(1293) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664                          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

i got this 2 errors.

In inc 1258 and 1293 line;;

Code:

    td = CreatePlayerTextDraw(playerid, x, y, text);//1258
td = TextDrawCreate(x, y, text);//1293


jasperschellekens 15/05/2020 09:53 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Quote:

Originally Posted by PrednizoN (Post 4145485)
[CODE]C:\Users\celli\Desktop\ww3\pawno\include\wshop.inc (1258) : error 035: argument type mismatch (argument 4)
C:\Users\celli\Desktop\ww3\pawno\include\wshop.inc (1293) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

Wanted to use this but getting the same errors

jasperschellekens 16/05/2020 02:49 PM

Re: MenuStore (Build dynamic stores with TextDraws)
 
Since I can't reach the author of this include, I've fixed it myself:
pawn Code:
/*
    MenuStore - Version 4.2
    Created by CaioTJF
*/



/* 
    You can NOT change
*/


#define MS_MAX_ITEMS_PER_PAGE 6
#define MS_MAX_ITEMS_CART 4
#define MSTORE_INVALID_ITEM_ID -1
#define MS_MAX_SIZE_DESCRIPTION 7.5

/*
    You can change
*/


#define MS_MAX_ITEMS (MS_MAX_ITEMS_PER_PAGE*5) // --> Limit of 5 Pages
#define MS_DEFAULT_MONEY_SIGN "$"
#define MS_DEFAULT_CONFIRM "Buy"

#define MS_COLOR_SELECT_TD 0xffffffFF
#define MS_COLOR_TEXT_MAIN 0xffffffFF

#define MS_COLOR_BACKGROUND_1 0x00000080
#define MS_COLOR_BACKGROUND_2 0x2c2c2cAA
#define MS_COLOR_BACKGROUND_ITEM 0x3e3e3eFF
#define MS_COLOR_BACKGROUND_ITEMSELECTED 0xffffff50
#define MS_COLOR_BACKGROUND_CONFIRM 0x5eaf3aFF
#define MS_COLOR_BACKGROUND_MODEL 0xffffff50

#define MS_COLOR_CART_REMOVEITEM 0xcc30a0aFF
#define MS_COLOR_CART_BACKGROUND_ITEM MS_COLOR_BACKGROUND_ITEM

#define MS_COLOR_DESCRIPTION_NAMEITEM MS_COLOR_TEXT_MAIN
#define MS_COLOR_DESCRIPTION_TEXT 0xffffffAA
#define MS_COLOR_DESCRIPTION_BACKGROUND_1 MS_COLOR_BACKGROUND_1
#define MS_COLOR_DESCRIPTION_BACKGROUND_2 MS_COLOR_BACKGROUND_2
#define MS_COLOR_DESCRIPTION_BACKGROUND_MODEL 0xffffff50

#define MS_COLOR_TITLE_DIALOG "{ffffff}"
#define MS_COLOR_TEXT_DIALOG "{ffffff}"

#define MS_MSG_TITLE_DIALOG "Choose quantity"
#define MS_MSG_DIALOG "Enter the quantity you want to buy"

#define MS_WORD_LIMIT "Limit"
#define MS_WORD_CLOSE "Close"
#define MS_WORD_TOTAL "Total"
#define MS_WORD_GO "Go"
#define MS_WORD_CANCEL "Cancel"
#define MS_WORD_CART "Cart"

#define MS_INTERVAL_DOUBLECLICK 300
#define DIALOG_MSTORE 23132

//-------------------------------------------

#if !defined isnull
    #define isnull(%1) \
        ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif

#define STORE:%0(%1) \
    forward store_%0(%1); public store_%0(%1)

#define Store:%0(%1) \
    STORE:%0(%1)

#define MenuStore_Show(%0,%1, \
    MenuStore_Open(%0, #%1,

enum enum_ms_Items
{
    ms_ItemID,
    ms_ItemModel,
    ms_ItemPrice,
    ms_ItemStack,
    ms_ItemName[32 char],
    ms_ItemDescription[256 char],
    Float:ms_ItemDescriptionBonus,
    bool:ms_ItemLineJump,
    Float:ms_ItemPreviewRot[4]
}      

static ms_Items[MAX_PLAYERS][MS_MAX_ITEMS][enum_ms_Items];

enum enum_ms_Info
{
    ms_TotalItems,
    ms_CurrentPage,
    bool:ms_IsOpen,
    ms_StoreID[32],
    ms_MoneySign[32],
    ms_DoubleClick,
    ms_DoubleClickRow,
    ms_Selected,
    bool:ms_ToggleControll
}

static ms_Info[MAX_PLAYERS][enum_ms_Info];

enum enum_ms_Cart
{
    ms_Cart_ItemID[MS_MAX_ITEMS_CART],
    ms_Cart_ItemPrice[MS_MAX_ITEMS_CART],
    ms_Cart_ItemAmount[MS_MAX_ITEMS_CART]

}

static ms_Cart[MAX_PLAYERS][enum_ms_Cart];

static ms_String[256];

// -- Global Textdraws

static Text:ms_TD_Backgrounds[2] = {Text:INVALID_TEXT_DRAW, ...};
static Text:ms_TD_Next = Text:INVALID_TEXT_DRAW;
static Text:ms_TD_Previous = Text:INVALID_TEXT_DRAW;

static Text:ms_TD_Cart_Backgrounds[2] = {Text:INVALID_TEXT_DRAW, ...};
static Text:ms_TD_Cart_BackgroundConfirm = Text:INVALID_TEXT_DRAW;
static Text:ms_TD_Cart_CartName = Text:INVALID_TEXT_DRAW;

// -- Player Textdraws

static PlayerText:ms_TD_ItemName[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE];
static PlayerText:ms_TD_ItemPrice[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE];
static PlayerText:ms_TD_ItemModel[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE];
static PlayerText:ms_TD_ItemBackground[MAX_PLAYERS][MS_MAX_ITEMS_PER_PAGE];
static PlayerText:ms_TD_StoreName[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
static PlayerText:ms_TD_Pagination[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
static PlayerText:ms_TD_DescriptionItemName[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
static PlayerText:ms_TD_DescriptionItemText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
static PlayerText:ms_TD_DescriptionItemModel[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
static PlayerText:ms_TD_DescriptionBackground[MAX_PLAYERS][2];

static PlayerText:ms_TD_Cart_ItemBackground[MAX_PLAYERS][MS_MAX_ITEMS_CART];
static PlayerText:ms_TD_Cart_ItemName[MAX_PLAYERS][MS_MAX_ITEMS_CART];
static PlayerText:ms_TD_Cart_ItemClose[MAX_PLAYERS][MS_MAX_ITEMS_CART];
static PlayerText:ms_TD_Cart_BuyName[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
static PlayerText:ms_TD_Cart_Total[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};

forward PlayerText:CreatePlayerTextDrawEx(playerid, Float:x, Float:y, 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);
forward Text:CreateTextDrawEx(Float:x, Float:y, 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);

//-------------------------------------------

public OnGameModeInit()
{
    ms_TD_Backgrounds[0]  = CreateTextDrawEx(145.500000, 130.499969, "box",
                                        0.000000, 30.198539,
                                        322.000000, 0.000000,
                                        1,
                                        -1,
                                        1,
                                        MS_COLOR_BACKGROUND_1,
                                        0,
                                        0,
                                        255,
                                        1,
                                        1);

    ms_TD_Backgrounds[1] = CreateTextDrawEx(153.000000, 149.383575, "box",
                                        0.000000, 26.226503,
                                        315.000000, 0.000000,
                                        1,
                                        -1,
                                        1,
                                        MS_COLOR_BACKGROUND_2,
                                        0,
                                        0,
                                        255,
                                        1,
                                        1);

    ms_TD_Next = CreateTextDrawEx(251.485229, 390.033355, "ld_beat:right",
                            0.000000, 0.000000,
                            11.000000, 13.000000,
                            1,
                            MS_COLOR_TEXT_MAIN,
                            0,
                            0,
                            0,
                            0,
                            255,
                            4,
                            1,
                            0,
                            0.0, 0.0, 0.0, 0.0,
                            1);

    ms_TD_Previous = CreateTextDrawEx(201.945220, 390.033355, "ld_beat:left",
                                0.000000, 0.000000,
                                11.000000, 13.000000,
                                1,
                                MS_COLOR_TEXT_MAIN,
                                0,
                                0,
                                0,
                                0,
                                255,
                                4,
                                1,
                                0,
                                0.0, 0.0, 0.0, 0.0,
                                1);

    ms_TD_Cart_Backgrounds[0] = CreateTextDrawEx(333.201141, 271.666656, "box",
                                            0.000000, 14.450012,
                                            516.000000, 0.000000,
                                            1,
                                            -1,
                                            1,
                                            MS_COLOR_BACKGROUND_1,
                                            0,
                                            0,
                                            255,
                                            1,
                                            1);

    ms_TD_Cart_Backgrounds[1] = CreateTextDrawEx(341.000000, 290.133575, "box",
                                            0.000000, 10.134258,
                                            508.000000, 0.000000,
                                            1,
                                            -1,
                                            1,
                                            MS_COLOR_BACKGROUND_2,
                                            0,
                                            0,
                                            255,
                                            1,
                                            1);

    ms_TD_Cart_BackgroundConfirm = CreateTextDrawEx(444.899230, 390.233489, "box",
                                    0.000000, 0.850001,
                                    507.701690, 15.000000,
                                    1,
                                    -1,
                                    1,
                                    MS_COLOR_BACKGROUND_CONFIRM,
                                    0,
                                    0,
                                    255,
                                    1,
                                    1,
                                    0,
                                    0.0, 0.0, 0.0, 0.0,
                                    1);

    ms_TD_Cart_CartName = CreateTextDrawEx(339.143798, 270.733520, MS_WORD_CART,
                                    0.310357, 1.434998,
                                    508.000000, 0.0,
                                    1,
                                    MS_COLOR_TEXT_MAIN,
                                    1,
                                    0xffffff00,
                                    0,
                                    0,
                                    255,
                                    2,
                                    1);

    #if defined MS_OnGameModeInit
        return MS_OnGameModeInit();
    #else
        return 1;
    #endif
}

#if defined _ALS_OnGameModeInit
    #undef OnGameModeInit
#else
    #define _ALS_OnGameModeInit
#endif
#define OnGameModeInit MS_OnGameModeInit

#if defined MS_OnGameModeInit
    forward MS_OnGameModeInit();
#endif

//-------------------------------------------

public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if(ms_Info[playerid][ms_ToggleControll])
    {
        for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++)
        {
            if(playertextid == ms_TD_ItemBackground[playerid][i])
            {
                new index = i+(MS_MAX_ITEMS_PER_PAGE * (ms_Info[playerid][ms_CurrentPage] - 1));   

                // --> Doubleclick
                if((GetTickCount() - ms_Info[playerid][ms_DoubleClick]) < MS_INTERVAL_DOUBLECLICK && ms_Info[playerid][ms_DoubleClickRow] == i)
                {

                    if(ms_Items[playerid][index][ms_ItemStack] > 1)
                    {
                        MenuStore_ToggleControll(playerid, false);
                        MenuStore_SelectRow(playerid, i);
                        format(ms_String, sizeof(ms_String), ""#MS_COLOR_TEXT_DIALOG""#MS_MSG_DIALOG" ("#MS_WORD_LIMIT": %d)", ms_Items[playerid][index][ms_ItemStack]);
                        ShowPlayerDialog(playerid, DIALOG_MSTORE, DIALOG_STYLE_INPUT, ""#MS_COLOR_TITLE_DIALOG""#MS_MSG_TITLE_DIALOG":", ms_String, MS_WORD_GO, MS_WORD_CANCEL);
                    }
                    else
                    {
                        MenuStore_AddToCart(playerid, ms_Items[playerid][index][ms_ItemID], ms_Items[playerid][index][ms_ItemPrice], ms_Items[playerid][index][ms_ItemStack]);
                        MenuStore_UnselectRow(playerid);
                        MenuStore_CloseDescription(playerid);
                    }

                    ms_Info[playerid][ms_DoubleClickRow] = -1;
                    ms_Info[playerid][ms_DoubleClick] = 0;
                    return true;
                }
                else
                {
                    ms_Info[playerid][ms_DoubleClickRow] = i;
                    ms_Info[playerid][ms_DoubleClick] = GetTickCount();
                }

                if(ms_Info[playerid][ms_Selected] == i)
                {
                    MenuStore_UnselectRow(playerid);
                    MenuStore_CloseDescription(playerid);
                    return true;
                }
                else if(ms_Info[playerid][ms_Selected] != -1)
                    MenuStore_UnselectRow(playerid);

                MenuStore_SelectRow(playerid, i);
                MenuStore_OpenDescription(playerid, index);
                return true;
            }
        }

        for(new row = 0; row < MS_MAX_ITEMS_CART; row++)
        {
            if(playertextid == ms_TD_Cart_ItemBackground[playerid][row])
            {
                MenuStore_RemoveFromCart(playerid, row);
                return true;
            }
        }
    }

    #if defined MS_OnPlayerClickPlayerTD
        return MS_OnPlayerClickPlayerTD(playerid, playertextid);
    #else
        return 1;
    #endif
}


#if defined _ALS_OnPlayerClickPlayerTD
    #undef OnPlayerClickPlayerTextDraw
#else
    #define _ALS_OnPlayerClickPlayerTD
#endif
#define OnPlayerClickPlayerTextDraw MS_OnPlayerClickPlayerTD

#if defined MS_OnPlayerClickPlayerTD
    forward MS_OnPlayerClickPlayerTD(playerid, PlayerText:playertextid);
#endif

//-------------------------------------------

public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == Text:INVALID_TEXT_DRAW && MenuStore_IsOpen(playerid) && ms_Info[playerid][ms_ToggleControll])
    {
        new storeid[32] = "store_";
        strcat(storeid, ms_Info[playerid][ms_StoreID]);
        CallLocalFunction(storeid, "iiiiiis", playerid, false, MSTORE_INVALID_ITEM_ID, 0, 0, 0, "N/A");
        MenuStore_Close(playerid);
        return true;
    }
    else if(clickedid == Text:INVALID_TEXT_DRAW && !ms_Info[playerid][ms_ToggleControll])
    {
        SelectTextDraw(playerid, MS_COLOR_SELECT_TD);
        return true;
    }

    if(ms_Info[playerid][ms_ToggleControll])
    {
        if(clickedid == ms_TD_Next)
        {
            if(ms_Info[playerid][ms_CurrentPage] < MenuStore_GetNumbersOfPage(playerid))
            {
                ms_Info[playerid][ms_CurrentPage]++;
                MenuStore_SetPage(playerid, ms_Info[playerid][ms_CurrentPage]);
                MenuStore_UnselectRow(playerid);
                return true;
            }
        }

        if(clickedid == ms_TD_Previous)
        {
            if(ms_Info[playerid][ms_CurrentPage] > 1)
            {
                ms_Info[playerid][ms_CurrentPage]--;
                MenuStore_SetPage(playerid, ms_Info[playerid][ms_CurrentPage]);
                MenuStore_UnselectRow(playerid);
                return true;
            }
        }

        if(clickedid == ms_TD_Cart_BackgroundConfirm)
        {
            if(MenuStore_GetTotalItemsInCart(playerid) != 0)
            {
                new storeid[32] = "store_", itemid;
                strcat(storeid, ms_Info[playerid][ms_StoreID]);

                for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
                {
                    itemid = ms_Cart[playerid][ms_Cart_ItemID][i];
                    if(itemid != MSTORE_INVALID_ITEM_ID)
                    {
                        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));
                    }
                }

                MenuStore_Close(playerid);
            }
            return true;
        }
    }

    #if defined MS_OnPlayerClickTextDraw
        return MS_OnPlayerClickTextDraw(playerid, clickedid);
    #else
        return 1;
    #endif
}


#if defined _ALS_OnPlayerClickTextDraw
    #undef OnPlayerClickTextDraw
#else
    #define _ALS_OnPlayerClickTextDraw
#endif
#define OnPlayerClickTextDraw MS_OnPlayerClickTextDraw

#if defined MS_OnPlayerClickTextDraw
    forward MS_OnPlayerClickTextDraw(playerid, Text:clickedid);
#endif

//-------------------------------------------

public OnPlayerConnect(playerid)
{
    for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++)
    {
        ms_TD_ItemName[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
        ms_TD_ItemPrice[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
        ms_TD_ItemModel[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
        ms_TD_ItemBackground[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
    }

    ms_TD_StoreName[playerid] = PlayerText:INVALID_TEXT_DRAW;

    ms_TD_DescriptionItemName[playerid] = PlayerText:INVALID_TEXT_DRAW;
    ms_TD_DescriptionItemText[playerid] = PlayerText:INVALID_TEXT_DRAW;
    ms_TD_DescriptionItemModel[playerid] = PlayerText:INVALID_TEXT_DRAW;
    ms_TD_DescriptionBackground[playerid][0] = PlayerText:INVALID_TEXT_DRAW;
    ms_TD_DescriptionBackground[playerid][1] = PlayerText:INVALID_TEXT_DRAW;
   
    for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
    {
        ms_TD_Cart_ItemBackground[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
        ms_TD_Cart_ItemName[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
        ms_TD_Cart_ItemClose[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
    }

    ms_TD_Cart_BuyName[playerid] = PlayerText:INVALID_TEXT_DRAW;
    ms_TD_Cart_Total[playerid] = PlayerText:INVALID_TEXT_DRAW;

    MenuStore_ResetVariables(playerid);

    #if defined MS_OnPlayerConnect
        return MS_OnPlayerConnect(playerid);
    #else
        return 1;
    #endif
}

#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect MS_OnPlayerConnect

#if defined MS_OnPlayerConnect
    forward MS_OnPlayerConnect(playerid);
#endif

//-------------------------------------------

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_MSTORE)
    {
        MenuStore_ToggleControll(playerid, true);
        MenuStore_CloseDescription(playerid);

        if(!response || ms_Info[playerid][ms_Selected] == -1 || isnull(inputtext))
        {
            MenuStore_UnselectRow(playerid);
            return true;
        }  

        new index = ms_Info[playerid][ms_Selected]+(MS_MAX_ITEMS_PER_PAGE * (ms_Info[playerid][ms_CurrentPage] - 1));
        MenuStore_UnselectRow(playerid);

        if(strval(inputtext) < 1 || strval(inputtext) > ms_Items[playerid][index][ms_ItemStack])
            return true;

        MenuStore_AddToCart(playerid, ms_Items[playerid][index][ms_ItemID], ms_Items[playerid][index][ms_ItemPrice], strval(inputtext));
        return true;
    }

    #if defined MS_OnDialogResponse
        return MS_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
    #else
        return 1;
    #endif
}

#if defined _ALS_OnDialogResponse
    #undef OnDialogResponse
#else
    #define _ALS_OnDialogResponse
#endif
#define OnDialogResponse MS_OnDialogResponse

#if defined MS_OnDialogResponse
    forward MS_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
#endif

//-------------------------------------------

stock MenuStore_SetPage(playerid, pageid)
{
    new Float:ms_Item_Name_Base_X = 190.000000,
        Float:ms_Item_Name_Base_Y = 153.933349,
        Float:ms_Item_Price_Base_X = 311.100158,
        Float:ms_Item_Price_Base_Y = 173.217605,
        Float:ms_Item_Model_Base_X = 158.699859,
        Float:ms_Item_Model_Base_Y = 156.116775,
        Float:ms_Item_Background_Base_X = 158.000000,
        Float:ms_Item_Background_Base_Y = 155.200027,
        lane_break = 0,
        Float:padding = 39.0,
        start_index, end_index,
        current_row = -1;

    start_index = MS_MAX_ITEMS_PER_PAGE * (pageid - 1);
    end_index = start_index + MS_MAX_ITEMS_PER_PAGE;

    if (ms_Info[playerid][ms_TotalItems] % end_index == ms_Info[playerid][ms_TotalItems]) {
        end_index = start_index + ms_Info[playerid][ms_TotalItems] % MS_MAX_ITEMS_PER_PAGE;
    }

    // Remove any previous
    for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++)
    {
        RemovePlayerTD(playerid, ms_TD_ItemBackground[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_ItemName[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_ItemPrice[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_ItemModel[playerid][i]);
    }

    RemovePlayerTD(playerid, ms_TD_Pagination[playerid]);

    // Write
    for(new i = start_index; i < end_index; i++)
    {
        current_row++;

        if(lane_break != 0)
        {
            ms_Item_Name_Base_Y += padding;
            ms_Item_Price_Base_Y += padding;
            ms_Item_Model_Base_Y += padding;
            ms_Item_Background_Base_Y += padding;
        }

        ms_TD_ItemBackground[playerid][current_row] = CreatePlayerTextDrawEx(playerid, ms_Item_Background_Base_X, ms_Item_Background_Base_Y, "box",
                                            0.000000, 3.299997,
                                            311.000000, 22.000000,
                                            1,
                                            -1,
                                            1,
                                            MS_COLOR_BACKGROUND_ITEM,
                                            0,
                                            0,
                                            255,
                                            1,
                                            1,
                                            0,
                                            0.0, 0.0, 0.0, 1.0,
                                            1);

        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],
                                        0.231024, 1.198331,
                                        310.000000, 0.0,
                                        1,
                                        MS_COLOR_TEXT_MAIN,
                                        1,
                                        0xffffff00,
                                        0,
                                        0,
                                        255,
                                        2,
                                        1);

        format(ms_String, sizeof(ms_String), "%s%d", ms_Info[playerid][ms_MoneySign], ms_Items[playerid][i][ms_ItemPrice]);
        ms_TD_ItemPrice[playerid][current_row] = CreatePlayerTextDrawEx(playerid, ms_Item_Price_Base_X, ms_Item_Price_Base_Y, ms_String,
                                        0.283500, 1.227498,
                                        0.0, 0.0,
                                        3,
                                        MS_COLOR_TEXT_MAIN,
                                        0,
                                        0,
                                        0,
                                        0,
                                        255,
                                        2,
                                        1);

        ms_TD_ItemModel[playerid][current_row] = CreatePlayerTextDrawEx(playerid, ms_Item_Model_Base_X, ms_Item_Model_Base_Y, "",
                                        0.000000, 0.000000,
                                        29.000000, 28.000000,
                                        1,
                                        -1,
                                        0,
                                        0,
                                        0,
                                        0,
                                        MS_COLOR_BACKGROUND_MODEL,
                                        5,
                                        0,
                                        ms_Items[playerid][i][ms_ItemModel],
                                        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]);

        lane_break++;

        PlayerTextDrawShow(playerid, ms_TD_ItemBackground[playerid][current_row]);
        PlayerTextDrawShow(playerid, ms_TD_ItemName[playerid][current_row]);
        PlayerTextDrawShow(playerid, ms_TD_ItemPrice[playerid][current_row]);
        PlayerTextDrawShow(playerid, ms_TD_ItemModel[playerid][current_row]);
    }

    if(ms_Info[playerid][ms_TotalItems] > MS_MAX_ITEMS_PER_PAGE)
    {
        format(ms_String, sizeof(ms_String), "%d/%d", pageid, MenuStore_GetNumbersOfPage(playerid));
        ms_TD_Pagination[playerid] = CreatePlayerTextDrawEx(playerid, 232.255233, 388.983795, ms_String,
                                0.318008, 1.454166,
                                0.0, 0.0,
                                2,
                                MS_COLOR_TEXT_MAIN,
                                0,
                                0,
                                0,
                                0,
                                255,
                                2,
                                1);

        PlayerTextDrawShow(playerid, ms_TD_Pagination[playerid]);
    }
}


 stock MenuStore_GetNumbersOfPage(playerid)
 {
    if((ms_Info[playerid][ms_TotalItems] >= MS_MAX_ITEMS_PER_PAGE) && (ms_Info[playerid][ms_TotalItems] % MS_MAX_ITEMS_PER_PAGE) == 0)
    {
        return (ms_Info[playerid][ms_TotalItems] / MS_MAX_ITEMS_PER_PAGE);
    }
    else return (ms_Info[playerid][ms_TotalItems] / MS_MAX_ITEMS_PER_PAGE) + 1;
 }

stock MenuStore_GetTotalItemsInCart(playerid)
{
    static count;
    count = 0;

    for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
        if(ms_Cart[playerid][ms_Cart_ItemID][i] != MSTORE_INVALID_ITEM_ID)
            count++;

    return count;
}

stock MenuStore_GetCartTotalValue(playerid)
{
    static count;
    count = 0;

    for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
        if(ms_Cart[playerid][ms_Cart_ItemID][i] != MSTORE_INVALID_ITEM_ID)
            count += (ms_Cart[playerid][ms_Cart_ItemPrice][i]*ms_Cart[playerid][ms_Cart_ItemAmount][i]);

    return count;
}

stock MenuStore_AddToCart(playerid, itemid, price, amount)
{
    for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
    {
        if(ms_Cart[playerid][ms_Cart_ItemID][i] == MSTORE_INVALID_ITEM_ID)
        {
            ms_Cart[playerid][ms_Cart_ItemID][i] = itemid;
            ms_Cart[playerid][ms_Cart_ItemPrice][i] = price;
            ms_Cart[playerid][ms_Cart_ItemAmount][i] = amount;
           
            MenuStore_CreateCartRow(playerid, i);
            MenuStore_UpdateCartTotalValue(playerid);
            break;
        }
    }
}

stock MenuStore_RemoveFromCart(playerid, row)
{
    ms_Cart[playerid][ms_Cart_ItemID][row] = MSTORE_INVALID_ITEM_ID;
    ms_Cart[playerid][ms_Cart_ItemPrice][row] = 0;
    ms_Cart[playerid][ms_Cart_ItemAmount][row] = 0;

    MenuStore_UpdateCartTotalValue(playerid);
    MenuStore_SortCart(playerid);
}


stock MenuStore_SortCart(playerid)
{
    for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
    {
        if(ms_Cart[playerid][ms_Cart_ItemID][i] == MSTORE_INVALID_ITEM_ID)
        {
            for(new x = i; x < MS_MAX_ITEMS_CART; x++)
            {
                if(ms_Cart[playerid][ms_Cart_ItemID][x] != MSTORE_INVALID_ITEM_ID)
                {
                    ms_Cart[playerid][ms_Cart_ItemID][i] = ms_Cart[playerid][ms_Cart_ItemID][x];
                    ms_Cart[playerid][ms_Cart_ItemPrice][i] = ms_Cart[playerid][ms_Cart_ItemPrice][x];
                    ms_Cart[playerid][ms_Cart_ItemAmount][i] = ms_Cart[playerid][ms_Cart_ItemAmount][x];

                    ms_Cart[playerid][ms_Cart_ItemID][x] = MSTORE_INVALID_ITEM_ID;
                    ms_Cart[playerid][ms_Cart_ItemPrice][x] = 0;
                    ms_Cart[playerid][ms_Cart_ItemAmount][x] = 0;
                    break;
                }
            }
        }
    }

    MenuStore_UpdateCart(playerid);
}

stock MenuStore_GetItemNameByID(playerid, id)
{
    format(ms_String, sizeof(ms_String), "N/A");

    for(new i = 0; i < MS_MAX_ITEMS; i++)
    {
        if(ms_Items[playerid][i][ms_ItemID] == id)
        {
            strunpack(ms_String, ms_Items[playerid][i][ms_ItemName]);
            return ms_String;
        }
    }

    return ms_String;
}

stock MenuStore_GetItemModelByID(playerid, id)
{
    for(new i = 0; i < MS_MAX_ITEMS; i++)
    {
        if(ms_Items[playerid][i][ms_ItemID] == id)
        {
            return ms_Items[playerid][i][ms_ItemModel];
        }
    }

    return 0;
}

stock MenuStore_CreateCartRow(playerid, row)
{
    new Float:ms_Cart_Item_Background_Base_Y = 293.883270,
        Float:ms_Cart_Item_ItemName_Base_Y = 294.566619,
        Float:ms_Cart_Item_ItemClose_Base_Y = 293.683410,
        Float:padding = 23.0;

    if(row > 0)
    {
        ms_Cart_Item_Background_Base_Y += (padding*row);
        ms_Cart_Item_ItemName_Base_Y += (padding*row);
        ms_Cart_Item_ItemClose_Base_Y += (padding*row);
    }

    ms_TD_Cart_ItemBackground[playerid][row] = CreatePlayerTextDrawEx(playerid, 344.000000, ms_Cart_Item_Background_Base_Y, "box",
                                                0.000000, 1.550000,
                                                505.000000, 15.000000,
                                                1,
                                                -1,
                                                1,
                                                MS_COLOR_CART_BACKGROUND_ITEM,
                                                0,
                                                0,
                                                255,
                                                1,
                                                1,
                                                0,
                                                0.0, 0.0, 0.0, 1.0,
                                                1);

    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]));
    ms_TD_Cart_ItemName[playerid][row] = CreatePlayerTextDrawEx(playerid, 345.200073, ms_Cart_Item_ItemName_Base_Y, ms_String,
                                        0.210997, 1.169996,
                                        506.000000, 0.0,
                                        1,
                                        MS_COLOR_TEXT_MAIN,
                                        1,
                                        0xffffff00,
                                        0,
                                        0,
                                        255,
                                        2,
                                        1);

    ms_TD_Cart_ItemClose[playerid][row] = CreatePlayerTextDrawEx(playerid, 501.965087, ms_Cart_Item_ItemClose_Base_Y, "X",
                                        0.387349, 1.546665,
                                        0.0, 0.0,
                                        3,
                                        MS_COLOR_CART_REMOVEITEM,
                                        0,
                                        0,
                                        0,
                                        0,
                                        255,
                                        1,
                                        1);

    PlayerTextDrawShow(playerid, ms_TD_Cart_ItemBackground[playerid][row]);
    PlayerTextDrawShow(playerid, ms_TD_Cart_ItemName[playerid][row]);
    PlayerTextDrawShow(playerid, ms_TD_Cart_ItemClose[playerid][row]);
}

stock MenuStore_RemoveCartRows(playerid)
{
    for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
    {
        RemovePlayerTD(playerid, ms_TD_Cart_ItemBackground[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_Cart_ItemName[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_Cart_ItemClose[playerid][i]);
    }
}

stock MenuStore_UpdateCartTotalValue(playerid)
{
    format(ms_String, sizeof(ms_String), ""#MS_WORD_TOTAL": %s%d", ms_Info[playerid][ms_MoneySign], MenuStore_GetCartTotalValue(playerid));
    PlayerTextDrawSetString(playerid, ms_TD_Cart_Total[playerid], ms_String);
}

stock MenuStore_UpdateCart(playerid)
{
    // Remove any previous
    MenuStore_RemoveCartRows(playerid);

    // Write
    for(new row = 0; row < MS_MAX_ITEMS_CART; row++)
    {
        if(ms_Cart[playerid][ms_Cart_ItemID][row] != MSTORE_INVALID_ITEM_ID)
        {
            MenuStore_CreateCartRow(playerid, row);
        }
    }
}

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)
{
    for(new i = 0; i < MS_MAX_ITEMS; i++)
        if(ms_Items[playerid][i][ms_ItemID] == itemid)
            return false;

    for(new i = 0; i < MS_MAX_ITEMS; i++)
    {
        if(ms_Items[playerid][i][ms_ItemID] == MSTORE_INVALID_ITEM_ID)
        {
            ms_Items[playerid][i][ms_ItemID] = itemid; 
            ms_Items[playerid][i][ms_ItemModel] = modelid;
            ms_Items[playerid][i][ms_ItemPrice] = price;
            ms_Items[playerid][i][ms_ItemStack] = stack;

            strpack(ms_Items[playerid][i][ms_ItemName], name, 32 char);
            strpack(ms_Items[playerid][i][ms_ItemDescription], description, 256 char);
           
            if(description_size > MS_MAX_SIZE_DESCRIPTION) {
                ms_Items[playerid][i][ms_ItemDescriptionBonus] = MS_MAX_SIZE_DESCRIPTION;
            }
            else {
                ms_Items[playerid][i][ms_ItemDescriptionBonus] = description_size;
            }

            ms_Items[playerid][i][ms_ItemLineJump] = description_line_jump;

            ms_Items[playerid][i][ms_ItemPreviewRot][0] = rotX;
            ms_Items[playerid][i][ms_ItemPreviewRot][1] = rotY;
            ms_Items[playerid][i][ms_ItemPreviewRot][2] = rotZ;
            ms_Items[playerid][i][ms_ItemPreviewRot][3] = zoom;

            ms_Info[playerid][ms_TotalItems]++;
            break;
        }  
    }

    return true;
}


stock MenuStore_Open(playerid, const menuid[], store_name[], const money_sign[] = MS_DEFAULT_MONEY_SIGN, button_confirm[] = MS_DEFAULT_CONFIRM)
{
    if(MenuStore_IsOpen(playerid))
        return false;

    SelectTextDraw(playerid, MS_COLOR_SELECT_TD);
    ms_Info[playerid][ms_IsOpen] = true;
    format(ms_Info[playerid][ms_MoneySign], 32, money_sign);
    format(ms_Info[playerid][ms_StoreID], 32, menuid);

    TextDrawShowForPlayer(playerid, ms_TD_Backgrounds[0]);
    TextDrawShowForPlayer(playerid, ms_TD_Backgrounds[1]);

    ms_TD_StoreName[playerid] = CreatePlayerTextDrawEx(playerid, 150.843780, 129.850082, store_name,
                                0.310358, 1.434999,
                                315.000000, 0.0,
                                1,
                                MS_COLOR_TEXT_MAIN,
                                1,
                                0,
                                0,
                                0,
                                255,
                                2,
                                1);

    if(ms_Info[playerid][ms_TotalItems] > MS_MAX_ITEMS_PER_PAGE)
    {
        TextDrawShowForPlayer(playerid, ms_TD_Previous);
        TextDrawShowForPlayer(playerid, ms_TD_Next);
    }

    PlayerTextDrawShow(playerid, ms_TD_StoreName[playerid]);

    // Cart

    format(ms_String, sizeof(ms_String), ""#MS_WORD_TOTAL": %s0", ms_Info[playerid][ms_MoneySign]);
    ms_TD_Cart_Total[playerid] = CreatePlayerTextDrawEx(playerid, 339.200012, 386.949951, ms_String,
                            0.219999, 1.331665,
                            437.000000, 0.0,
                            1,
                            MS_COLOR_TEXT_MAIN,
                            1,
                            0xffffff00,
                            0,
                            0,
                            255,
                            2,
                            1);

    ms_TD_Cart_BuyName[playerid] = CreatePlayerTextDrawEx(playerid, 476.000152, 386.683441, button_confirm,
                            0.282000, 1.442499,
                            0.000000, 61.000000,
                            2,
                            MS_COLOR_TEXT_MAIN,
                            1,
                            0xffffff00,
                            0,
                            0,
                            255,
                            2,
                            1);

    TextDrawShowForPlayer(playerid, ms_TD_Cart_Backgrounds[0]);
    TextDrawShowForPlayer(playerid, ms_TD_Cart_Backgrounds[1]);
    TextDrawShowForPlayer(playerid, ms_TD_Cart_BackgroundConfirm);
    TextDrawShowForPlayer(playerid, ms_TD_Cart_CartName);

    PlayerTextDrawShow(playerid, ms_TD_Cart_BuyName[playerid]);
    PlayerTextDrawShow(playerid, ms_TD_Cart_Total[playerid]);

    ms_Info[playerid][ms_CurrentPage] = 1;
    MenuStore_SetPage(playerid, ms_Info[playerid][ms_CurrentPage]);
    return true;
}

stock MenuStore_Close(playerid)
{
    MenuStore_ResetVariables(playerid);

    CancelSelectTextDraw(playerid);
    MenuStore_UnselectRow(playerid);
    MenuStore_CloseDescription(playerid);

    TextDrawHideForPlayer(playerid, ms_TD_Backgrounds[0]);
    TextDrawHideForPlayer(playerid, ms_TD_Backgrounds[1]);
    TextDrawHideForPlayer(playerid, ms_TD_Previous);
    TextDrawHideForPlayer(playerid, ms_TD_Next);

    RemovePlayerTD(playerid, ms_TD_StoreName[playerid]);

    // Cart TextDraws

    TextDrawHideForPlayer(playerid, ms_TD_Cart_Backgrounds[0]);
    TextDrawHideForPlayer(playerid, ms_TD_Cart_Backgrounds[1]);
    TextDrawHideForPlayer(playerid, ms_TD_Cart_BackgroundConfirm);
    TextDrawHideForPlayer(playerid, ms_TD_Cart_CartName);

    RemovePlayerTD(playerid, ms_TD_Cart_BuyName[playerid]);
    RemovePlayerTD(playerid, ms_TD_Cart_Total[playerid]);

    for(new i = 0; i < MS_MAX_ITEMS_PER_PAGE; i++)
    {
        RemovePlayerTD(playerid, ms_TD_ItemBackground[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_ItemName[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_ItemPrice[playerid][i]);
        RemovePlayerTD(playerid, ms_TD_ItemModel[playerid][i]);
    }

    RemovePlayerTD(playerid, ms_TD_Pagination[playerid]);

    MenuStore_RemoveCartRows(playerid);

}

stock MenuStore_IsOpen(playerid)
    return ms_Info[playerid][ms_IsOpen];


stock MenuStore_SelectRow(playerid, row)
{
    ms_Info[playerid][ms_Selected] = row;

    PlayerTextDrawBoxColor(playerid, ms_TD_ItemBackground[playerid][row], MS_COLOR_BACKGROUND_ITEMSELECTED);
    PlayerTextDrawHide(playerid, ms_TD_ItemBackground[playerid][row]);
    PlayerTextDrawShow(playerid, ms_TD_ItemBackground[playerid][row]);
}

stock MenuStore_UnselectRow(playerid)
{
    if(ms_Info[playerid][ms_Selected] != -1)
    {
        new row = ms_Info[playerid][ms_Selected];
        PlayerTextDrawBoxColor(playerid, ms_TD_ItemBackground[playerid][row], MS_COLOR_BACKGROUND_ITEM);
        PlayerTextDrawHide(playerid, ms_TD_ItemBackground[playerid][row]);
        PlayerTextDrawShow(playerid, ms_TD_ItemBackground[playerid][row]);
    }

    ms_Info[playerid][ms_Selected] = -1;
}

stock MenuStore_ToggleControll(playerid, bool:toggle)
    return ms_Info[playerid][ms_ToggleControll] = toggle;


stock MenuStore_OpenDescription(playerid, index)
{
    if(ms_Info[playerid][ms_Selected] == -1)
        return false;

    if(ms_TD_DescriptionItemModel[playerid] == PlayerText:INVALID_TEXT_DRAW)
    {
        ms_TD_DescriptionBackground[playerid][0] = CreatePlayerTextDrawEx(playerid, 333.100463, 130.980590, "box",
                                                0.000000, (6.630985+ms_Items[playerid][index][ms_ItemDescriptionBonus]),
                                                516.000000, 0.000000,
                                                1,
                                                -1,
                                                1,
                                                MS_COLOR_DESCRIPTION_BACKGROUND_1,
                                                0,
                                                0,
                                                255,
                                                1,
                                                1);

        ms_TD_DescriptionBackground[playerid][1] = CreatePlayerTextDrawEx(playerid, 335.215118, 133.416717, "box",
                                                0.000000, (6.111274+ms_Items[playerid][index][ms_ItemDescriptionBonus]),
                                                514.000000, 0.000000,
                                                1,
                                                -1,
                                                1,
                                                MS_COLOR_DESCRIPTION_BACKGROUND_2,
                                                0,
                                                0,
                                                255,
                                                1,
                                                1);

        ms_TD_DescriptionItemName[playerid] = CreatePlayerTextDrawEx(playerid, 336.807769, 134.333419, ms_Items[playerid][index][ms_ItemName],
                                                0.225572, 1.349166,
                                                514.000000, 0.0,
                                                1,
                                                MS_COLOR_DESCRIPTION_NAMEITEM,
                                                1,
                                                0xffffff00,
                                                0,
                                                0,
                                                255,
                                                2,
                                                1);

        new Float:description_text_size_y = 460.000000,
            Float:description_text_size_x = 0.000000;

        if(!ms_Items[playerid][index][ms_ItemLineJump])
            description_text_size_y = 513.000000;

        ms_TD_DescriptionItemText[playerid] = CreatePlayerTextDrawEx(playerid, 336.981842, 147.783721, ms_Items[playerid][index][ms_ItemDescription],
                                                0.199804, 1.098332,
                                                description_text_size_y, description_text_size_x,
                                                1,
                                                MS_COLOR_DESCRIPTION_TEXT,
                                                1,
                                                0xffffff00,
                                                0,
                                                0,
                                                255,
                                                2,
                                                1);

        ms_TD_DescriptionItemModel[playerid] = CreatePlayerTextDrawEx(playerid, 460.658721, 135.700027, "",
                                                0.000000, 0.000000,
                                                52.000000, 51.000000,
                                                1,
                                                -1,
                                                0,
                                                0,
                                                0,
                                                0,
                                                MS_COLOR_DESCRIPTION_BACKGROUND_MODEL,
                                                5,
                                                0,
                                                ms_Items[playerid][index][ms_ItemModel],
                                                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]);
    }
    else
    {
        PlayerTextDrawHide(playerid, ms_TD_DescriptionItemName[playerid]);
        PlayerTextDrawHide(playerid, ms_TD_DescriptionItemText[playerid]);
        PlayerTextDrawHide(playerid, ms_TD_DescriptionItemModel[playerid]);

        PlayerTextDrawSetPreviewModel(playerid, ms_TD_DescriptionItemModel[playerid], ms_Items[playerid][index][ms_ItemModel]);
        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]);

        PlayerTextDrawSetString(playerid, ms_TD_DescriptionItemName[playerid], ms_Items[playerid][index][ms_ItemName][0]);
        PlayerTextDrawSetString(playerid, ms_TD_DescriptionItemText[playerid], ms_Items[playerid][index][ms_ItemDescription][0]);

        new Float:description_text_size_y = 460.000000,
            Float:description_text_size_x = 0.000000;

        if(!ms_Items[playerid][index][ms_ItemLineJump])
            description_text_size_y = 513.000000;

        PlayerTextDrawTextSize(playerid, ms_TD_DescriptionItemText[playerid], description_text_size_y, description_text_size_x);

        PlayerTextDrawLetterSize(playerid, ms_TD_DescriptionBackground[playerid][0], 0.000000, (6.630985+ms_Items[playerid][index][ms_ItemDescriptionBonus]));
        PlayerTextDrawLetterSize(playerid, ms_TD_DescriptionBackground[playerid][1], 0.000000, (6.111274+ms_Items[playerid][index][ms_ItemDescriptionBonus]));
    }

    PlayerTextDrawShow(playerid, ms_TD_DescriptionBackground[playerid][0]);
    PlayerTextDrawShow(playerid, ms_TD_DescriptionBackground[playerid][1]);
    PlayerTextDrawShow(playerid, ms_TD_DescriptionItemName[playerid]);
    PlayerTextDrawShow(playerid, ms_TD_DescriptionItemText[playerid]);
    PlayerTextDrawShow(playerid, ms_TD_DescriptionItemModel[playerid]);
    return true;
}

stock MenuStore_CloseDescription(playerid)
{
    RemovePlayerTD(playerid, ms_TD_DescriptionBackground[playerid][0]);
    RemovePlayerTD(playerid, ms_TD_DescriptionBackground[playerid][1]);
    RemovePlayerTD(playerid, ms_TD_DescriptionItemName[playerid]);
    RemovePlayerTD(playerid, ms_TD_DescriptionItemText[playerid]);
    RemovePlayerTD(playerid, ms_TD_DescriptionItemModel[playerid]);
}


stock MenuStore_ResetVariables(playerid)
{
    for(new i = 0; i < MS_MAX_ITEMS; i++)
    {
        ms_Items[playerid][i][ms_ItemID] = MSTORE_INVALID_ITEM_ID;
        ms_Items[playerid][i][ms_ItemModel] = 0;
        ms_Items[playerid][i][ms_ItemPrice] = 0;
        ms_Items[playerid][i][ms_ItemStack] = 0;
        ms_Items[playerid][i][ms_ItemName][0] = EOS;
        ms_Items[playerid][i][ms_ItemDescription][0] = EOS;
        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;
        ms_Items[playerid][i][ms_ItemLineJump] = true;
        ms_Items[playerid][i][ms_ItemDescriptionBonus] = 0.0;
    }

    for(new i = 0; i < MS_MAX_ITEMS_CART; i++)
    {
        ms_Cart[playerid][ms_Cart_ItemID][i] = MSTORE_INVALID_ITEM_ID;
        ms_Cart[playerid][ms_Cart_ItemPrice][i] = 0;
        ms_Cart[playerid][ms_Cart_ItemAmount][i] = 0;
    }

    ms_Info[playerid][ms_TotalItems] = 0;
    ms_Info[playerid][ms_CurrentPage] = 1;
    ms_Info[playerid][ms_IsOpen] = false;
    ms_Info[playerid][ms_StoreID][0] = EOS;
    ms_Info[playerid][ms_MoneySign][0] = EOS;
    ms_Info[playerid][ms_DoubleClickRow] = -1;
    ms_Info[playerid][ms_DoubleClick] = 0;
    ms_Info[playerid][ms_Selected] = -1;
    ms_Info[playerid][ms_ToggleControll] = true;
}


static stock RemovePlayerTD(playerid, &PlayerText:td)
{
    if(td == PlayerText:INVALID_TEXT_DRAW)
        return false;

    PlayerTextDrawHide(playerid, td);
    PlayerTextDrawDestroy(playerid, td);
    td = PlayerText:INVALID_TEXT_DRAW;
    return true;
}

static stock PlayerText:CreatePlayerTextDrawEx(playerid, Float:x, Float:y, 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)
{
    new PlayerText:td;
    td = CreatePlayerTextDraw(playerid, x, y, text);
    PlayerTextDrawLetterSize(playerid, td, size_x, size_y);
    PlayerTextDrawTextSize(playerid, td, textsize_x, textsize_y);
    PlayerTextDrawAlignment(playerid, td, align);
    PlayerTextDrawColor(playerid, td, color);
    PlayerTextDrawUseBox(playerid, td, usebox);
    PlayerTextDrawBoxColor(playerid, td, boxcolor);
    PlayerTextDrawSetShadow(playerid, td, shadow);
    PlayerTextDrawSetOutline(playerid, td, outline);
    PlayerTextDrawBackgroundColor(playerid, td, bg_color);
    PlayerTextDrawFont(playerid, td, font);
    PlayerTextDrawSetProportional(playerid, td, proportional);
    PlayerTextDrawSetPreviewModel(playerid, td, model);
    PlayerTextDrawSetPreviewRot(playerid, td, preview_x, preview_y, preview_z, preview_zoom);
    PlayerTextDrawSetSelectable(playerid, td, selectable);
    return td;
}

static stock Text:CreateTextDrawEx(Float:x, Float:y, 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)
{
    new Text:td;
    td = TextDrawCreate(x, y, text);
    TextDrawLetterSize(td, size_x, size_y);
    TextDrawTextSize(td, textsize_x, textsize_y);
    TextDrawAlignment(td, align);
    TextDrawColor(td, color);
    TextDrawUseBox(td, usebox);
    TextDrawBoxColor(td, boxcolor);
    TextDrawSetShadow(td, shadow);
    TextDrawSetOutline(td, outline);
    TextDrawBackgroundColor(td, bg_color);
    TextDrawFont(td, font);
    TextDrawSetProportional(td, proportional);
    TextDrawSetPreviewModel(td, model);
    TextDrawSetPreviewRot(td, preview_x, preview_y, preview_z, preview_zoom);
    TextDrawSetSelectable(td, selectable);
    return td;
}


All times are GMT. The time now is 06:58 AM.

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