/carpark
#1

Basically my car wont save its location when /carpark

car park code:

Код:
CMD:carpark(playerid, params[])
{
	new v = GetPlayerVehicleID(playerid), Float: X, Float: Y, Float: Z, Float: A;
	GetPlayerPos(playerid, X, Y, Z), GetPlayerFacingAngle(playerid, A);

	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] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own a vehicle!");

	if(GetPlayerVehicleID(playerid) == v)
	{
		if(pInfo[playerid][VehicleOwner] == v)
		{
   vInfo[v][posX] = X;
			vInfo[v][posY] = Y;
			vInfo[v][posZ] = Z;
	    	vInfo[v][posA] = A;

			SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You've parked your vehicle!");
			SaveVehicles();
	 	}

	 	else SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own this car!");
	}

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

	return 1;
}
Save 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]);

		    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:

Код:
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;
}

forward LoadVehicleData(v, name[], value[]);
public LoadVehicleData(v, name[], value[])
{
    INI_String("Owner", vInfo[v][Owner], 31);
    INI_Int("ModelID", vInfo[v][ModelID]);
    INI_String("NrPlate", vInfo[v][NrPlate], 8);

    INI_Float("posX", vInfo[v][posX]);
    INI_Float("posY", vInfo[v][posY]);
    INI_Float("posZ", vInfo[v][posZ]);
    INI_Float("posA", vInfo[v][posA]);

    INI_Int("ColorA", vInfo[v][ColorA]);
    INI_Int("ColorB", vInfo[v][ColorB]);

    INI_Int("Locked", vInfo[v][Locked]);
    INI_Int("Faction", vInfo[v][Faction]);

	return 1;
}
when you buy the car if needed..

Код:
stock CreatePlayerVehicle(playerid, model)
{
	new pname[30], file[64], playercar, v;
	GetPlayerName(playerid, pname, sizeof(pname));

	playercar = CreateVehicle(model, 170.8668, -16.1531, 1.5781, 220.7102, random(5), random(5), -1);
	PutPlayerInVehicle(playerid, playercar, 0);

	new INI:File = INI_Open(VehiclePath(v));

	vInfo[v][ModelID] = model;
    vInfo[v][NrPlate] = "DT-0000-RP";
    vInfo[v][Owner] = pname;

	vInfo[v][posX] = 170.8668;
	vInfo[v][posY] = -16.1531;
	vInfo[v][posZ] = 1.5781;
	vInfo[v][posA] = 220.7102;

	vInfo[v][ColorA] = random(50);
	vInfo[v][ColorB] = random(50);

	vInfo[v][Locked] = 1;

	INI_Close(File);

	format(file, 64, "Vehicles/%d.ini", v);

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

	SaveVehicles();

	pInfo[playerid][VehicleOwner] = playercar;
	vEngine[playercar] = 1;

	return 1;
}
Reply
#2

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
Basically my car wont save its location when /carpark

car park code:

Код:
CMD:carpark(playerid, params[])
{
	new v = GetPlayerVehicleID(playerid), Float: X, Float: Y, Float: Z, Float: A;
	GetPlayerPos(playerid, X, Y, Z), GetPlayerFacingAngle(playerid, A);

	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] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own a vehicle!");

	if(GetPlayerVehicleID(playerid) == v)
	{
		if(pInfo[playerid][VehicleOwner] == v)
		{
   vInfo[v][posX] = X;
			vInfo[v][posY] = Y;
			vInfo[v][posZ] = Z;
	    	vInfo[v][posA] = A;

			SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You've parked your vehicle!");
			SaveVehicles();
	 	}

	 	else SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own this car!");
	}

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

	return 1;
}
Save 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]);

		    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:

Код:
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;
}

forward LoadVehicleData(v, name[], value[]);
public LoadVehicleData(v, name[], value[])
{
    INI_String("Owner", vInfo[v][Owner], 31);
    INI_Int("ModelID", vInfo[v][ModelID]);
    INI_String("NrPlate", vInfo[v][NrPlate], 8);

    INI_Float("posX", vInfo[v][posX]);
    INI_Float("posY", vInfo[v][posY]);
    INI_Float("posZ", vInfo[v][posZ]);
    INI_Float("posA", vInfo[v][posA]);

    INI_Int("ColorA", vInfo[v][ColorA]);
    INI_Int("ColorB", vInfo[v][ColorB]);

    INI_Int("Locked", vInfo[v][Locked]);
    INI_Int("Faction", vInfo[v][Faction]);

	return 1;
}
when you buy the car if needed..

Код:
stock CreatePlayerVehicle(playerid, model)
{
	new pname[30], file[64], playercar, v;
	GetPlayerName(playerid, pname, sizeof(pname));

	playercar = CreateVehicle(model, 170.8668, -16.1531, 1.5781, 220.7102, random(5), random(5), -1);
	PutPlayerInVehicle(playerid, playercar, 0);

	new INI:File = INI_Open(VehiclePath(v));

	vInfo[v][ModelID] = model;
    vInfo[v][NrPlate] = "DT-0000-RP";
    vInfo[v][Owner] = pname;

	vInfo[v][posX] = 170.8668;
	vInfo[v][posY] = -16.1531;
	vInfo[v][posZ] = 1.5781;
	vInfo[v][posA] = 220.7102;

	vInfo[v][ColorA] = random(50);
	vInfo[v][ColorB] = random(50);

	vInfo[v][Locked] = 1;

	INI_Close(File);

	format(file, 64, "Vehicles/%d.ini", v);

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

	SaveVehicles();

	pInfo[playerid][VehicleOwner] = playercar;
	vEngine[playercar] = 1;

	return 1;
}
When you save it... Does the Vehicles folder include any files ?
If yes, Show the content of the file to ensure the data is saved properly..
Reply
#3

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
When you save it... Does the Vehicles folder include any files ?
If yes, Show the content of the file to ensure the data is saved properly..
In the data files it's just 0 for everything ;/
Reply
#4

Change the save code to:
pawn Код:
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("%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;
}
And then check what gets written to the console when u save.
Reply
#5

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
Change the save code to:
pawn Код:
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("%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;
}
And then check what gets written to the console when u save.
Reply
#6

Change the command code to:
pawn Код:
CMD:carpark(playerid, params[])
{
    new v = GetPlayerVehicleID(playerid), Float: X, Float: Y, Float: Z, Float: A;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);

    printf("%f | %f | %f | %f", X, Y, Z, A);
   
    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] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own a vehicle!");

    if(GetPlayerVehicleID(playerid) == v)
    {
        if(pInfo[playerid][VehicleOwner] == v)
        {
            vInfo[v][posX] = X;
            vInfo[v][posY] = Y;
            vInfo[v][posZ] = Z;
            vInfo[v][posA] = A;

            print("**** %f | %f | %f ****", vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]);
           
            SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You've parked your vehicle!");
            SaveVehicles();
        }

        else SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own this car!");
    }

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

    return 1;
}
if the console still show's zeros... than that's really pretty weird... (It shouldn't though.)
Reply
#7

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
Change the command code to:
pawn Код:
CMD:carpark(playerid, params[])
{
    new v = GetPlayerVehicleID(playerid), Float: X, Float: Y, Float: Z, Float: A;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);

    printf("%f | %f | %f | %f", X, Y, Z, A);
   
    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] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own a vehicle!");

    if(GetPlayerVehicleID(playerid) == v)
    {
        if(pInfo[playerid][VehicleOwner] == v)
        {
            vInfo[v][posX] = X;
            vInfo[v][posY] = Y;
            vInfo[v][posZ] = Z;
            vInfo[v][posA] = A;

            print("**** %f | %f | %f ****", vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]);
           
            SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You've parked your vehicle!");
            SaveVehicles();
        }

        else SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER:{FFFFFF} You don't own this car!");
    }

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

    return 1;
}
if the console still show's zeros... than that's really pretty weird... (It shouldn't though.)
Код:
C:\Users\Nathan\Desktop\Downtown Roleplay\gamemodes\core.pwn(2868) : warning 202: number of arguments does not match definition
C:\Users\Nathan\Desktop\Downtown Roleplay\gamemodes\core.pwn(2868) : warning 202: number of arguments does not match definition
C:\Users\Nathan\Desktop\Downtown Roleplay\gamemodes\core.pwn(2868) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Reply
#8

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
Код:
C:\Users\Nathan\Desktop\Downtown Roleplay\gamemodes\core.pwn(2868) : warning 202: number of arguments does not match definition
C:\Users\Nathan\Desktop\Downtown Roleplay\gamemodes\core.pwn(2868) : warning 202: number of arguments does not match definition
C:\Users\Nathan\Desktop\Downtown Roleplay\gamemodes\core.pwn(2868) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Change:
Quote:

print("**** %f | %f | %f ****", vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]);

to
Quote:

printf("**** %f | %f | %f ****", vInfo[v][posX], vInfo[v][posY], vInfo[v][posZ]);

Reply
#9

Reply
#10

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
The heck... How the fuck...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)