Some bugs on saving vehicle system -
blackwave - 27.11.2010
Код:
#include <a_samp>
#include <gl_common>
#define ARQUIVO_CARROS "carros.ini"
#define AMARELO 0xFFFF00FF
forward save_cars(playerid);
public OnFilterScriptInit()
{
LoadStaticVehiclesFromFile(ARQUIVO_CARROS);
SetTimer("save_cars", 300000, false) && print("Save_cars forward jб em processo...");
return 1;
}
public OnFilterScriptExit()
{
new Float:x,Float:y,Float:z,Float:a;
new str[64],Model;
new File:CarFile = fopen(ARQUIVO_CARROS,io_write);
for(new i=1; i < MAX_VEHICLES; i++)
{
if((Model=GetVehicleModel(i)))
{
GetVehiclePos(i,x,y,z);
GetVehicleZAngle(i,a);
format(str,64,"%d,%f,%f,%f,%f,%d,%d ;\r\n",Model,x,y,z,a,-1,-1);
fwrite(CarFile,str);
DestroyVehicle(i);
}
else if(i == 0) return 0;
}
fclose(CarFile);
return 1;
}
stock SoundForAll(SoundID)
{
for(new i = 0; i < MAX_PLAYERS; i++) PlayerPlaySound(i, SoundID, 0.0, 0.0, 0.0);
}
public save_cars(playerid)
{
new Float:x,Float:y,Float:z,Float:a;
new str[64],Model;
new File:CarFile = fopen(ARQUIVO_CARROS,io_write);
for(new i=1; i < MAX_VEHICLES; i++)
{
if((Model=GetVehicleModel(i)) && GetVehicleHealth(i) > 0)
{
GetVehiclePos(i,x,y,z);
GetVehicleZAngle(i,a);
format(str,64,"%d,%f,%f,%f,%f,%d,%d ;\r\n",Model,x,y,z,a,-1,-1);
fwrite(CarFile,str);
//DestroyVehicle(i);
}
}
fclose(CarFile);
SoundForAll(1133);
SendClientMessageToAll(AMARELO, "SERVER: veiculos salvos");
print("VEICULOS SALVOS EM carros.ini");
SetTimer("save_cars", 300000, true);
}
What's wrong? everytime I turn server on with "carros.ini" empty, it says it loaded 0 vehicles, but when I close server, it shows on "carros.ini" file this line:
Код:
457,1336.319946,1778.599975,10.819999,90.000000,-1,-1 ;
And so everytime. Can someone tell me what's wrong? I wanted this like: not saving vehicles with 0 of life or less, reloading them on OnFilterScriptInit, and saving them on OnFilterScriptExit. Sorry for asking again, but that's not right =s
Re: Some bugs on saving vehicle system -
randomkid88 - 27.11.2010
Is there a vehicle in the game somewhere?
Re: Some bugs on saving vehicle system -
blackwave - 27.11.2010
Dude, that's really weird. I did a test with my car command, but same if I destroy the car I created, explosion or w/e, it saves lol. If there were any problems on the car command, here's:
Код:
dcmd_car(playerid, params[])
{
new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); tmp3 = strtok(params,Index);
if(!strlen(tmp)) return SendClientMessage(playerid, VERMELHO, "USAGE: /car [Modelid/Name] [colour1] [colour2]");
new car, colour1, colour2, string[128];
if(!IsNumeric(tmp)) car = GetVehicleModelIDFromName(tmp); else car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid, VERMELHO, "ERROR: Invalid Vehicle Model");
if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
new LVehicleID,Float:X,Float:Y,Float:Z, Float:Angle,int1; GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,Angle); int1 = GetPlayerInterior(playerid);
return LVehicleID = CreateVehicle(car, X+3,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
}
Just a simple code. And for your question, I think there's noone vehicle lol ( I cant know), since it loads empty and closes saving one o_o
Re: Some bugs on saving vehicle system -
blackwave - 27.11.2010
Please =z