02.06.2011, 02:10
Whole script is not given.
When I go onto my server four vehicles are created where the one vehicle should be.
Enumeration
Forwards
OnGameModInit Callback
Load Vehicle Public
Save Vehicle Public
Save Vehicles Public
/setvehicle command used to create vehicle file.
Vehicles/0.ini File - "Owner" should equal nobody no reason why.
This is from my custom script. Please do not steal. Only posted for debugging purposes.
When I go onto my server four vehicles are created where the one vehicle should be.
Enumeration
PHP Code:
enum VehicleInfo {
Owner,
OwnerType,
Model,
Float:PosX,
Float:PosY,
Float:PosZ,
Float:PosA,
Color1,
Color2,
Mod0,
Mod1,
Mod2,
Mod3,
Mod4,
Mod5,
Mod6,
Mod7,
Mod8,
Mod9,
Mod10,
Mod11,
Mod12,
Mod13,
Paintjob,
ID
}
new vInfo[5000][VehicleInfo];
PHP Code:
forward LoadVehicle(vehicleid);
forward SaveVehicle(vehicleid);
forward SaveVehicles();
PHP Code:
public OnGameModeInit()
{
// ^^^ Other Crap ^^^ //
SetTimer("SaveVehicles", 60000, true);
LoadVehicle(0);
return 1;
}
PHP Code:
public LoadVehicle(vehicleid)
{
new file[256];
format(file, 256, "Vehicles/%i.ini", vehicleid);
format(vInfo[vehicleid][Owner], 256, "%s", dini_Get(file, "Owner"));
vInfo[vehicleid][OwnerType] = dini_Int(file, "OwnerType");
vInfo[vehicleid][Model] = dini_Int(file, "Model");
vInfo[vehicleid][PosX] = dini_Float(file, "PosX");
vInfo[vehicleid][PosY] = dini_Float(file, "PosY");
vInfo[vehicleid][PosZ] = dini_Float(file, "PosZ");
vInfo[vehicleid][PosA] = dini_Float(file, "PosA");
vInfo[vehicleid][Color1] = dini_Int(file, "Color1");
vInfo[vehicleid][Color2] = dini_Int(file, "Color2");
vInfo[vehicleid][Mod0] = dini_Int(file, "Mod0");
vInfo[vehicleid][Mod1] = dini_Int(file, "Mod1");
vInfo[vehicleid][Mod2] = dini_Int(file, "Mod2");
vInfo[vehicleid][Mod3] = dini_Int(file, "Mod3");
vInfo[vehicleid][Mod4] = dini_Int(file, "Mod4");
vInfo[vehicleid][Mod5] = dini_Int(file, "Mod5");
vInfo[vehicleid][Mod6] = dini_Int(file, "Mod6");
vInfo[vehicleid][Mod7] = dini_Int(file, "Mod7");
vInfo[vehicleid][Mod8] = dini_Int(file, "Mod8");
vInfo[vehicleid][Mod9] = dini_Int(file, "Mod9");
vInfo[vehicleid][Mod10] = dini_Int(file, "Mod10");
vInfo[vehicleid][Mod11] = dini_Int(file, "Mod11");
vInfo[vehicleid][Mod12] = dini_Int(file, "Mod12");
vInfo[vehicleid][Mod13] = dini_Int(file, "Mod13");
vInfo[vehicleid][Paintjob] = dini_Int(file, "Paintjob");
vInfo[vehicleid][ID] = CreateVehicle(vInfo[vehicleid][Model], vInfo[vehicleid][PosX], vInfo[vehicleid][PosY], vInfo[vehicleid][PosZ], vInfo[vehicleid][PosA], vInfo[vehicleid][Color1], vInfo[vehicleid][Color2], -1);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod0]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod1]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod2]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod3]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod4]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod5]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod6]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod7]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod8]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod9]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod10]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod11]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod12]);
AddVehicleComponent(vInfo[vehicleid][ID], vInfo[vehicleid][Mod13]);
ChangeVehiclePaintjob(vInfo[vehicleid][ID], vInfo[vehicleid][Paintjob]);
return 1;
}
PHP Code:
public SaveVehicle(vehicleid)
{
new file[256];
format(file, 256, "Vehicles/%i.ini", vehicleid);
if(!dini_Exists(file))
{
dini_Create(file);
}
dini_Set(file, "Owner", vInfo[vehicleid][Owner]);
dini_IntSet(file, "OwnerType", vInfo[vehicleid][OwnerType]);
dini_IntSet(file, "Model", vInfo[vehicleid][Model]);
dini_FloatSet(file, "PosX", vInfo[vehicleid][PosX]);
dini_FloatSet(file, "PosY", vInfo[vehicleid][PosY]);
dini_FloatSet(file, "PosZ", vInfo[vehicleid][PosZ]);
dini_FloatSet(file, "PosA", vInfo[vehicleid][PosA]);
dini_IntSet(file, "Color1", vInfo[vehicleid][Color1]);
dini_IntSet(file, "Color2", vInfo[vehicleid][Color2]);
dini_IntSet(file, "Mod0", vInfo[vehicleid][Mod0]);
dini_IntSet(file, "Mod1", vInfo[vehicleid][Mod1]);
dini_IntSet(file, "Mod2", vInfo[vehicleid][Mod2]);
dini_IntSet(file, "Mod3", vInfo[vehicleid][Mod3]);
dini_IntSet(file, "Mod4", vInfo[vehicleid][Mod4]);
dini_IntSet(file, "Mod5", vInfo[vehicleid][Mod5]);
dini_IntSet(file, "Mod6", vInfo[vehicleid][Mod6]);
dini_IntSet(file, "Mod7", vInfo[vehicleid][Mod7]);
dini_IntSet(file, "Mod8", vInfo[vehicleid][Mod8]);
dini_IntSet(file, "Mod9", vInfo[vehicleid][Mod9]);
dini_IntSet(file, "Mod10", vInfo[vehicleid][Mod10]);
dini_IntSet(file, "Mod11", vInfo[vehicleid][Mod11]);
dini_IntSet(file, "Mod12", vInfo[vehicleid][Mod12]);
dini_IntSet(file, "Mod13", vInfo[vehicleid][Mod13]);
dini_IntSet(file, "Paintjob", vInfo[vehicleid][Paintjob]);
return 1;
}
PHP Code:
public SaveVehicles()
{
for(new vehicleid = 0; vehicleid < 5000; vehicleid++)
{
if(vInfo[vehicleid][Model])
{
new file[256];
format(file, 256, "Vehicles/%i.ini", vehicleid);
if(!dini_Exists(file))
{
dini_Create(file);
}
dini_Set(file, "Owner", vInfo[vehicleid][Owner]);
dini_IntSet(file, "OwnerType", vInfo[vehicleid][OwnerType]);
dini_IntSet(file, "Model", vInfo[vehicleid][Model]);
dini_FloatSet(file, "PosX", vInfo[vehicleid][PosX]);
dini_FloatSet(file, "PosY", vInfo[vehicleid][PosY]);
dini_FloatSet(file, "PosZ", vInfo[vehicleid][PosZ]);
dini_FloatSet(file, "PosA", vInfo[vehicleid][PosA]);
dini_IntSet(file, "Color1", vInfo[vehicleid][Color1]);
dini_IntSet(file, "Color2", vInfo[vehicleid][Color2]);
dini_IntSet(file, "Mod0", vInfo[vehicleid][Mod0]);
dini_IntSet(file, "Mod1", vInfo[vehicleid][Mod1]);
dini_IntSet(file, "Mod2", vInfo[vehicleid][Mod2]);
dini_IntSet(file, "Mod3", vInfo[vehicleid][Mod3]);
dini_IntSet(file, "Mod4", vInfo[vehicleid][Mod4]);
dini_IntSet(file, "Mod5", vInfo[vehicleid][Mod5]);
dini_IntSet(file, "Mod6", vInfo[vehicleid][Mod6]);
dini_IntSet(file, "Mod7", vInfo[vehicleid][Mod7]);
dini_IntSet(file, "Mod8", vInfo[vehicleid][Mod8]);
dini_IntSet(file, "Mod9", vInfo[vehicleid][Mod9]);
dini_IntSet(file, "Mod10", vInfo[vehicleid][Mod10]);
dini_IntSet(file, "Mod11", vInfo[vehicleid][Mod11]);
dini_IntSet(file, "Mod12", vInfo[vehicleid][Mod12]);
dini_IntSet(file, "Mod13", vInfo[vehicleid][Mod13]);
dini_IntSet(file, "Paintjob", vInfo[vehicleid][Paintjob]);
}
}
return 1;
}
PHP Code:
dcmd_setvehicle(playerid, params[])
{
if(pInfo[playerid][Rank] >= 3)
{
new owner[256], ownertype, color1, color2;
if(sscanf(params, "siii", owner, ownertype, color1, color2))
{
SendClientMessage(playerid, COLOR_PINK, " Usage: /setvehicle [owner] [ownertype] [color1] [color2]");
SendClientMessage(playerid, COLOR_PINK, " [Owners] Factions: 1(Police) 2(EMS)");
SendClientMessage(playerid, COLOR_PINK, " [Owner Types] 1(Player) 2(Faction) 3(Public)");
}
else if(ownertype < 1 || ownertype > 3)
{
SendClientMessage(playerid, COLOR_ORANGE, " Invalid Owner Type");
}
else if(color1 < 0 || color1 > 256)
{
SendClientMessage(playerid, COLOR_ORANGE, " Invalid Color1");
}
else if(color2 < 0 || color2 > 256)
{
SendClientMessage(playerid, COLOR_ORANGE, " Invalid Color2");
}
else
{
for(new vehicleid = 0; vehicleid < 5000; vehicleid++)
{
if(vInfo[vehicleid][Model] == 0)
{
format(vInfo[vehicleid][Owner], 256, "%s", owner);
vInfo[vehicleid][OwnerType] = ownertype;
vInfo[vehicleid][Model] = GetVehicleModel(GetPlayerVehicleID(playerid));
new Float:x, Float:y, Float:z, Float:a;
GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
vInfo[vehicleid][PosX] = x;
vInfo[vehicleid][PosY] = y;
vInfo[vehicleid][PosZ] = z;
vInfo[vehicleid][PosA] = a;
vInfo[vehicleid][Color1] = color1;
vInfo[vehicleid][Color2] = color2;
new output[256];
format(output, 256, " Vehicle File(%i) Created", vehicleid);
return SendClientMessage(playerid, COLOR_WHITE, output);
}
}
SendClientMessage(playerid, COLOR_ORANGE, " Vehicle Limit Reached");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Commmand Doesn't Exists");
}
return 1;
}
PHP Code:
Owner=Nљ’nKЊ
OwnerType=3
Model=410
PosX=1291.799072
PosY=343.792419
PosZ=19.206686
PosA=65.997161
Color1=3
Color2=3
Mod0=0
Mod1=0
Mod2=0
Mod3=0
Mod4=0
Mod5=0
Mod6=0
Mod7=0
Mod8=0
Mod9=0
Mod10=0
Mod11=0
Mod12=0
Mod13=0
Paintjob=0