Creating Businesses
#1

Hey, this is my code but I'm not quite sure how to save the pickup co-ordinates, this is my code:

pawn Код:
command(createbusiness, playerid, params[])
{
    if(loggedin[playerid] == 0) return SendClientMessage(playerid, 0x66666666, "You must be logged in perform commands");
    if(PVar[playerid][alevel] > 3)
    {
        new name[28], str[128], price, payout;
       
        if(sscanf(params, "sdd", name, price, payout))
        {
            SendClientMessage(playerid, 0x66666666, "Usage: /createbusiness [Business Name] [Price] [Payout] * The price must be below 1000000 and the Payout must not exceed 5000 *");
            return 1;
        }
        else
        {
            new Query[500];
            new EscName[28];
            currbusiness += 1;
            mysql_real_escape_string(name, EscName);
           
            new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid, x, y, z);
            BVar[businessid[currbusiness]][bid] = currbusiness;
            BVar[businessid[currbusiness]][bpickupx] = x;
            BVar[businessid[currbusiness]][bpickupy] = y;
            BVar[businessid[currbusiness]][bpickupz] = z;
            BVar[businessid[currbusiness]][bname] = EscName;
            BVar[businessid[currbusiness]][bprice] = price;
            BVar[businessid[currbusiness]][bpayout] = payout;
           
            CreatePickup(1272, 1, x, y, z, 0);

            format(Query, sizeof(Query), "INSERT INTO `businessinfo` (`bid`, `bpickupx`, `bpickupy`, `bpickupz`, `bname`, `bname`, `bprice`, `bpayout`) VALUES ('%d', '%d', '%d', '%d', '%s', '%d', '%d')", currbusiness, x, y, z, EscName, price, payout);
            mysql_query(Query);
            SaveBVar();
            format(str, sizeof(str), "You have created a business called: %s with a payout of %d worth $%d", name, payout, price);
            SendClientMessage(playerid, 0xFFFFFFFF, str);
           
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, 0x66666666, "You are not authorised to use that command.");
        return 1;
    }
}
Here is the stock for "SaveBVar();"

pawn Код:
stock SaveBVar()
{
        new Query[600];
        format(Query, sizeof(Query), "UPDATE `bid` SET `bid` = '%d', `bpickupx` = '%d', `bpickupy` = '%d', `bpickupz` = '%d', `bname` = '%s', `bprice` = '%d'", // Also remember to update this...

        BVar[businessid[currbusiness]][bid],
        BVar[businessid[currbusiness]][bpickupx],
        BVar[businessid[currbusiness]][bpickupy],
        BVar[businessid[currbusiness]][bpickupz],
        BVar[businessid[currbusiness]][bname],
        BVar[businessid[currbusiness]][bprice]);

        mysql_query(Query);
        mysql_free_result();
        return 1;
}
These are the errors I get:

pawn Код:
C:\Users\Ben\Desktop\SF-RP\gamemodes\bensamp.pwn(1979) : warning 213: tag mismatch
C:\Users\Ben\Desktop\SF-RP\gamemodes\bensamp.pwn(1980) : warning 213: tag mismatch
C:\Users\Ben\Desktop\SF-RP\gamemodes\bensamp.pwn(1981) : warning 213: tag mismatch

BVar[businessid[currbusiness]][bpickupx] = x;
BVar[businessid[currbusiness]][bpickupy] = y;
BVar[businessid[currbusiness]][bpickupz] = z;
Reply
#2

pawn Код:
VALUES ('%d', '%d', '%d', '%d', '%s', '%d', '%d')", currbusiness, x, y, z
That is wrong in the first place.

That should be;

pawn Код:
VALUES ('%d', '%f', '%f', '%f', '%s', '%d', '%d')", currbusiness, x, y, z
The %f means Float.

That's one mistake.

Not sure about the other two.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)