Simple problem please help
#1

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.
Reply
#2

shwo how have u defined VEH_FILE
and also what is VehicleInfo[v][vValue] and how does it changes?
Reply
#3

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$
Reply
#4

i mean what does VehicleInfo[v][vValue] contain? how do you change it, where is this variable used?
Reply
#5

I tried with
pawn Код:
new vehValue;
Then when the vehicle creates
pawn Код:
VehicleInfo[v][vValue] = vehValue;
And when you buy the vehicle:
pawn Код:
vehValue = 2000000;
Reply
#6

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?
Reply
#7

I want it to get the vehicle value...
Reply
#8

you mean vehicle id?
Reply
#9

The vehicle value, which is 2000000, then give the player the money, which is the vehicle value
Reply
#10

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
Reply
#11

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
Reply
#12

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
Reply
#13

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...)
Reply
#14

I use Y_Ini, please tell me how can I read the value and put the value in that variable?
Reply
#15

https://sampforum.blast.hk/showthread.php?pid=1138420#pid1138420
Reply
#16

Can you make me an example? Please I'm a noob.
Reply
#17

removed, sorry saw it
Reply
#18

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).
Reply
#19

I did
pawn Код:
new vv = VehicleInfo[v][vValue];
but it gives me 0$ even though the value it's set to 2000000
Reply
#20

Please help..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)