[HELP] Money Back
#1

I put an FS with dealership system. But, when i want to buy a vehicle, my money descrease, and then increase in how much money I had before

pawn Код:
if(dialogid == DIALOG_VEHICLE_BUY)
    {
        if(response)
        {
            if(GetPlayerVehicles(playerid) >= MAX_PLAYER_VEHICLES)
            {
                ShowErrorDialog(playerid, "You can't buy any more vehicles! Max: " #MAX_PLAYER_VEHICLES );
                return 1;
            }
            new id = GetPVarInt(playerid, "DialogValue1");
            if(GetPlayerMoney(playerid) < VehicleValue[id])
            {
                ShowErrorDialog(playerid, "You don't have enough money to buy this vehicle!");
                return 1;
            }
            new freeid = GetFreeVehicleID();
            if(!freeid)
            {
                ShowErrorDialog(playerid, "Vehicle dealership is out of stock!");
                return 1;
            }
            GivePlayerMoney(playerid, -VehicleValue[id]);
            new dealerid = strval(VehicleOwner[id]);
            VehicleCreated[freeid] = VEHICLE_PLAYER;
            VehicleModel[freeid] = VehicleModel[id];
            VehiclePos[freeid] = DealershipPos[dealerid];
            VehicleColor[freeid] = VehicleColor[id];
            VehicleInterior[freeid] = VehicleInterior[id];
            VehicleWorld[freeid] = VehicleWorld[id];
            VehicleValue[freeid] = VehicleValue[id];
            GetPlayerName(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
            VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
            for(new d=0; d < sizeof(VehicleTrunk[]); d++)
            {
                VehicleTrunk[freeid][d][0] = 0;
                VehicleTrunk[freeid][d][1] = 0;
            }
            for(new d=0; d < sizeof(VehicleMods[]); d++)
            {
                VehicleMods[freeid][d] = 0;
            }
            VehiclePaintjob[freeid] = 255;
            VehicleLock[freeid] = 0;
            VehicleAlarm[freeid] = 0;
            UpdateVehicle(freeid, 0);
            SaveVehicle(freeid);
            new msg[128];
            format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
            SendClientMessage(playerid, COLOR_WHITE, msg);
        }
        else
        {
            new id = GetPVarInt(playerid, "DialogValue1");
            if(GetPlayerVehicleAccess(playerid, id) < 1)
            {
                RemovePlayerFromVehicle(playerid);
            }
        }
        return 1;
    }
PS: In my GM a have another ds system.
Reply
#2

Its probably because you have a stock function to give money to players in your server for example, i have RewardPlayer(playerid, money, score); function in my server. It was made to prevent the hackers from using a money cheat which also blocks GivePlayerMoney function. So i guess that maybe the reason its resetting the player money. Search for the stock function in your gamemode and replace GivePlayerMoney with it.

I had the same problem while using some filterscripts in my server but later found out there was a stock function created. I would suggest you to convert your filterscripts to your gamemode as long as the stock function that is created in your gamemode won't work in any FS(s).
Reply
#3

I guess you are probably having few lines under OnPlayerUpdate which constantly checks how much money does player have and if there is difference, it will give the player their saved amount of money which is probably in some enum. The problem is your dealership FS decreases player's money, and your gamemode is changing it back to saved amount. You will need to connect that FS and your GM so you can know when player buys something so you can change their money in your enum.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)