[Ajuda] GM nгo ta salvando dados do carro
#1

Olб pessoal, estou com um probleminha aqui, quando eu crio um carro de concessionбria, estaciono como admin ou estaciono ele normal, ele nгo salva direito os dados do carro em: scriptfiles\BrasilGames\masini.cfg
o documento masini.cfg salva as coordenadas de onde um carro do sistema de concessionбria foi criado ou estacionado pela ultima vez. E em vez de ser salvo como 42kb, que й o salvamento perfeito do carro, ele sу salva em apenas 22kb, ou seja, algo no GM nгo estб deixando salvar as coordenadas do carro, e infelizmente nгo sei o que й, e preciso da ajudar de vocкs pra me dizer o que estб dando esse conflito, agradeзo desde jб
Pra quem estiver interessado em ajudar, deixo aqui alguns codes...

Cуdigo /acriarcarro :
Код:
if(strcmp(cmd, "/acriarcarro", true) == 0)
	{
	    if(IsPlayerAdmin(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Use: /acriarcarro [carroid] [cor1] [cor2] [Preзo]");
				return 1;
			}
			new car;
			car = strval(tmp);
			if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, " Nъmero do veнculo nгo pode ser inferior a 400 ou acima de 611!"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Use: /acriarcarro [carroid] [cor1] [cor2] [Preзo]");
				return 1;
			}
			new color1;
			color1 = strval(tmp);
			if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Nъmero da cor nгo pode ser inferior a 0 ou acima de 126!"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Use: /acriarcarro [carroid] [cor1] [cor2] [Preзo]");
				return 1;
			}
			new color2;
			color2 = strval(tmp);
			if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Nъmero da cor nгo pode ser inferior a 0 ou acima de 126!"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Use: /acriarcarro [carroid] [cor1] [cor2] [Preзo]");
				return 1;
			}
			new value;
			value = strval(tmp);
			new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
            new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
            format(CarInfo[thiscar][cLicense], 32 ,"A venda");
	        SetVehicleNumberPlate(vehid,CarInfo[thiscar][cLicense]);
			CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
			CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
			CarInfo[thiscar][cValue] = value; CarInfo[thiscar][cLock] = 0; CarInfo[thiscar][paintjob] = -1; LoadComponents(thiscar);
			PutPlayerInVehicle(playerid,thiscar,0);
			OnPropUpdate(); SavePlayerData(playerid);
			strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
			format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
			format(string, sizeof(string), " Carro %d foi criado com sucesso!", thiscar);
			SendClientMessage(playerid, COLOR_BLUE, string);
		}
		else
		{
		    SendClientMessage(playerid, COLOR_GRAD1, " Vocк nгo estб autorizado a usar este comando!");
			return 1;
		}
	}
Cуdigo /aestacionar :
Код:
if(strcmp(cmd, "/aestacionar", true) == 0)
	{
		if(IsPlayerConnected(playerid))
 		{
			new Float:x,Float:y,Float:z;
			new Float:a;
			new carid;
			carid = GetPlayerVehicleID(playerid);
			GetPlayerName(playerid, playername, sizeof(playername));
			GetVehiclePos(carid, x, y, z);
			GetVehicleZAngle(carid, a);
			if(IsPlayerAdmin(playerid))
			{
				CarInfo[carid][cLocationx] = x;
				CarInfo[carid][cLocationy] = y;
				CarInfo[carid][cLocationz] = z;
				CarInfo[carid][cAngle] = a;
				format(string, sizeof(string), "~n~ Voce estacionou o veiculo nesta posiзao. ~n~");
				GameTextForPlayer(playerid, "Voce estacionou o veiculo nesta posiзao. Ele ira respawnar aqui", 10000, 3);
				OnPropUpdate(); SavePlayerData(playerid);
	    		DestroyVehicle(carid);
	    		new thiscar = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
	    		LoadComponents(thiscar);
                return 1;
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "   Vocк nгo estб autorizado a usar este comando !");
			    return 1;
			}
		}
		return 1;
	}
Cуdigo /v estacionar :
Код:
else if(strcmp(x_nr,"estacionar",true) == 0)
	        {
	            new Float:x,Float:y,Float:z;
				new Float:a;
				new carid;
				new getcarid;
				if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pCarKey]) { carid = PlayerInfo[playerid][pCarKey]; }
				else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pCarKey2]) { carid = PlayerInfo[playerid][pCarKey2]; }
				else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pCarKey3]) { carid = PlayerInfo[playerid][pCarKey3]; }
				else { return 1; }
				getcarid = GetPlayerVehicleID(playerid);
				GetPlayerName(playerid, playername, sizeof(playername));
				GetVehiclePos(carid, x, y, z);
				GetVehicleZAngle(carid, a);
				if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
				{
			   		if(PlayerInfo[playerid][pCarKey] == -1 && PlayerInfo[playerid][pCarKey2] == -1 && PlayerInfo[playerid][pCarKey3] == -1)
					{
						SendClientMessage(playerid, COLOR_GREY, "Vocк nгo possui um carro.");
						return 1;
					}
   					if(getcarid == carid)
					{
                        new Float:CarHP, Float:OldCarHP; new panels,doors,lights,tires;
						CarInfo[carid][cLocationx] = x;
						CarInfo[carid][cLocationy] = y;
						CarInfo[carid][cLocationz] = z;
						CarInfo[carid][cAngle] = a;
						GetVehicleDamageStatus(carid,panels,doors,lights,tires);
						GetVehicleHealth(carid, CarHP); OldCarHP = CarHP;
						format(string, sizeof(string), "~n~ Voce estacionou seu veiculo aqui. ~n~");
						GameTextForPlayer(playerid, "Veiculo estacionado, ele ira nascer aqui.", 10000, 3);
						OnPropUpdate(); SavePlayerData(playerid);  DestroyVehicle(carid);
						CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
						LoadComponents(carid);
						PutPlayerInVehicle(playerid,carid,0); SetVehicleHealth(carid, OldCarHP);
						UpdateVehicleDamageStatus(carid,panels,doors,lights,tires);
						TogglePlayerControllable(playerid, 1);
						return 1;
   					}
				}
	        }
Cуdigo da callback OnPropUpdate(que no caso й onde armazena as coordenadas do carro, e como podem ver, estб direitinho em todos que quando se compra ou quando se estacionar um carro estб OnPropUpadte()
Код:
public OnPropUpdate()
{
	new idx;
	new File: file2;
	idx = carsonserver;
 	while (idx < sizeof(CarInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo],
		CarInfo[idx][cOwner],
		CarInfo[idx][cDescription],
		CarInfo[idx][cValue],
		CarInfo[idx][cLicense],
		CarInfo[idx][cOwned],
		CarInfo[idx][cLock],
		CarInfo[idx][mod1],
		CarInfo[idx][mod2],
		CarInfo[idx][mod3],
		CarInfo[idx][mod4],
		CarInfo[idx][mod5],
		CarInfo[idx][mod6],
		CarInfo[idx][mod7],
		CarInfo[idx][mod8],
		CarInfo[idx][mod9],
		CarInfo[idx][mod10],
		CarInfo[idx][mod11],
		CarInfo[idx][mod12],
		CarInfo[idx][mod13],
		CarInfo[idx][mod14],
		CarInfo[idx][mod15],
		CarInfo[idx][mod16],
		CarInfo[idx][mod17],
		CarInfo[idx][paintjob]);
		if(idx == carsonserver)
		{
			file2 = fopen("BrasilGames/masini.cfg", io_write);
		}
		else
		{
			file2 = fopen("BrasilGames/masini.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
        idx = 0;
	while (idx < sizeof(HouseInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
		HouseInfo[idx][hEntrancex],
		HouseInfo[idx][hEntrancey],
		HouseInfo[idx][hEntrancez],
		HouseInfo[idx][hExitx],
		HouseInfo[idx][hExity],
		HouseInfo[idx][hExitz],
		HouseInfo[idx][hHealthx],
		HouseInfo[idx][hHealthy],
		HouseInfo[idx][hHealthz],
		HouseInfo[idx][hArmorrx],
		HouseInfo[idx][hArmorry],
		HouseInfo[idx][hArmorrz],
		HouseInfo[idx][hOwner],
		HouseInfo[idx][hDiscription],
		HouseInfo[idx][hValue],
		HouseInfo[idx][hHel],
		HouseInfo[idx][hArm],
		HouseInfo[idx][hInt],
		HouseInfo[idx][hLock],
		HouseInfo[idx][hOwned],
		HouseInfo[idx][hRooms],
		HouseInfo[idx][hRent],
		HouseInfo[idx][hRentabil],
		HouseInfo[idx][hTakings],
		HouseInfo[idx][hVec],
		HouseInfo[idx][hVcol1],
		HouseInfo[idx][hVcol2],
		HouseInfo[idx][hDate],
		HouseInfo[idx][hLevel],
		HouseInfo[idx][hWorld]);

		HouseInfo[idx][hWorld] = idx;
		if(idx == 0)
		{
			file2 = fopen("BrasilGames/Casas.cfg", io_write);
		}
		else
		{
			file2 = fopen("BrasilGames/Casas.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	idx = 0;
	while (idx < sizeof(BizzInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d|%s|%s|%s|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d\n",
		BizzInfo[idx][bOwned],
		BizzInfo[idx][bOwner],
		BizzInfo[idx][bMessage],
		BizzInfo[idx][bExtortion],
		BizzInfo[idx][bEntranceX],
		BizzInfo[idx][bEntranceY],
		BizzInfo[idx][bEntranceZ],
		BizzInfo[idx][bExitX],
		BizzInfo[idx][bExitY],
		BizzInfo[idx][bExitZ],
		BizzInfo[idx][bLevelNeeded],
		BizzInfo[idx][bBuyPrice],
		BizzInfo[idx][bEntranceCost],
		BizzInfo[idx][bTill],
		BizzInfo[idx][bLocked],
		BizzInfo[idx][bInterior]);
		//BizzInfo[idx][VirtualWorld]);
		if(idx == 0)
		{
			file2 = fopen("BrasilGames/Empresas.cfg", io_write);
		}
		else
		{
			file2 = fopen("BrasilGames/Empresas.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	idx = 0;
	while (idx < sizeof(SBizzInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d|%s|%s|%s|%f|%f|%f|%d|%d|%d|%d|%d\n",
		SBizzInfo[idx][sbOwned],
		SBizzInfo[idx][sbOwner],
		SBizzInfo[idx][sbMessage],
		SBizzInfo[idx][sbExtortion],
		SBizzInfo[idx][sbEntranceX],
		SBizzInfo[idx][sbEntranceY],
		SBizzInfo[idx][sbEntranceZ],
		SBizzInfo[idx][sbLevelNeeded],
		SBizzInfo[idx][sbBuyPrice],
		SBizzInfo[idx][sbEntranceCost],
		SBizzInfo[idx][sbTill],
		SBizzInfo[idx][sbLocked]);
		if(idx == 0)
		{
			file2 = fopen("BrasilGames/MiniEmpresas.cfg", io_write);
		}
		else
		{
			file2 = fopen("BrasilGames/MiniEmpresas.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
        return true;
}
Me ajudem por favor, nгo consigo ver onde possivelmente estб o erro :/
Reply
#2

Alguйm ajuda ae por favor
Reply
#3

nao tem nada para salvar as informacoes do carro como quer que salve?
Reply
#4

Quote:
Originally Posted by PT
Посмотреть сообщение
nao tem nada para salvar as informacoes do carro como quer que salve?
Na callback OnPropUpdate...
olha que todos os cуdigos dos comandos tem como essa callback pra armazenar as informaзхes dos carros.
OnPropUpdate(); SavePlayerData(playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)