About trunks. -
Zh3r0 - 14.07.2011
Well, I'm trying to convert a Roleplay gamemode from standard file system, to SQLite, but since I got zero experience how a Role-Play works, I want to ask the experts.
Till now everything went well, no confusions, but when I reached the Trunks file I just saw this:
pawn Код:
0,0,0,0,0,0,0,0,0,0.000000
0,0,0,0,0,0,0,0,0,0.000000
0,0,0,0,0,0,0,0,0,0.000000
0,0,0,0,0,0,0,0,0,0.000000
0,0,0,0,0,0,0,0,0,0.000000
0,0,0,0,0,0,0,0,0,0.000000
0,0,0,0,0,0,0,0,0,0.000000
//Continues like that for about 200+ lines
What values these number will receive? I can clearly see only the fact that the last parameter is a float.
I need more information about this so I can convert it properly.
Re: About trunks. -
Steven82 - 14.07.2011
Offtopic:
I have also always wanted to know how the trunk system works.
Re: About trunks. -
Flyfishes - 14.07.2011
Show use the trunk enum. I think the first number is id. The second is weaponmodel for weapon 1. Third is ammo for weapon 1 etc. The last float is armour i bet.
Re: About trunks. -
Zh3r0 - 14.07.2011
Quote:
Originally Posted by Flyfishes
Show use the trunk enum. I think the first number is id. The second is weaponmodel for weapon 1. Third is ammo for weapon 1 etc. The last float is armour i bet.
|
Just studied the script and yes, the last parameter is armor.
pawn Код:
vehTrunk[idx][1] = strval(arrCoords[0]);
vehTrunkAmmo[idx][1] = strval(arrCoords[1]);
vehTrunk[idx][2] = strval(arrCoords[2]);
vehTrunkAmmo[idx][2] = strval(arrCoords[3]);
vehTrunk[idx][3] = strval(arrCoords[4]);
vehTrunkAmmo[idx][3] = strval(arrCoords[5]);
vehTrunk[idx][4] = strval(arrCoords[6]);
vehTrunkAmmo[idx][4] = strval(arrCoords[7]);
vehTrunkCounter[idx] = strval(arrCoords[8]);
vehTrunkArmour[idx] = floatstr(arrCoords[9]);
I now see how those get read, now lets see how its used...
Re: About trunks. -
DRIFT_HUNTER - 14.07.2011
Its just storing weapon ID and Ammo
Same like any other system...
I see that delimiter is
, so you will find split/explode or sscanf on trunk load
System as for houses,cars ect....
At server start you read data from file and store them to variables (enum) and when server shut down you save them (Some people save them after every change or every X amount of time)
Re: About trunks. -
Zh3r0 - 14.07.2011
Quote:
Originally Posted by DRIFT_HUNTER
Its just storing weapon ID and Ammo
Same like any other system...
I see that delimiter is , so you will find split/explode or sscanf on trunk load
System as for houses,cars ect....
At server start you read data from file and store them to variables (enum) and when server shut down you save them (Some people save them after every change or every X amount of time)
|
I know that it uses a delimiter, that's not a problem at all, as SQLite uses columns, which is better.
But I get stuck at understanding the following code.
pawn Код:
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%i,%i,%i,%i,%i,%i,%i,%i,%i,%f\n",
vehTrunk[idx][1],
vehTrunkAmmo[idx][1],
vehTrunk[idx][2],
vehTrunkAmmo[idx][2],
vehTrunk[idx][3],
vehTrunkAmmo[idx][3],
vehTrunk[idx][4],
vehTrunkAmmo[idx][4],
vehTrunkCounter[idx],
vehTrunkArmour[idx]);
if(idx == 1)
{
file2 = fopen("LARP/Trunks/trunk.cfg", io_write);
}
else
{
file2 = fopen("LARP/Trunks/trunk.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
Ok, the part that I don't understand is
pawn Код:
if(idx == 1)
{
file2 = fopen("LARP/Trunks/trunk.cfg", io_write);
}
else
{
file2 = fopen("LARP/Trunks/trunk.cfg", io_append);
}
Does it re-write them or "update" ?
Also this code is part of a while function, and the idx integer value is 184, why?
Re: About trunks. -
DRIFT_HUNTER - 14.07.2011
Quote:
Originally Posted by Zh3r0
I know that it uses a delimiter, that's not a problem at all, as SQLite uses columns, which is better.
But I get stuck at understanding the following code.
pawn Код:
new coordsstring[256]; format(coordsstring, sizeof(coordsstring), "%i,%i,%i,%i,%i,%i,%i,%i,%i,%f\n", vehTrunk[idx][1], vehTrunkAmmo[idx][1], vehTrunk[idx][2], vehTrunkAmmo[idx][2], vehTrunk[idx][3], vehTrunkAmmo[idx][3], vehTrunk[idx][4], vehTrunkAmmo[idx][4], vehTrunkCounter[idx], vehTrunkArmour[idx]); if(idx == 1) { file2 = fopen("LARP/Trunks/trunk.cfg", io_write); } else { file2 = fopen("LARP/Trunks/trunk.cfg", io_append); } fwrite(file2, coordsstring); idx++; fclose(file2);
Ok, the part that I don't understand is
pawn Код:
if(idx == 1) { file2 = fopen("LARP/Trunks/trunk.cfg", io_write); } else { file2 = fopen("LARP/Trunks/trunk.cfg", io_append); }
Does it re-write them or "update" ?
Also this code is part of a while function, and the idx integer value is 184, why?
|
we have IDX 0 and we will add 1 to it for each formatted and write'd line so while idx is lover than a max_something server will save lines to file (until it gets to max_something)
io_write writes a FIRST LINE AND OVERRIDE everything alse
io_append writes a line at the end of the file
you see if idx is 1 (first line) it will override file if idx is not 1 it must be 2,3 or whatever but not lover so it will just add line at the end of the file
[EDIT]Since you converting it to sqlLite you will just need to update that info
Re: About trunks. -
Zh3r0 - 14.07.2011
Quote:
Originally Posted by DRIFT_HUNTER
we have IDX 0 and we will add 1 to it for each formatted and write'n line so while idx is lover than a max_something server will save lines to file (until it gets to max_something)
io_write writes a FIRST LINE AND OVERRIDE everything alse
io_append writes a line at the end of the file
[EDIT]Since you converting it to sqlLite you will just need to update that info
|
Thanks, that helped me understand the parameters of fopen.
EDIT: Just wanted something else to ask, what's with the idx being so high?
pawn Код:
new idx = 184;
while (idx < sizeof(CarInfo))
{
//code code
idx++;
}
BTW, I'm also adding a `Key` that auto-increments, does it matter?