SA-MP Forums Archive
Paying for car in car system issue - 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: Paying for car in car system issue (/showthread.php?tid=426387)



Paying for car in car system issue - ethman326 - 28.03.2013

So I have this car script that allows me to spawn cars etc dynamically and when you get in a dialog box pops up asking if you want to buy the car or not. When I guy it, it spawns my car and I own it and everything, but it doesn't deduct the price of the car out of my money, I have no idea how to change it either. The code for when you buy it is below and for some reason it doesn't like I said deduct the price of the car. Please help.






case 1:
{
GivePlayerMoney(playerid, -DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice]);
format(string, sizeof(string), "You have purchased a %s for $%d, for more help regarding your purchase, type /carhelp.", GetVehicleName(GetPlayerVehicleID(playerid)), DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice]);
SendClientMessage(playerid, YELLOW, string);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
return 1;
}


Re: Paying for car in car system issue - JJB562 - 28.03.2013

Try adding a new variable(like this):
pawn Код:
case 1:
{
new vehiclemoney;
vehiclemoney = DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice];
GivePlayerMoney(playerid, -vehiclemoney);
format(string, sizeof(string), "You have purchased a %s for $%d, for more help regarding your purchase, type /carhelp.", GetVehicleName(GetPlayerVehicleID(playerid)), DealershipVehicles[GetPlayerVehicleID(playerid)][vPrice]);
SendClientMessage(playerid, YELLOW, string);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
return 1;
}



Re: Paying for car in car system issue - Joshman543 - 28.03.2013

How is your [vPrice] changed/defined?


Re: Paying for car in car system issue - zxc1 - 28.03.2013

Maybe you've got another money variable in your script.
For example in my script, when I add someone certain amount of cash, I don't only use GivePlayerMoney, I save it in another variable inside PlayerInfo, to avoid money cheats. Check that..


Re: Paying for car in car system issue - ethman326 - 29.03.2013

Idk if its supposed to be = to 0 or what Btw that case doesn't work, it takes the money away but then for some reason it counts back up to the original amount I had like I mean it gives me the money I spent on the car back like a refund.






DealershipVehicles[vehicleid][vPrice] = 0;

and there is this

DealershipVehicles[vehicleid][vPrice] = price;


Re: Paying for car in car system issue - ethman326 - 29.03.2013

*bump*


Re: Paying for car in car system issue - ethman326 - 29.03.2013

*bump* again, someone help please.