// Maksimalno tuninga po igraču
#define MAX_TUNINGS 50
// Čuvanje tuninga u memoriji za brzi load
new TuningName[MAX_PLAYERS][MAX_TUNINGS][64];
new TuningVehicleID[MAX_PLAYERS][MAX_TUNINGS];
new TuningCount[MAX_PLAYERS];
// ==============================
// Save tuning
// ==============================
public SaveTuning(playerid, vehicleid, name[])
{
if(TuningCount[playerid] >= MAX_TUNINGS)
{
SendClientMessage(playerid, 0xFF0000AA, "You reached max tunings!");
return 0;
}
new index = TuningCount[playerid];
strcopy(TuningName[playerid][index], sizeof(TuningName[][]), name);
TuningVehicleID[playerid][index] = vehicleid;
// Save to ini
new section[64];
format(section, sizeof(section), "Tuning_%d_%d", playerid, vehicleid);
Y_INI_SetInt("tunings.ini", section, "Color1", GetVehicleColor(vehicleid, 0));
Y_INI_SetInt("tunings.ini", section, "Color2", GetVehicleColor(vehicleid, 1));
Y_INI_SetInt("tunings.ini", section, "Health", GetVehicleHealth(vehicleid));
Y_INI_SetInt("tunings.ini", section, "Nitro", GetVehicleNitro(vehicleid));
Y_INI_SetInt("tunings.ini", section, "Engine", GetVehicleEngine(vehicleid));
// Dodaj ostale parametre po potrebi
TuningCount[playerid]++;
SendClientMessage(playerid, 0x00FF00AA, "Tuning saved successfully!");
return 1;
}
// ==============================
// Load tuning
// ==============================
public LoadTuning(playerid, vehicleid)
{
new section[64];
format(section, sizeof(section), "Tuning_%d_%d", playerid, vehicleid);
if(!Y_INI_Exists("tunings.ini", section))
{
// tuning ne postoji
return 0;
}
new color1 = Y_INI_GetInt("tunings.ini", section, "Color1", 0);
new color2 = Y_INI_GetInt("tunings.ini", section, "Color2", 0);
new health = Y_INI_GetInt("tunings.ini", section, "Health", 1000);
new nitro = Y_INI_GetInt("tunings.ini", section, "Nitro", 0);
new engine = Y_INI_GetInt("tunings.ini", section, "Engine", 100);
SetVehicleColor(vehicleid, color1, color2);
SetVehicleHealth(vehicleid, health);
SetVehicleNitro(vehicleid, nitro);
SetVehicleEngine(vehicleid, engine);
// Dodaj ostale parametre po potrebi
return 1;
}
// ==============================
// Automatski load pri spawn-u
// ==============================
public OnPlayerSpawn(playerid)
{
for(new i = 0; i < MAX_TUNINGS; i++)
{
new vehicleid = TuningVehicleID[playerid][i];
if(vehicleid != 0 && IsVehicleStreamedInForPlayer(vehicleid, playerid))
{
LoadTuning(playerid, vehicleid);
}
}
return 1;
}
// ==============================
// ZCMD komande
// ==============================
CMD:savetuning(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == 0)
{
SendClientMessage(playerid, 0xFF0000AA, "You must be in a vehicle to save tuning!");
return 0;
}
new name[32];
if(sscanf(params, "s[32]", name))
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: /savetuning [name]");
return 0;
}
SaveTuning(playerid, vehicleid, name);
return 1;
}
CMD:loadtuning(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == 0)
{
SendClientMessage(playerid, 0xFF0000AA, "You must be in a vehicle to load tuning!");
return 0;
}
LoadTuning(playerid, vehicleid);
return 1;
}