SA-MP Forums Archive
Multiplying costs. - 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: Multiplying costs. (/showthread.php?tid=607246)



Multiplying costs. - GunZsmd - 16.05.2016

Hi guys,
So im trying to multiply a car cost by 0.9 (10% cheaper) if hes gasoline. however when i go ingame and i try it, i get a huge ammount of negative cash.

PHP код:
precoveiculo *= 0.9
So could anyone tell me whats wrong or how it is suppost to be made? Because the number it multiplies by 0.9 is 60k that im currently testing and its suppost to get 54k no decimal numbers or anything.


Re: Multiplying costs. - AbyssMorgan - 16.05.2016

PHP код:
precoveiculo floatround(precoveiculo*0.9); 



Re: Multiplying costs. - GunZsmd - 16.05.2016

Ok i made that and now my script just spams the hell out of the messages like a loop.
Heres the script:
PHP код:
if(dialogid == 169)
{
    if(
response)
    {
        
TogglePlayerControllable(playerid1);
        new 
TCarModel GetVehicleModel(carroapresentar[playerid]);
        
escolhacombustivel[playerid] = 1;
        new 
valorveiculo TCarModel-400;
        new 
precoveiculo VehiclePrices[valorveiculo][0];
        if(
listitem == 0)
        {
            
tipocombustivel[playerid] = 1;
        }
        if(
listitem == 1)
        {
            
tipocombustivel[playerid] = 2;
            
precoveiculo floatround(precoveiculo*0.9);
        }
            for(new 
c=0;c<MAX_VEHICLES;c++)
            {
                if(
DynamicCars[c][comprado] != 0) continue;
                if(
DynamicCars[c][valor] != 0) continue;
                if(
DynamicCars[c][buy] != 1) continue;
                if(
DynamicCars[c][CarModel] != 481) continue;
                if(!
IsValidModel(TCarModel))
                    return 
SendClientMessage(playeridCOLOR_RED,"{FF0000}[Erro]: {FFFFFF}Modelo Invбlido.");
                
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                
SendClientMessage(playeridCOLOR_WHITE"Compraste o veiculo com sucesso. Este aparecerб na marinha de Palomino Creek em 10 horas ingame");
                
SendClientMessage(playeridCOLOR_GREY"========================================================================================================");
                
SetTimerEx("buyvehtime"2000false"iii"playeridTCarModelc);
                if(
PlayerInfo[playerid][pVipActive] != 0)
                {
                    
GivePlayerEuros(playerid, -precoveiculo/2);
                    
Businesses[1][Products]=Businesses[1][Products]-(precoveiculo/2/100);
                       
Businesses[1][Till]+=precoveiculo;
                    
OnPlayerDataSave(playerid);
                }
                else
                {
                    
GivePlayerEuros(playerid, -precoveiculo);
                    
Businesses[1][Products]=Businesses[1][Products]-(precoveiculo/100);
                       
Businesses[1][Till]+=precoveiculo;
                }
                if(
PlayerInfo[playerid][pChave1] == 255)
                {
                       
PlayerInfo[playerid][pChave1] = c+1;
                      return 
1;
                }
                else if(
PlayerInfo[playerid][pChave2] == 255)
                {
                      
PlayerInfo[playerid][pChave2] = c+1;
                    return 
1;
                }
                else if(
PlayerInfo[playerid][pChave3] == 255)
                {
                    
PlayerInfo[playerid][pChave3] = c+1;
                    return 
1;
                }
                else if(
PlayerInfo[playerid][pChave4] == 255)
                {
                    
PlayerInfo[playerid][pChave4] = c+1;
                    return 
1;
                }
                else if(
PlayerInfo[playerid][pChave5] == 255)
                {
                    
PlayerInfo[playerid][pChave5] = c+1;
                      return 
1;
                }
                else if(
PlayerInfo[playerid][pChave6] == 255)
                {
                   
PlayerInfo[playerid][pChave6] = c+1;
                   return 
1;
                }
            }
            return 
1;
    }