20.02.2014, 08:02
(
Последний раз редактировалось Swyft™; 20.02.2014 в 10:04.
)
So my friend has made me a dynamic job/faction vehicles and it has been filled with lots of issues but I think he fell asleep so I'm just going to ask here.
Basically it will create the car, but won't save to each faction/job..... It's weird.
SaveDynamicVehicles & LoadDynamicVehicles
All the cmds associated with it
Basically it will create the car, but won't save to each faction/job..... It's weird.
SaveDynamicVehicles & LoadDynamicVehicles
pawn Код:
stock SaveDynamicVehicles()
{
if (!fexist("dynamicvehicles.cfg"))
return fremove("dynamicvehicles.cfg");
new
File:file = fopen("dynamicvehicles.cfg", io_append),
str[128]
;
for (new i = 0; i < MAX_DYNAMIC_VEHICLES; i ++) {
format(str, sizeof(str), "%d|%d|%.4f|%.4f|%.4f|%.4f|%d|%d|%d|%d\r\n",
VehicleInfo[i][vExists],
VehicleInfo[i][vModel],
VehicleInfo[i][vPosX],
VehicleInfo[i][vPosY],
VehicleInfo[i][vPosZ],
VehicleInfo[i][vPosA],
VehicleInfo[i][vColor1],
VehicleInfo[i][vColor2],
VehicleInfo[i][vFaction],
VehicleInfo[i][vJob]
);
fwrite(file, str);
}
fclose(file);
return 1;
}
stock LoadDynamicVehicles()
{
if (!fexist("dynamicvehicles.cfg"))
return 0;
new
File:file = fopen("dynamicvehicles.cfg", io_read),
strRead[128],
arrData[10][16]
;
if (file)
{
for (new i = 0; i < MAX_DYNAMIC_VEHICLES; i ++) {
fread(file, strRead, sizeof(strRead));
split(strRead, arrData, '|');
VehicleInfo[i][vExists] = strval(arrData[0]);
VehicleInfo[i][vModel] = strval(arrData[1]);
VehicleInfo[i][vPosX] = floatstr(arrData[2]);
VehicleInfo[i][vPosY] = floatstr(arrData[3]);
VehicleInfo[i][vPosZ] = floatstr(arrData[4]);
VehicleInfo[i][vPosA] = floatstr(arrData[5]);
VehicleInfo[i][vColor1] = strval(arrData[6]);
VehicleInfo[i][vColor2] = strval(arrData[7]);
VehicleInfo[i][vFaction] = strval(arrData[8]);
VehicleInfo[i][vJob] = strval(arrData[9]);
if (VehicleInfo[i][vExists] && VehicleInfo[i][vModel] >= 400)
{
VehicleInfo[i][vRealID] = CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vPosX], VehicleInfo[i][vPosY], VehicleInfo[i][vPosZ], VehicleInfo[i][vPosA], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2], -1);
}
}
}
fclose(file);
return 1;
}
All the cmds associated with it
pawn Код:
CMD:savecar(playerid, params[])
{
new factionid, jobid, vehicleid = GetPlayerVehicleID(playerid), string[128];
if (PlayerInfo[playerid][pAdmin] < 5)
return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if (!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_GREY, "You are not inside any admin vehicle (/veh).");
if (sscanf(params, "dI(0)", factionid, jobid))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /savecar [factionid] [jobid]");
for (new i = 0; i < MAX_CUSTOM_VEHICLES; i ++) if (vehicleid == cVeh[i])
{
for (new j = 0; j < MAX_DYNAMIC_VEHICLES; j ++) if (!VehicleInfo[j][vExists])
{
VehicleInfo[j][vModel] = GetVehicleModel(vehicleid);
VehicleInfo[j][vColor1] = gVehicleColors[cVeh[i]][0];
VehicleInfo[j][vColor2] = gVehicleColors[cVeh[i]][1];
GetVehiclePos(vehicleid, VehicleInfo[j][vPosX], VehicleInfo[j][vPosY], VehicleInfo[j][vPosZ]);
GetVehicleZAngle(vehicleid, VehicleInfo[j][vPosA]);
VehicleInfo[j][vFaction] = factionid;
VehicleInfo[j][vJob] = jobid;
VehicleInfo[j][vExists] = 1;
VehicleInfo[i][vRealID] = vehicleid;
cVeh[i] = 0;
SaveDynamicVehicles();
format(string, sizeof(string), "* You have saved this %s (ID: %d)", GetVehicleName(vehicleid), vehicleid);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
}
SendClientMessage(playerid, COLOR_GREY, "The limit has been reached, or you aren't inside any admin vehicle.");
return 1;
}
CMD:deletecar(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid), string[128];
if (PlayerInfo[playerid][pAdmin] < 5)
return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if (!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_GREY, "You are not inside any vehicle.");
for (new i = 0; i < MAX_DYNAMIC_VEHICLES; i ++)
{
if (VehicleInfo[i][vExists] && VehicleInfo[i][vRealID] == vehicleid)
{
format(string, sizeof(string), "* You have destroyed this %s (ID: %d).", GetVehicleName(vehicleid), vehicleid);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
DestroyVehicle(VehicleInfo[i][vRealID]);
VehicleInfo[i][vExists] = 0;
VehicleInfo[i][vModel] = 0;
SaveDynamicVehicles();
return 1;
}
}
SendClientMessage(playerid, COLOR_GREY, "You are not inside any dynamic vehicle.");
return 1;
}