Got problem when using vehicle park command
#1

I'll have problem, when i write to command line /park it says Server: Unknown command.
I am hooked alltime to catch that error, but i just simple don't just see any problem there...

Header:
Код:
forward SaveDynamicCars();
Command code:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	// Park your vehicle
	if(strcmp(cmdtext, "/park",true) == 0)
	{
 	new vehicleid = GetPlayerVehicleID(playerid);
 	new car = GetPlayerVehicleID(playerid) - 1;
	new Float:x,Float:y,Float:z;
	new Float:a;

		GetVehiclePos(vehicleid, x, y, z); // Gets vehicle pos
		GetVehicleZAngle(vehicleid, a); // Gets vehicle angle

		DynamicCars[car][CarX] = x; // Coords
		DynamicCars[car][CarY] = y; // Coords
		DynamicCars[car][CarZ] = z; // Coords
		DynamicCars[car][CarAngle] = a; // Angle
		DestroyVehicle(vehicleid); // Destoroy car

		CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1); // Creates car

		SaveDynamicCars(); // Save cars to file

	  SendClientMessage(playerid,COLOR_WHITE,"SERVER: Your vehicle is now parked to here.");
		return 1;
	}
 return 1;
 }
...And SaveDynamicCars() public...
Код:
public SaveDynamicCars()
{
	new idx;
	new File: file2;
	while (idx < sizeof(DynamicCars))
	{

		new coordsstring[512];
		format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d %d\n",
		DynamicCars[idx][CarModel],
		DynamicCars[idx][CarX],
		DynamicCars[idx][CarY],
		DynamicCars[idx][CarZ],
		DynamicCars[idx][CarAngle],
		DynamicCars[idx][CarColor1],
		DynamicCars[idx][CarColor2]);

		if(idx == 0)
		{
			file2 = fopen("vehicles/san_andreas.txt", io_write);
		}
		else
		{
			file2 = fopen("vehicles/san_andreas.txt", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
	return 1;
}
... and san_andreas.txt format
Код:
modelid, Float:spawn_x, Float:spawn_y,Float:spawn_z, Float:angle, color1, color2 ;
This script is meaned to work on 0.3 version.
Reply
#2

Set debug messages. Does the code fail /park or SaveDynamicCars(); ?
Also, you don't need to make public SaveDynamicCars if it isn't in a timer
Reply
#3

Quote:
Originally Posted by dice7
Set debug messages. Does the code fail /park or SaveDynamicCars(); ?
Looks like it stop writing debug msgs after GetVehicleZAngle(vehicleid, a);
Код:
...
new vehicleid = GetPlayerVehicleID(playerid);
new car = GetPlayerVehicleID(playerid) - 1;
new Float:x,Float:y,Float:z;
new Float:a;
...
GetVehiclePos(vehicleid, x, y, z); // Gets vehicle pos
GetVehicleZAngle(vehicleid, a); // Gets vehicle angle
Stop on at this
After there will be...
Код:
DynamicCars[car][CarX] = x; // Coords
DynamicCars[car][CarY] = y; // Coords
DynamicCars[car][CarZ] = z; // Coords
DynamicCars[car][CarAngle] = a; // Angle
DestroyVehicle(vehicleid); // Destoroy car
...
Those are on at /park phase.
Reply
#4

I still need help with this
Reply
#5

Did you tried it inside vehicle?
Reply
#6

Quote:
Originally Posted by MadeMan
Did you tried it inside vehicle?
Yeah, of course...
Reply
#7

Can you show how you create variable DynamicCars ?

I guess it's an enum.
Reply
#8

Код:
enum Cars
{
	CarModel,
	Float:CarX,
	Float:CarY,
	Float:CarZ,
	Float:CarAngle,
	CarColor1,
	CarColor2,
};
Код:
new DynamicCars[140][Cars];
Reply
#9

Do you have less than 140 cars in your server? If you have more then make the array bigger.
Reply
#10

Quote:
Originally Posted by MadeMan
Do you have less than 140 cars in your server? If you have more then make the array bigger.
Kk, yeah i have over 1800+ vehicles, so i make an bigger array, it worked.
Код:
new DynamicCars[1900][Cars];
But now, when it saves the vehicle, it screw up whole san_andreas.txt vehicle file.... why? I think there is something messed with code..?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)