SA-MP Forums Archive
Problem with buying vehicle - Not enough money false error. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with buying vehicle - Not enough money false error. (/showthread.php?tid=315569)



Problem with buying vehicle - Not enough money false error. - milanosie - 03.02.2012

So, I checked files, pricelabel, everything,

Everything tells me that the car I just created is 740k.

I hold 5.5 mil in my hand, I try to buy the car and it tells me that I dont have enough money.
I cant spot the mistake I made, if there even is one.
Could anyone give me some help here?
btw: Please don't copy this code for your own purposes

pawn Код:
CMD:buycar(playerid, params[])
{
    if(PlayerInfo[playerid][Vehkey] == 9999 ||PlayerInfo[playerid][Vehkey2] == 9998 || PlayerInfo[playerid][Vehkey3] == 99997)
    {
        new pvehid = GetPlayerVehicleID(playerid);
        if(IsPlayerInAnyVehicle(playerid))
        {
            format(file4, sizeof(file4), "realityrp/vehicles/%d.ini", pvehid);
            if(vehiforsale[GetPlayerVehicleID(playerid)] == 1)
            {
                if(fexist(file4))
                {
                    carprice[pvehid] = dini_Int(file4, "Vehprice");
                    if(GetPlayerMoney(playerid) >= carprice[pvehid])
                    {
                        if(vehiforsale[GetPlayerVehicleID(playerid)] == 1)
                        {
                            new name[MAX_PLAYER_NAME];
                            new vehicle[24];
                            new string[128];
                            GetPlayerName(playerid, name, sizeof(name));
                            dini_IntSet(file4, "owner", CarInfo[pvehid][owner] = PlayerInfo[playerid][Pid]);
                            dini_IntSet(file4, "forsale",CarInfo[pvehid][forsale] = 0);
                            dini_IntSet(file4, "CarLock",CarInfo[pvehid][CarLock] = 0);
                            dini_Set(file4, "OwnerName", name);
                            GivePlayerMinusCash(playerid, carprice[pvehid]);
                            GetVehicleName(pvehid, vehicle, sizeof(vehicle));
                            format(string, sizeof(string), "Congratulations! You bought a %s", vehicle);
                            SendClientMessage(playerid, COLOR_GREEN, string);
                            Delete3DTextLabel(VehicleLabel[pvehid]);
                            vehiforsale[pvehid] = 0;
                            TogglePlayerControllable(playerid, 1);
                            if(PlayerInfo[playerid][Vehkey] == 9999)
                            {
                                PlayerInfo[playerid][Vehkey] = pvehid;
                            }
                            else if(PlayerInfo[playerid][Vehkey2] == 9998)
                            {
                                PlayerInfo[playerid][Vehkey2] = pvehid;
                            }
                            else if(PlayerInfo[playerid][Vehkey3] == 9997)
                            {
                                PlayerInfo[playerid][Vehkey3] = pvehid;
                            }
                            return 1;
                        }
                        else return SendClientMessage(playerid, COLOR_GREY, "This vehicle is not for sale");
                    }
                    else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money for this!");
                }
                else return SendClientMessage(playerid, COLOR_GREY, "This vehicle is not for sale");
            }
            else return SendClientMessage(playerid, COLOR_GREY, "This vehicle is not for sale!");
        }
        else return SendClientMessage(playerid, COLOR_GREY, "You must be in a vehicle to do this!");
    }
    else return SendClientMessage(playerid, COLOR_GREY, "You already own the maximum amount of vehicles!");
}



Re: Problem with buying vehicle - Not enough money false error. - Scenario - 03.02.2012

I would say that "carprice[pvehid]" isn't <= the amount of money the player has.