Saving incorrectly!
#1

Okay, so my functions are getting the positions correctly, but when it sets them and saves them it doesn't save properly, look..

THIS CORRECTLY SAVES THE VARIABLE

Код:
CMD:carpark(playerid, params[])
{
	new v = pInfo[playerid][VehicleOwner], currentveh = GetPlayerVehicleID(playerid);
	new Float:vehx, Float:vehy, Float:vehz;
	new file[64];
	GetVehiclePos(currentveh, vehx, vehy, vehz);

	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You need to be in a car in order to do this command!");
	if(pInfo[playerid][VehicleOwner] == 9999) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own a vehicle!");
	
	
	SendClientMessage(playerid, -1, "Done!");

	if(pInfo[playerid][VehicleOwner] == v)
	{
		vInfo[v][posX] = vehx;
		vInfo[v][posY] = vehy;
		vInfo[v][posZ] = vehz;
		format(file, 64, "Vehicles/%d.ini", v);
	    if(fexist(file))
	    {
     		new INI:File = INI_Open(file);

		    INI_WriteFloat(File, "posX", vehx);
		    INI_WriteFloat(File, "posY", vehy);
		    INI_WriteFloat(File, "posZ", vehz);
		    


		    INI_Close(File);
		}
	}
	else SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} This isn't your vehicle!");

	return 1;
}
But when it sets it to vInfo[v][posX] etc.. on save vehicles I think it's saving incorrectly thus loading incorrectly..

SAVING VEHICLES:

Код:
stock SaveVehicles()
{
	new file[64];

	for(new v = 0; v < MAX_CARS; v ++)
	{
		format(file, 64, "Vehicles/%d.ini", v);

	    if(fexist(file))
	    {
     		new INI:File = INI_Open(file);

		    INI_SetTag(File, "Vehicle Data");

		    INI_WriteInt(File, "ModelID", vInfo[v][ModelID]);
		    INI_WriteString(File, "Owner", vInfo[v][Owner]);
		    INI_WriteString(File, "NrPlate", vInfo[v][NrPlate]);

			printf("Car saved at pos: %f | %f | %f", vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]);
		    INI_WriteFloat(File, "posX", vInfo[v][posX]);
		    INI_WriteFloat(File, "posY", vInfo[v][posY]);
		    INI_WriteFloat(File, "posZ", vInfo[v][posZ]);
		    INI_WriteFloat(File, "posA", vInfo[v][posA]);

		    INI_WriteInt(File, "ColorA", vInfo[v][ColorA]);
		    INI_WriteInt(File, "ColorB", vInfo[v][ColorB]);

		    INI_WriteInt(File, "Locked", vInfo[v][Locked]);
		    INI_WriteInt(File, "Faction", vInfo[v][Faction]);

		    INI_Close(File);
		}
	}

	return 1;
}
Loading vehicles..:

Код:
stock LoadVehicles()
{
	new file[64], s[64], count;

	print("\n  Loading vehicles: \n");

	for(new v = 0; v < MAX_CARS; v ++)
	{
		format(file, 64, "Vehicles/%d.ini", v);

	    if(fexist(file))
	    {
	        INI_ParseFile(VehiclePath(v), "LoadVehicleData", false, true, v, true, false );

			CreateVehicle(vInfo[v][ModelID], vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ], vInfo[v][posA], vInfo[v][ColorA], vInfo[v][ColorB], -1);
			SetVehicleNumberPlate(v, vInfo[v][NrPlate]);

            SetVehicleParamsForPlayer(v, v, 0, 1);
			SetVehicleToRespawn(v); // numberplate

            format(s, 64, "[VEHICLE] Loaded Vehicle ID: %d at %f %f %f", v, vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]);
			printf(s);
			
			count++;
		}
	}

	printf("\n  %d vehicles loaded!", count);

	return 1;
}
Help me out and I'll rep you
Reply
#2

You forgot to set the tag on save. (on /carpark cmd)
Reply
#3

The tag makes no difference..
Reply
#4

Anything?
Reply
#5

Does no one know?
Reply
#6

Hello!

What is printing here?
PHP код:
printf("Vehicle: %d park at X: %f - Y: %f - Z: %f",currentveh,vehx,vehy,vehz); 
PHP код:
printf("Car saved at pos: %f | %f | %f"vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]); 
The both have to the same coords if you park and save it.

And what is printing here, if you load your vehicle after save.
PHP код:
format(s64"[VEHICLE] Loaded Vehicle ID: %d at %f %f %f"vvInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]); 
Mencent
Reply
#7

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

What is printing here?
PHP код:
printf("Vehicle: %d park at X: %f - Y: %f - Z: %f",currentveh,vehx,vehy,vehz); 
PHP код:
printf("Car saved at pos: %f | %f | %f"vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]); 
The both have to the same coords if you park and save it.

And what is printing here, if you load your vehicle after save.
PHP код:
format(s64"[VEHICLE] Loaded Vehicle ID: %d at %f %f %f"vvInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]); 
Mencent
When I park it says the real postition of the car..

But when it saves it says 0.0000 for all then loads at 0.0000
Reply
#8

What is printing for v?
PHP код:
CMD:carpark(playeridparams[])
{
    new 
pInfo[playerid][VehicleOwner], currentveh GetPlayerVehicleID(playerid);
    new 
Float:vehxFloat:vehyFloat:vehz;
    new 
file[64];
    
GetVehiclePos(currentvehvehxvehyvehz);
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} You need to be in a car in order to do this command!");
    if(
pInfo[playerid][VehicleOwner] == 9999) return SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} You don't own a vehicle!");
    
SendClientMessage(playerid, -1"Done!");
    if(
pInfo[playerid][VehicleOwner] == v)
    {
        
vInfo[v][posX] = vehx;
        
vInfo[v][posY] = vehy;
        
vInfo[v][posZ] = vehz;
        
printf("v: %d",v);
        
format(file64"Vehicles/%d.ini"v);
        if(
fexist(file))
        {
             new 
INI:File INI_Open(file);
            
INI_WriteFloat(File"posX"vehx);
            
INI_WriteFloat(File"posY"vehy);
            
INI_WriteFloat(File"posZ"vehz);
            
INI_Close(File);
        }
    }
    else 
SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} This isn't your vehicle!");
    return 
1;

Mencent
Reply
#9

Quote:
Originally Posted by Mencent
Посмотреть сообщение
What is printing for v?
PHP код:
CMD:carpark(playeridparams[])
{
    new 
pInfo[playerid][VehicleOwner], currentveh GetPlayerVehicleID(playerid);
    new 
Float:vehxFloat:vehyFloat:vehz;
    new 
file[64];
    
GetVehiclePos(currentvehvehxvehyvehz);
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} You need to be in a car in order to do this command!");
    if(
pInfo[playerid][VehicleOwner] == 9999) return SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} You don't own a vehicle!");
    
SendClientMessage(playerid, -1"Done!");
    if(
pInfo[playerid][VehicleOwner] == v)
    {
        
vInfo[v][posX] = vehx;
        
vInfo[v][posY] = vehy;
        
vInfo[v][posZ] = vehz;
        
printf("v: %d",v);
        
format(file64"Vehicles/%d.ini"v);
        if(
fexist(file))
        {
             new 
INI:File INI_Open(file);
            
INI_WriteFloat(File"posX"vehx);
            
INI_WriteFloat(File"posY"vehy);
            
INI_WriteFloat(File"posZ"vehz);
            
INI_Close(File);
        }
    }
    else 
SendClientMessage(playeridCOLOR_LIGHTRED"SERVER:{FFFFFF} This isn't your vehicle!");
    return 
1;

Mencent


and when i /q...

Reply
#10

Well,your mistake is:
here is what u did
pawn Код:
new v = pInfo[playerid][VehicleOwner];
vInfo[v][posX] = vehx;
vInfo[v][posY] = vehy;
vInfo[v][posZ] = vehz;
so you are setting it wrong
what do you use for changing vehicles things like color and..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)