Businesses doesn't save after restart
#1

Alright. I'm using MySQL and the business system is working perfectly. The problem is there, once I log in the server and create businesses or even one business, after restart they are gone. How do I make them to save after restart? I copied the system from one other script. Is there way to make it to be saved in scriptfiles folder. I will create folder in scripfiles- Business. How do I do that? Please help me.
Reply
#2

Bump
Reply
#3

Bump again
Reply
#4

Are you actually saving it? And does it load the businesses OnGameModeInit? And we can't help you without a code!
And you first said your using MySQL For saving then you said you will save at scriptfiles? Do you even know what SQL and Dini is?
Reply
#5

Well, tell me what code do you need and I will post it for you here.
Reply
#6

Ok a couple questions for you
1: Do you know what MySQL is and what DINI is?
2: If this a system from sa-mp forums
3: Can you show us the code you use to create a business.(or cmd...)
Reply
#7

1. Yes, I do.
2.No, It is not from the SA:MP forum.
3. Yes, of course.
pawn Код:
CMD:bedit(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
        return 1;
    }

    new choice[32], businessid, amount, string[128];
    if(sscanf(params, "s[32]dD(0)", choice, businessid, amount))
    {
        SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /bedit [name] [businessid] [amount]");
        SendClientMessageEx(playerid, COLOR_GREY, "Available names: Exterior, Interior, SupplyPoint, Price, Type, Inventory, InventoryCapacity, SafeBalance, Delete");
        SendClientMessageEx(playerid, COLOR_GREY, "Available names: CustomInterior, CustomExterior, Months, GymEntryFee, GymType, VW, Grade");
        return 1;
    }

    if (!IsValidBusinessID(businessid))
    {
        SendClientMessageEx(playerid, COLOR_GREY, "Invalid business ID entered.");
        return 1;
    }
    if(!strcmp(choice, "grade", true))
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "You have changed the grade on this business!");
        format(string, sizeof(string), "%s has changed BusinessID %d's Grade to %i", GetPlayerNameEx(playerid), businessid, amount);
        Businesses[businessid][bGrade] = amount;
        Log("logs/bedit.log", string);
    }
    if(!strcmp(choice, "months", true))
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "You have changed the months left on this business!");
        format(string, sizeof(string), "%s has changed BusinessID %d's Months to %i", GetPlayerNameEx(playerid), businessid, amount);
        Businesses[businessid][bMonths] = 2592000*amount+gettime()+259200;
        Log("logs/bedit.log", string);
    }
    else if(!strcmp(choice, "vw", true))
    {
        Businesses[businessid][bVW] = amount;
        SendClientMessageEx(playerid, COLOR_WHITE, "You have changed the VW!");
        format(string, sizeof(string), "%s has changed BusinessID %d's vw to %d", GetPlayerNameEx(playerid), businessid, amount);
        Log("logs/bedit.log", string);
    }
    if(!strcmp(choice, "exterior", true))
    {
        GetPlayerPos(playerid, Businesses[businessid][bExtPos][0], Businesses[businessid][bExtPos][1], Businesses[businessid][bExtPos][2]);
        GetPlayerFacingAngle(playerid, Businesses[businessid][bExtPos][3]);
        SendClientMessageEx(playerid, COLOR_WHITE, "You have changed the exterior!");
        format(string, sizeof(string), "%s has changed BusinessID %d's Exterior to X:%f Y:%f Z:%f", GetPlayerNameEx(playerid), businessid, Businesses[businessid][bExtPos][0], Businesses[businessid][bExtPos][1],Businesses[businessid][bExtPos][2]);
        Log("logs/bedit.log", string);
    }
    else if(!strcmp(choice, "interior", true))
    {
        GetPlayerPos(playerid, Businesses[businessid][bIntPos][0], Businesses[businessid][bIntPos][1], Businesses[businessid][bIntPos][2]);
        GetPlayerFacingAngle(playerid, Businesses[businessid][bIntPos][3]);
        Businesses[businessid][bInt] = GetPlayerInterior(playerid);
        SendClientMessageEx(playerid, COLOR_WHITE, "You have changed the interior!");
        format(string, sizeof(string), "%s has changed BusinessID %d's Interior to X:%f Y:%f Z:%f", GetPlayerNameEx(playerid), businessid, Businesses[businessid][bIntPos][0], Businesses[businessid][bIntPos][1],Businesses[businessid][bIntPos][2]);
        Log("logs/bedit.log", string);
    }
    else if(strcmp(choice, "custominterior", true) == 0)
    {
        if(Businesses[businessid][bCustomInterior] == 0)
        {
            Businesses[businessid][bCustomInterior] = 1;
            SendClientMessageEx(playerid, COLOR_WHITE, "Business set to custom interior!");
        }
        else
        {
            Businesses[businessid][bCustomInterior] = 0;
            SendClientMessageEx(playerid, COLOR_WHITE, "Business set to normal (not custom) interior!");
        }
        format(string, sizeof(string), "%s has edited BusinessID %d's CustomInterior.", GetPlayerNameEx(playerid), businessid);
        Log("logs/bedit.log", string);
        return 1;
    }
    else if(strcmp(choice, "customexterior", true) == 0)
    {
        if(Businesses[businessid][bCustomExterior] == 0)
        {
            Businesses[businessid][bCustomExterior] = 1;
            SendClientMessageEx(playerid, COLOR_WHITE, "Business set to custom exterior!");
        }
        else
        {
            Businesses[businessid][bCustomExterior] = 0;
            SendClientMessageEx(playerid, COLOR_WHITE, "Business set to normal (not custom) exterior!");
        }
        format(string, sizeof(string), "%s has edited BusinessID %d's CustomExterior.", GetPlayerNameEx(playerid), businessid);
        Log("logs/bedit.log", string);
        return 1;
    }
    else if(!strcmp(choice, "supplypoint", true))
    {
        if(Businesses[businessid][bOrderState] == 2)
        {
            return SendClientMessageEx(playerid, COLOR_GREY, "You can't change the supply point when a delivery is on its way.");
        }
        GetPlayerPos(playerid, Businesses[businessid][bSupplyPos][0], Businesses[businessid][bSupplyPos][1], Businesses[businessid][bSupplyPos][2]);
        SendClientMessageEx(playerid, COLOR_WHITE, "You have edited the supply point!");
        format(string, sizeof(string), "%s has changed BusinessID %d's Supply Point to X:%f Y:%f Z:%f", GetPlayerNameEx(playerid), businessid, Businesses[businessid][bSupplyPos][0], Businesses[businessid][bSupplyPos][1],Businesses[businessid][bSupplyPos][2]);
        Log("logs/bedit.log", string);
    }

    else if(!strcmp(choice, "price", true))
    {
        Businesses[businessid][bValue] = amount;
        format(string, sizeof(string), "You have set the business price to $%d.", amount);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has changed BusinessID %d's Price to $%d.", GetPlayerNameEx(playerid), businessid, amount);
        Log("logs/bedit.log", string);
    }

    else if(!strcmp(choice, "type", true))
    {
        if(Businesses[businessid][bOrderState] == 2)
        {
            return SendClientMessageEx(playerid, COLOR_GREY, "You can't change the business type when a delivery is on its way.");
        }
        Businesses[businessid][bType] = amount;
        format(string, sizeof(string), "You have set the business type to %s.", GetBusinessTypeName(amount));
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has changed BusinessID %d's Type to %s (%d).", GetPlayerNameEx(playerid), businessid, GetBusinessTypeName(amount), amount);
        Log("logs/bedit.log", string);
    }

    else if(!strcmp(choice, "inventory", true))
    {
        Businesses[businessid][bInventory] = amount;
        format(string, sizeof(string), "You have set the business inventory to %d.", amount);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has changed BusinessID %d's Inventory to %d.", GetPlayerNameEx(playerid), businessid, amount);
        Log("logs/bedit.log", string);
    }
    else if(!strcmp(choice, "InventoryCapacity", true))
    {
        Businesses[businessid][bInventoryCapacity] = amount;
        format(string, sizeof(string), "You have set the business inventory capacity to %d.", amount);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has changed BusinessID %d's Inventory Capacity to %d.", GetPlayerNameEx(playerid), businessid, amount);
        Log("logs/bedit.log", string);
    }

    else if(!strcmp(choice, "safebalance", true))
    {
        Businesses[businessid][bSafeBalance] = amount;
        format(string, sizeof(string), "You have set the business safe to %d.", amount);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has changed BusinessID %d's safe to %d.", GetPlayerNameEx(playerid), businessid, amount);
        Log("logs/bedit.log", string);
    }

    else if (!strcmp(choice, "gymentryfee", true))
    {
        if (Businesses[businessid][bType] != BUSINESS_TYPE_GYM)
        {
            return SendClientMessageEx(playerid, COLOR_GRAD2, "Only Gyms can have entrance fees!");
        }

        Businesses[businessid][bGymEntryFee] = amount;
        format(string, sizeof(string), "You have set the gym entry fee to %i.", amount);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has changed BusinessID %i's gym entry fee to %i.", GetPlayerNameEx(playerid), businessid, amount);
        Log("logs/bedit.log", string);
    }

    else if (!strcmp(choice, "gymtype", true))
    {
        if (Businesses[businessid][bType] != BUSINESS_TYPE_GYM)
        {
            return SendClientMessageEx(playerid, COLOR_GRAD2, "You can only use this command on a gym!");
        }

        if (amount == 1) // swimming pool & boxing arena
        {
            Businesses[businessid][bGymType] = amount;
        }
        else if (amount == 2) // bike parkour
        {
            Businesses[businessid][bGymType] = amount;
        }
        else
        {
            return SendClientMessageEx(playerid, COLOR_GRAD2, "Available types are: Swimming Pool / Boxing Arena(1) or Bike Parkour (2)");
        }

        format(string, sizeof(string), "You have the set the gym type to %i.", amount);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has changed BusinessID %i's gym type to %i.", GetPlayerNameEx(playerid), businessid, amount);
        Log("logs/bedit.log", string);
    }

    else if(!strcmp(choice, "delete", true))
    {
        Businesses[businessid][bExtPos][0] = 0;
        Businesses[businessid][bExtPos][1] = 0;
        Businesses[businessid][bExtPos][2] = 0;
        Businesses[businessid][bName][0] = 0;
        Businesses[businessid][bType] = 0;
        format(string, sizeof(string), "You have deleted the business.", amount);
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), "%s has deleted BusinessID %d.", GetPlayerNameEx(playerid), businessid);
        Log("logs/bedit.log", string);
        //TODO IMPROVE
        for (new i; i < MAX_BUSINESS_GAS_PUMPS; i++) {
            DestroyDynamicGasPump(businessid, i);
        }
        for (new i; i < MAX_BUSINESS_DEALERSHIP_VEHICLES; i++) {
            DestroyVehicle(Businesses[businessid][bVehID][i]);
        }
    }

    RefreshBusinessPickup(businessid);
    SaveBusiness(businessid);
    Streamer_UpdateEx(playerid, Businesses[businessid][bExtPos][0], Businesses[businessid][bExtPos][1], Businesses[businessid][bExtPos][2]);

    return 1;
}
And sorry for the late reply.
Reply
#8

Bump
Reply
#9

Fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)