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!


All times are GMT. The time now is 03:55 PM.

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