Simple problem please help -
friezakinght - 06.07.2014
Hi, I tried making a variable that reads a car value from the file
pawn Код:
new vv = format(file, sizeof(file), VEH_FILE, VehicleInfo[v][vValue]);
The problem is it gives 1 instead of 2000000, please help.
Re: Simple problem please help -
BroZeus - 06.07.2014
shwo how have u defined VEH_FILE
and also what is VehicleInfo[v][vValue] and how does it changes?
Re: Simple problem please help -
friezakinght - 06.07.2014
pawn Код:
#define VEH_FILE "FRICNR/Vehicles/%d.ini"
VehicleInfo:
pawn Код:
enum FRICNR_vehicle
{
vModel,
vColor1,
vColor2,
vPrice,
vOwner[24],
Float:vPosX,
Float:vPosY,
Float:vPosZ,
Float:vPosA,
vPlate[32],
vPaintJob,
vLocked,
vNeons,
vFuel,
Float:vHealth,
vValue
}
new VehicleInfo[MAX_SHOP_VEHICLES][FRICNR_vehicle];
v:
pawn Код:
new v = GetPlayerVehicleID(playerid);
In the scriptfiles when I open the vehicle file at the value it says 2000000 but when I try to sell it and give the player cash with
pawn Код:
GivePlayerMoney(playerid, vv);
it gives the player 1$
Re: Simple problem please help -
BroZeus - 06.07.2014
i mean what does VehicleInfo[v][vValue] contain? how do you change it, where is this variable used?
Re: Simple problem please help -
friezakinght - 06.07.2014
I tried with
Then when the vehicle creates
pawn Код:
VehicleInfo[v][vValue] = vehValue;
And when you buy the vehicle:
Re: Simple problem please help -
BroZeus - 06.07.2014
thats why when u are setting it to 200000 then how will it be 1
what do u exactly want that the format line should do?
Re: Simple problem please help -
friezakinght - 06.07.2014
I want it to get the vehicle value...
Re: Simple problem please help -
BroZeus - 06.07.2014
you mean vehicle id?
Re: Simple problem please help -
friezakinght - 06.07.2014
The vehicle value, which is 2000000, then give the player the money, which is the vehicle value
Re: Simple problem please help -
BroZeus - 06.07.2014
oh that i didnt read the thread carefully
you cant read from file using "format"
what do u use for saving y_ini or dini and show us how u save its value in it
Re: Simple problem please help -
friezakinght - 06.07.2014
I use Y_ini, I think i already showed you how I save the value in it, i think the problem is at
pawn Код:
new vv = format(file, sizeof(file), VEH_FILE, VehicleInfo[v][vValue]);
and
pawn Код:
GivePlayerMoney(playerid, vv);
please help me i will +rep
Re: Simple problem please help -
BroZeus - 06.07.2014
where did u showed that how u save value in it?
You cannot read from files with format() function
Read the y_ini topic carefully to see how to read from files
Re: Simple problem please help -
Crayder - 06.07.2014
THE PROBLEM-
new vv = format(file, sizeof(file), VEH_FILE, VehicleInfo[v][vValue]);
format returns 1 because it worked, format does not store what you want...
You need to read the file like BroZues said... What file manager do you use? (EX: y_ini, dini, the default - from pawno, etc...)
Re: Simple problem please help -
friezakinght - 06.07.2014
I use Y_Ini, please tell me how can I read the value and put the value in that variable?
Re: Simple problem please help -
BroZeus - 06.07.2014
https://sampforum.blast.hk/showthread.php?pid=1138420#pid1138420
Re: Simple problem please help -
friezakinght - 06.07.2014
Can you make me an example? Please I'm a noob.
Re: Simple problem please help -
Sawalha - 06.07.2014
removed, sorry saw it
Re: Simple problem please help -
Konstantinos - 06.07.2014
format returns 1 as it executed successful so storing the value that returns makes absolutely no sense.
If vValue holds the value you want, then:
pawn Код:
new vv = VehicleInfo[v][vValue];
If you want to read from a file, you need to open the file, read and close it (there are tutorials about that though so I'm not going to explain it).
Re: Simple problem please help -
friezakinght - 06.07.2014
I did
pawn Код:
new vv = VehicleInfo[v][vValue];
but it gives me 0$ even though the value it's set to 2000000
Re: Simple problem please help -
friezakinght - 06.07.2014
Please help..