#include <zcmd>
#include <dini>
#undef MAX_VEHICLES
#define MAX_VEHICLES 5 // 5 For now :)
enum vInfo
{
vModel, // Vehicle Model
Float:vPosx, // Vehicle X Position
Float:vPosy, // Vehicle Y Position
Float:vPosz, // Vehicle Z Position
Float:vPosa, // Vehicle A Position
vColor1, // Vehicle Color ID 1
vColor2, // Vehicle Color ID 2
vvw, // The virtual world of the vehicle
vPlate[10], // And last but not least the plate :) Not necessary but why not?
}
// Alright! Not falling asleep? GOOD!
new VehicleInfo[][vInfo] = // How it saves so 540 = vModel - -2937.5 = Float:vPosx - Ect, ect...
{
{540,-2937.5,-2927.5, 19.2819, 268.0262,1,1,0,"GSLS - 0"}, // This is ID 0 and is never used but keep it defined!
{540,-2947.5,-2927.5, 19.2819, 268.0262,1,1,0,"GSLS - 1"}, // ID 1
{540,-2957.5,-2927.5, 19.2819, 268.0262,1,1,0,"GSLS - 2"}, // ID 2
{540,-2967.5,-2927.5, 19.2819, 268.0262,1,1,0,"GSLS - 3"}, // ID 3
{540,-2977.5,-2927.5, 19.2819, 268.0262,1,1,0,"GSLS - 4"} // ID 4
};
public OnGameModeInit()
{
LoadVehicles(); // When you start/open the server it will Load all the vehicles we've set! (ID 1-4)
return 1;
}
stock LoadVehicles()
{
for(new i = 1; i < sizeof(VehicleInfo); i++) // This will loop through all the Vehicle's! Remember when we made the enum? Let me refresh your brain abit and reshow you the code we made : new VehicleInfo[][vInfo] = (This will get/load the vehicles)
{
if( !dini_Exists( CarFile(i) ) ) // If the file doesn't exist
{
dini_Create(CarFile(i)); // We will make the file (CarFile = We will script soon)
printf("%s created!", CarFile(i)); // This will basiclly print witch ID has been made inside the Server Console
new iStr[10]; // String for the plate itself
dini_IntSet(CarFile(i), "model", VehicleInfo[i][vModel]); // Here we set the Vehicle Model
dini_FloatSet(CarFile(i), "x", VehicleInfo[i][vPosx]); // Here we set the position X of the Vehicle
dini_FloatSet(CarFile(i), "y", VehicleInfo[i][vPosy]); // Here we set the position Y of the Vehicle
dini_FloatSet(CarFile(i), "z", VehicleInfo[i][vPosz]); // Here we set the position Z of the Vehicle
dini_FloatSet(CarFile(i), "a", VehicleInfo[i][vPosa]); // Here we set the position A of the Vehicle
dini_IntSet(CarFile(i), "color1", VehicleInfo[i][vColor1]); // Here we set the Color ID 1 of the vehicle
dini_IntSet(CarFile(i), "color2", VehicleInfo[i][vColor2]); // Here we set the Color ID 2 of the vehicle
dini_Set(CarFile(i), "plate", "GSLS-NONREG"); // And last but not least the plate :)
CreateVehicle(VehicleInfo[i][vModel],VehicleInfo[i][vPosx], VehicleInfo[i][vPosy],VehicleInfo[i][vPosz],VehicleInfo[i][vPosa], VehicleInfo[i][vColor1],VehicleInfo[i][vColor2], 500000); // Alright! This is the code to create the vehicle. Zelf explainitory really... But the "500000" is basiclly the respawn timer
format(iStr, sizeof(iStr), "GSLS - %d", i); // We will not format the plate and set it later on
SetVehicleNumberPlate(i, iStr); // Here we set the plate, Depending on the ID so if I was infront of CAR ID 2 it will show GSLS - 2.
}
else
{
LoadVehicle(i); // If the file does exist it will load all the info from the .ini car file. (We will create the stock for it now.)
}
}
}
// NOTE: Compiling now will give you alot of errors!
stock LoadVehicle(i) // If the .ini car file does exist it will execute this stock.
{
// All these lines will load the .ini CarFile. I explained everything before so this doesn't need explaining I guess :) If you have any questions feel free the tell me via a Reply on this topic.
new iStr[10];
VehicleInfo[i][vModel] = dini_Int(CarFile(i), "model");
VehicleInfo[i][vPosx] = dini_Float(CarFile(i), "x");
VehicleInfo[i][vPosy] = dini_Float(CarFile(i), "y");
VehicleInfo[i][vPosz] = dini_Float(CarFile(i), "z");
VehicleInfo[i][vPosa] = dini_Float(CarFile(i), "a");
VehicleInfo[i][vColor1] = dini_Int(CarFile(i), "color1");
VehicleInfo[i][vColor2] = dini_Int(CarFile(i), "color2");
myStrcpy(VehicleInfo[i][vPlate],dini_Get(CarFile(i), "plate"));
CreateVehicle(VehicleInfo[i][vModel],VehicleInfo[i][vPosx], VehicleInfo[i][vPosy],VehicleInfo[i][vPosz],VehicleInfo[i][vPosa], VehicleInfo[i][vColor1],VehicleInfo[i][vColor2], 500000);
format(iStr, sizeof(iStr), "GSLS - %d", i);
SetVehicleNumberPlate(i, iStr);
SetVehicleToRespawn(i); // Respawn's the vehicle itself
}
stock CarFile(vID)
{
new fn[20];
format(fn, sizeof(fn), "Cars/Car%d.txt", vID);
return fn;
}
stock myStrcpy(dest[], src[])
{
new i = 0;
while ((dest[i] = src[i])) i++;
}
dini_Create to DOF2_CreateFile
dini_IntSet to DOF2_SetInt
dini_FloatSet to DOF2_SetFloat
dini_Set to DOF2_SetString
dini_Int to DOF2_GetInt
dini_Float to DOF2_GetFloat
dini_Get to DOF2_GetString
Thought of using Y_ini but I do preffer dini even though its outdated ooh well... :P
|
Thought of using Y_ini but I do preffer dini even though its outdated ooh well... :P
|
Regardless of your personal taste, a tutorial needs to use the best methods. People assume that whatever's in a tutorial is the best method, merely because it is in a tutorial.
|
Regardless of your personal taste, a tutorial needs to use the best methods. People assume that whatever's in a tutorial is the best method, merely because it is in a tutorial.
|
I don't see how or why I can't use my personal taste? I can make tutorials on what and how I want
|