SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Business problem- Zgaming roleplay... (https://forum.sa-mp.com/showthread.php?t=439250)

razor steven 24/05/2013 04:31 PM

Business problem- Zgaming roleplay...
 
Zgaming roleplay gamemode has dynamic business system with level system.

The problem is, Whatever the level of a business maybe, I can buy any item. Like Gascan is a level 5 item. Which means if the market doesn't have level 5, no one will be able to buy it. If the market have level 5, then it will be buyable.
But it is not working that way. Level 5 items can be bought from level 1 market...
How do I fix it?

Here's the code...

Code:

CMD:prices(playerid, params[])
{
        new idx = GetPlayerVirtualWorld(playerid)-100, string[128];
        if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
        if(idx > 0 && idx < MAX_BIZ && BizInfo[idx][bType] != 1 && BizInfo[idx][bType] != 2 && BizInfo[idx][bType] != 3 && BizInfo[idx][bType] != 4 && BizInfo[idx][bType] != 6 || idx < 1 || idx > MAX_BIZ) return SendClientMessage(playerid, COLOR_GREY, "You are not inside a business.");
    if(BizInfo[idx][bType] == 1)
        {
            format(string, sizeof(string), "** %s's 24/7 Market menu list **", BizInfo[idx][bOwner]);
            SendClientMessage(playerid, COLOR_ORANGE, string);
                if(BizInfo[idx][bLevel] >= 1) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 1: Cellphone ($100) | Phonebook ($50) | Dice ($20) | Cigar ($100)");
                if(BizInfo[idx][bLevel] >= 2) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 2: Speedometer ($200) | Sprunk ($30) | Spraycan ($100) | Rope ($60)");
                if(BizInfo[idx][bLevel] >= 3) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 3: Blindfold ($60) | WalkieTalkie ($200) | Smartphone($500)");
                if(BizInfo[idx][bLevel] >= 4) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 4: Camera ($300) | GasCan ($100)");
                //if(BizInfo[idx][bLevel] >= 5) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 5: Radio ($300)");
        }
        else if(BizInfo[idx][bType] == 3)
        {
            format(string, sizeof(string), "** %s's Ammunation menu list **", BizInfo[idx][bOwner]);
            SendClientMessage(playerid, COLOR_ORANGE, string);
                if(BizInfo[idx][bLevel] >= 1) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 1: 1) Shotgun Ammo ($400) | 2) Rifle Ammo ($2000)");
                if(BizInfo[idx][bLevel] >= 4) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 2: 3) Gun Ammo ($800)");
                if(BizInfo[idx][bLevel] >= 2) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 3: 4) Light-Machinegun Ammo ($1200)");
                if(BizInfo[idx][bLevel] >= 3) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 4: 5) Heavy-Machinegun Ammo ($2200)");
                if(BizInfo[idx][bLevel] >= 5) SendClientMessage(playerid, COLOR_WHITE, "UPGRADE 5: 6) Vest ($1000)");
        }
        else if(BizInfo[idx][bType] == 4)
        {
            format(string, sizeof(string), "** %s's Club menu list **", BizInfo[idx][bOwner]);
            SendClientMessage(playerid, COLOR_ORANGE, string);
                SendClientMessage(playerid, COLOR_WHITE, "1) Sprunk ($50) | 2) Beer ($100) | 3) Vodka ($200)");
        }
        else if(BizInfo[idx][bType] == 6)
        {
            format(string, sizeof(string), "** %s's Fast Food menu list **", BizInfo[idx][bOwner]);
            SendClientMessage(playerid, COLOR_ORANGE, string);
                SendClientMessage(playerid, COLOR_WHITE, "1) Small Meal ($10) | 2) Medium Meal ($30) | 3) Big Meal ($50)");
        }
        return 1;
}


Krakuski 25/05/2013 12:42 AM

Re: Business problem- Zgaming roleplay...
 
Add this line to after every line in the /buy command.

For example:

HINT: make sure to look for the //RIGHT HERE VVVVVVVVVVVV messages

pawn Code:
CMD:buy(playerid, params[])
{
    new idx = GetPlayerVirtualWorld(playerid)-100, string[128], type, price;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(idx > 0 && idx < MAX_BIZ && BizInfo[idx][bType] != 1 && BizInfo[idx][bType] != 2 && BizInfo[idx][bType] != 3 && BizInfo[idx][bType] != 4 && BizInfo[idx][bType] != 6 || idx < 1 || idx > MAX_BIZ) return SendClientMessage(playerid, COLOR_GREY, "You are not inside a business.");
    if(BizInfo[idx][bType] == 1)
    {
        if(sscanf(params, "s[32]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buy [item]");
        if(BizInfo[idx][bProducts] < 1) return SendClientMessage(playerid, COLOR_GREY, "This business is currently out of products.");
//RIGHT HERE VVVVVVVVVVVV
        if(BizInfo[idx][bLevel] < 2) return SendClientMessage(playerid, COLOR_GREY, "This 24/7 Market doesn't have this product yet."); //ADD THIS DEPENDING ON THE LEVEL
//THIS LINE HERE ^^^^^^^^^^
        if(!strcmp(params, "cellphone", true))
        {

            if(PlayerInfo[playerid][pMoney] < 100) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to do this.");
            new randphone = random(1000) + random(8999);//minimum 100  max 9999
            PlayerInfo[playerid][pNumber] = randphone;
            PlayerInfo[playerid][pHasCellphone] = 1;
            BizInfo[idx][bMoney] += 100;
            BizInfo[idx][bProducts] --;
            BizInfo[idx][bSold] ++;
            GiveDodMoney(playerid, -100);
            format(string, sizeof(string), "* %s has bought a cellphone for $100.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            SendClientMessage(playerid, COLOR_WHITE, " (( Check /stats to check your new Phone Number ))");
        }
        if(!strcmp(params, "phonebook", true))
        {

razor steven 25/05/2013 07:17 AM

Re: Business problem- Zgaming roleplay...
 
Thank you very much:D

+REP


All times are GMT. The time now is 08:26 PM.

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