30.01.2012, 12:57
My mind is clustering at the moment trying to figure out how to make load vehicles. I would appreciate, if someone can help me out of this troublesome.
This is what my vehicle system currently.
I couldn't figure out how to make the LoadVehicle as I cannot use my mind. Any help will be appreciated.
This is what my vehicle system currently.
pawn Код:
#define MAX_VEHICLES (1000)
enum cInfo
{
model,
Float: spawnX, Float: spawnY, Float: spawnZ, Float: spawnAngle,
color1,
color2,
respawn,
owner
}
new CI[MAX_VEHICLES][cInfo];
stock GetVehicleFreeSlot()
{
for(new i = 0; i < sizeof(validcar); i++)
{
if(!validcar[i]) return i;
}
return -1;
}
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, cl1, cl2, respawndelay, ownername[MAX_PLAYER_NAME])
{
new carid = GetVehicleFreeSlot();
CI[carid][model] = modelid;
CI[carid][spawnX] = x;
CI[carid][spawnY] = y;
CI[carid][spawnZ] = z;
CI[carid][spawnAngle] = angle;
CI[carid][color1] = cl1;
CI[carid][color2] = cl2;
CI[carid][respawn] = respawndelay;
CI[carid][owner] = ownername;
validcar[carid] = true;
CreateVehicle(modelid, x, y, z, angle, cl1, cl2, respawndelay);
return carid;
}
stock SaveVehicle(vehicle)
{
format(largestr, sizeof(largestr), "INSERT INTO `vehicles`(\
`modelid`, \
`x`, \
`y`, \
`z`, \
`angle`, \
`color1`, \
`color2`, \
`respawn`, \
`owner` \
) VALUES (\
%d, \
%f, \
%f, \
%f, \
%f, \
%d, \
%d, \
%d, \
'%s' \
)",
CI[vehicle][model],
CI[vehicle][spawnX],
CI[vehicle][spawnY],
CI[vehicle][spawnZ],
CI[vehicle][spawnAngle],
CI[vehicle][color1],
CI[vehicle][color2],
CI[vehicle][respawn],
CI[vehicle][owner]
);
mysql_query(largestr);
mysql_free_result();
}
stock SaveAllVehicles()
{
new saveindex = 0;
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(validcar[i])
{
SaveVehicle(i)
saveindex++;
}
}
}