[Include] MenuStore (Build dynamic stores with TextDraws)
#1

MenuStore.inc

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

Demonstration



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.
Reply
#2

+Rep for the neat design!
Reply
#3

You should always use global textdraws where possible there is a lot of player textdraws wasted here plus extra overhead to create them needlessly.
Reply
#4

Quote:
Originally Posted by Pottus
View Post
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.
Reply
#5

Just convert the static ones to global (that black and gray backgrounds, arrows, etc).
Reply
#6

Quote:
Originally Posted by ExTaZZ69
View Post
Just convert the static ones to global (that black and gray backgrounds, arrows, etc).
Next update I'll do it
Reply
#7

Looks promising. Keep up the good work. REP+
Reply
#8

Version 3.0

- Some PlayerTDs have been transformed into GlobalTDs
- Fixed bugs
Reply
#9

I think Pottus will be happy now.

Nice work by the way
Reply
#10

Some people doesn't know even what is dynamic (Dynamic mysql connection, dynamic stores, dynamic npc creator)


Anyways, the text draws are nice, good job
Reply
#11

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


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.
Reply
#12

Quote:
Originally Posted by PT
View Post
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.
Reply
#13

Good job!
Reply
#14

Quote:
Originally Posted by nG Inverse
View Post
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?
Reply
#15

@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
Reply
#16

Very nice design, keep update
Reply
#17

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

Reply
#18

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
Reply
#19

Quote:
Originally Posted by DanDRT
View Post
@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'.
Reply
#20

Quote:
Originally Posted by Sellize
View Post
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)