Selling vehicle at half price
#1

Hello guys

i have a problem selling my car at the half of the real price problem is i dont get half of price i get random numbers but same car model, here is my code :


Vehicle shop enum:


PHP код:
enum ShopVehiclesData
{
    
VehicleModel,
    
VehicleID,
    
Price,
    
FloatvPos_X,
    
FloatvPos_Y,
    
FloatvPos_Z,
    
FloatvPos_A
};
new 
ShopVehicles[33][ShopVehiclesData] =
{
    
//{Vehicle Model, -1, Price, PosX, PosY, PosZ, PosA} <--- this is example 
    
{411, -150000561.0876,-1289.7925,16.9753,21.1978}, //Infernus
    
{429, -123000557.0084,-1291.0620,16.9279,20.9678}, //Banshee
    
{451, -120000552.8647,-1291.4087,16.9558,22.4345}, //Turismo
    
{541, -125000548.1733,-1291.7915,16.8731,18.5864}, //Bullet
}; 
Selling Checkpoint:

PHP код:
if(listitem == 2)
{
    new 
vsellstring[128];
    if(
pInfo[playerid][pcar] ==0) return SendClientMessage(playerid,0xAA3333AA"{F81414}[ Error ]: {FFFFFF}You dont own a car!");
    
format(vsellstringsizeof(vsellstring), "You selling your %s price as %d !"VehicleNames2[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400], ShopVehiclesVehicleSelected[playerid]] ][Price]/2);
    
ShowPlayerDialog(playeridDIALOG_CONFIRM_VEHICLE_SELLDIALOG_STYLE_MSGBOX"DealerShip"vsellstring"Sell""Cancel");

And this is confirmation :

PHP код:
    if(dialogid == DIALOG_CONFIRM_VEHICLE_SELL)
    {
        if(
response)
        {
            
SendClientMessage(playeridGREEN"{EE5555}[SERVERIS]{FFFFFF} Your sold your car");
            
GivePlayerMoney(playeridShopVehiclesVehicleSelected[playerid] ][Price]/2);
            
RemovePlayerFromVehicle(playerid);
        }
    } 
Reply
#2

Try:

pawn Код:
if(listitem == 2)
{
    new vsellstring[128];
    if(pInfo[playerid][pcar] ==0) return SendClientMessage(playerid,0xAA3333AA, "{F81414}[ Error ]: {FFFFFF}You dont own a car!");
    new Float:sellprice = floatdiv(ShopVehicles[VehicleSelected[playerid]][Price], 2.0);
    format(vsellstring, sizeof(vsellstring), "You selling your %s price as $%.2f!", VehicleNames2[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400], sellprice);
    ShowPlayerDialog(playerid, DIALOG_CONFIRM_VEHICLE_SELL, DIALOG_STYLE_MSGBOX, "DealerShip", vsellstring, "Sell", "Cancel");
}
Reply
#3

Quote:
Originally Posted by Schneider
Посмотреть сообщение
Try:

pawn Код:
if(listitem == 2)
{
    new vsellstring[128];
    if(pInfo[playerid][pcar] ==0) return SendClientMessage(playerid,0xAA3333AA, "{F81414}[ Error ]: {FFFFFF}You dont own a car!");
    new Float:sellprice = floatdiv(ShopVehicles[VehicleSelected[playerid]][Price], 2.0);
    format(vsellstring, sizeof(vsellstring), "You selling your %s price as $%.2f!", VehicleNames2[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400], sellprice);
    ShowPlayerDialog(playerid, DIALOG_CONFIRM_VEHICLE_SELL, DIALOG_STYLE_MSGBOX, "DealerShip", vsellstring, "Sell", "Cancel");
}
Thank you man that worked
Reply
#4

You're welcome, don't forget to do the same method with the giveplayermoney-function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)