function GetVehiclePrice(player)
{
if ( player.Vehicle ) {
return ReadIniInteger("vdb.ini", "Vehicle" + player.Vehicle.ID, "Price");
}
}
This code always returns "true" when it should display the price of vehicle
how do i fix that?
tried this with my role and I know well but not is you because you may have different the code if you like raisins all lcodigopara see as it is and fix it
function GetVehiclePrice(player)
{
local VehicleID2=ReadIniNumber( "vdb.ini", ""+player.Vehicle.ID+"", "Price");
if(VehicleID2 !=null)
{
return VehicleID2;
}
return 0;
}
not work( still returns true
Quote from: JiN_KaZaMa on Dec 10, 2016, 08:18 PMnot work( still returns true
I did a cost, owner, shared system of vehicle
http://forum.vc-mp.org/?topic=3499.new#new
Check for another function with the same name. You've done that mistake many times though :p
Dont you hate it when that happens?
Well at-least try this code, This worked for me, So I modified the code to work for your script. I hope it works....
function GetVehiclePrice(player)
{
local Price;
Price = ReadIniInteger("vdb.ini", "Vehicle" + player.Vehicle.ID, "Price");
if ( Price != null )
return Price;
return 0;
}
And If not IDK I would just play with the bool
function GetVehiclePrice(player)
{
local Price;
Price = ReadIniInteger("vdb.ini", "Vehicle" + player.Vehicle.ID, "Price");
if ( Price ) //It's true
{
if ( Price != null ) return Price;
}
return 0;
}
you could attempt to read it as a string first the change the value to be an integer.
local convert = ReadIniString("vdb.ini", "Vehicle" + player.Vehicle.ID, "Price");
convert.tointeger()
etc etc
just saying, Try goofing around with it
sorry just woke up and heading to work
Quote from: Mötley on Dec 11, 2016, 01:03 PM if ( Price ) //It's true
{
if ( Price != null ) return Price;
}
}
I didn't really expected that from you.
Quote from: Xmair on Dec 11, 2016, 01:28 PMQuote from: Mötley on Dec 11, 2016, 01:03 PM if ( Price ) //It's true
{
if ( Price != null ) return Price;
}
}
I didn't really expected that from you.
You sure tho?
local Price;
Price = ReadIniInteger(...);
Quote from: . on Dec 11, 2016, 01:37 PMQuote from: Xmair on Dec 11, 2016, 01:28 PMQuote from: Mötley on Dec 11, 2016, 01:03 PM if ( Price ) //It's true
{
if ( Price != null ) return Price;
}
}
I didn't really expected that from you.
You sure tho?
local Price;
Price = ReadIniInteger(...);
Now both of you have me questioning this, This worked for me in the past as the file read something so it returned true instead, Then checking if that value is not null "Doesn't exist, an error whatever", It returns zero instead blah blah..
I will await for Kewuns Answer I suppose
Kewun, Could you add
print("The returned value: " + Price)
yes it worked thanks @Motley
Quote from: JiN_KaZaMa on Dec 11, 2016, 02:08 PMyes it worked thanks @Motley
ROFL, this is the first time I'm seeing something like this lol
There are many reasons as to why this is correct. Do I need to elaborate just a little?
Quote from: Mötley on Dec 11, 2016, 09:25 PMThere are many reasons as to why this is correct. Do I need to elaborate just a little?
No, you don't. Actually, when you use ReadIniInteger, you must expect a integer. If the file doesn't exist, it should throw an error instead of returning true or false. This will make all the newbies confused...( though no one uses the original INI plugin these days... )
stop spam