Vehicle System (parking bug)
#1

As you can see on my video its a parking bug and I dont know how to get rid off it.So if someone could help i would really appreciate it.

Here is the .pwn file:

http://www.solidfiles.com/d/8dd1310e26/

VIDEO:

[Watch video in 720p]

http://www.youtube.com/watch?v=-9iay...ature=*********
Reply
#2

Someone help please?I need to fix that bug immediatly.

Thanks!
Reply
#3

Here is the command /park :

Код:
	if(strcmp(cmd, "/park", true) == 0)
	{
     	new Float:X, Float:Y, Float:Z, Float:Rot;
   	  	if(!IsPlayerInVehicle(playerid, Vehicle[playerid]))
   		{
   			SendClientMessage(playerid, 0xFFFFFFAA, "You are not in a car that you own.");
			return 1;
		}
		new file[256], name[24];
    	GetPlayerName(playerid, name, 24);
		format(file,sizeof(file),"Cars/%s.ini",name);
	    dini_IntSet(file, "Model", VehicleInfo[playerid][Model]);
		dini_IntSet(file, "Price", VehicleInfo[playerid][Price]);
		dini_FloatSet(file, "X", VehicleInfo[playerid][CarX]);
		dini_FloatSet(file, "Y", VehicleInfo[playerid][CarY]);
		dini_FloatSet(file, "Z", VehicleInfo[playerid][CarZ]);
		dini_FloatSet(file, "Rot", VehicleInfo[playerid][CarRot]);
		dini_IntSet(file, "Locked", VehicleInfo[playerid][Locked]);
		dini_Set(file, "Plate", VehPlate[Vehicle[playerid]]);
		dini_IntSet(file, "mod1", VehicleInfo[playerid][mod1]);
		dini_IntSet(file, "mod2", VehicleInfo[playerid][mod2]);
		dini_IntSet(file, "mod3", VehicleInfo[playerid][mod3]);
		dini_IntSet(file, "mod4", VehicleInfo[playerid][mod4]);
		dini_IntSet(file, "mod5", VehicleInfo[playerid][mod5]);
		dini_IntSet(file, "mod6", VehicleInfo[playerid][mod6]);
		dini_IntSet(file, "mod7", VehicleInfo[playerid][mod7]);
		dini_IntSet(file, "mod8", VehicleInfo[playerid][mod8]);
		dini_IntSet(file, "mod9", VehicleInfo[playerid][mod9]);
		dini_IntSet(file, "mod10", VehicleInfo[playerid][mod10]);
		dini_IntSet(file, "mod11", VehicleInfo[playerid][mod11]);
		dini_IntSet(file, "mod12", VehicleInfo[playerid][mod12]);
		dini_IntSet(file, "mod13", VehicleInfo[playerid][mod13]);
		dini_IntSet(file, "mod14", VehicleInfo[playerid][mod14]);
		dini_IntSet(file, "mod15", VehicleInfo[playerid][mod15]);
		dini_IntSet(file, "mod16", VehicleInfo[playerid][mod16]);
		dini_IntSet(file, "mod17", VehicleInfo[playerid][mod17]);
		dini_IntSet(file, "paintjob", VehicleInfo[playerid][paintjob]);
		dini_IntSet(file, "color1", VehicleInfo[playerid][colora]);
		dini_IntSet(file, "color2", VehicleInfo[playerid][colorb]);
  		SendClientMessage(playerid, 0xFFFF00FF, "Car parked successfully, it'll respawn at your parked location.");
     	GetVehiclePos(Vehicle[playerid], X, Y, Z);
     	GetVehicleZAngle(Vehicle[playerid], Rot);
     	VehicleInfo[playerid][Model] = GetVehicleModel(playerid);
     	VehicleInfo[playerid][CarX] = X;
     	VehicleInfo[playerid][CarY] = Y;
     	VehicleInfo[playerid][CarZ] = Z;
     	VehicleInfo[playerid][CarRot] = Rot;
     	return 1;
	}
Reply
#4

I think you should destroy it then spawn it again at the new position in order to make it respawn there..
Reply
#5

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
I think you should destroy it then spawn it again at the new position in order to make it respawn there..
I destroyed it.It spawned at the same place as on video.I want that when someone use cmd /park it would par there and it would be there until player park it somewhere else.
Reply
#6

You didn't destroy it. You just re-spawned all the vehicles at the place they where spawned in... Use DestroyVehicle then CreateVehicle
Reply
#7

I guess you've mixed up some things.
According to your code, you grab the coordinates of the vehicle-data (from VehicleInfo) and save that data to disc.
Then you grab the current position of your vehicle, which then gets stored in VehicleInfo.
Shouldn't you:
- grab the current coordinates first
- store them in your VehicleInfo array
- then save to disc
?

I also don't see any code which destroys the vehicle and re-creates it at the new coordinates.

What you can do as well, is using OnVehicleSpawn.
In that callback, use SetVehiclePos to the coordinates you stored in VehicleInfo.
That should do it as well, then you won't have to destroy the vehicle and re-create is at the saved coordinates (which may mix-up vehicle-id's).
Reply
#8

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
I guess you've mixed up some things.
According to your code, you grab the coordinates of the vehicle-data (from VehicleInfo) and save that data to disc.
Then you grab the current position of your vehicle, which then gets stored in VehicleInfo.
Shouldn't you:
- grab the current coordinates first
- store them in your VehicleInfo array
- then save to disc
?

I also don't see any code which destroys the vehicle and re-creates it at the new coordinates.

What you can do as well, is using OnVehicleSpawn.
In that callback, use SetVehiclePos to the coordinates you stored in VehicleInfo.
That should do it as well, then you won't have to destroy the vehicle and re-create is at the saved coordinates (which may mix-up vehicle-id's).
Sounds logic.But I didnt made that FS,I downloaded it from samp forums and I dont know how to edit it like you said now.I am still a newbie and I am still learning,so if someone could put that stuff which PowerPC603 said in the script so it would work i would be really thanksfull!
Reply
#9

pawn Код:
if(strcmp(cmd, "/park", true) == 0)
    {
        new Float:X, Float:Y, Float:Z, Float:Rot;
        if(!IsPlayerInVehicle(playerid, Vehicle[playerid]))
        {
        SendClientMessage(playerid, 0xFFFFFFAA, "You are not in a car that you own.");
        return 1;
        }
        new file[256], name[24];
        GetVehiclePos(Vehicle[playerid], X, Y, Z);
        GetVehicleZAngle(Vehicle[playerid], Rot);
        VehicleInfo[playerid][Model] = GetVehicleModel(playerid);
        VehicleInfo[playerid][CarX] = X;
        VehicleInfo[playerid][CarY] = Y;
        VehicleInfo[playerid][CarZ] = Z;
        VehicleInfo[playerid][CarRot] = Rot;
        GetPlayerName(playerid, name, 24);
        format(file,sizeof(file),"Cars/%s.ini", name);
        dini_IntSet(file, "Model", VehicleInfo[playerid][Model]);
        dini_IntSet(file, "Price", VehicleInfo[playerid][Price]);
        dini_FloatSet(file, "X", VehicleInfo[playerid][CarX]);
        dini_FloatSet(file, "Y", VehicleInfo[playerid][CarY]);
        dini_FloatSet(file, "Z", VehicleInfo[playerid][CarZ]);
        dini_FloatSet(file, "Rot", VehicleInfo[playerid][CarRot]);
        dini_IntSet(file, "Locked", VehicleInfo[playerid][Locked]);
        dini_Set(file, "Plate", VehPlate[Vehicle[playerid]]);
        dini_IntSet(file, "mod1", VehicleInfo[playerid][mod1]);
        dini_IntSet(file, "mod2", VehicleInfo[playerid][mod2]);
        dini_IntSet(file, "mod3", VehicleInfo[playerid][mod3]);
        dini_IntSet(file, "mod4", VehicleInfo[playerid][mod4]);
        dini_IntSet(file, "mod5", VehicleInfo[playerid][mod5]);
        dini_IntSet(file, "mod6", VehicleInfo[playerid][mod6]);
        dini_IntSet(file, "mod7", VehicleInfo[playerid][mod7]);
        dini_IntSet(file, "mod8", VehicleInfo[playerid][mod8]);
        dini_IntSet(file, "mod9", VehicleInfo[playerid][mod9]);
        dini_IntSet(file, "mod10", VehicleInfo[playerid][mod10]);
        dini_IntSet(file, "mod11", VehicleInfo[playerid][mod11]);
        dini_IntSet(file, "mod12", VehicleInfo[playerid][mod12]);
        dini_IntSet(file, "mod13", VehicleInfo[playerid][mod13]);
        dini_IntSet(file, "mod14", VehicleInfo[playerid][mod14]);
        dini_IntSet(file, "mod15", VehicleInfo[playerid][mod15]);
        dini_IntSet(file, "mod16", VehicleInfo[playerid][mod16]);
        dini_IntSet(file, "mod17", VehicleInfo[playerid][mod17]);
        dini_IntSet(file, "paintjob", VehicleInfo[playerid][paintjob]);
        dini_IntSet(file, "color1", VehicleInfo[playerid][colora]);
        dini_IntSet(file, "color2", VehicleInfo[playerid][colorb]);
        SendClientMessage(playerid, 0xFFFF00FF, "Car parked successfully, it'll respawn at your parked location.");
        return 1;
    }
Maybe ?
Reply
#10

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
I guess you've mixed up some things.
According to your code, you grab the coordinates of the vehicle-data (from VehicleInfo) and save that data to disc.
Then you grab the current position of your vehicle, which then gets stored in VehicleInfo.
Shouldn't you:
- grab the current coordinates first
- store them in your VehicleInfo array
- then save to disc
?

I also don't see any code which destroys the vehicle and re-creates it at the new coordinates.

What you can do as well, is using OnVehicleSpawn.
In that callback, use SetVehiclePos to the coordinates you stored in VehicleInfo.
That should do it as well, then you won't have to destroy the vehicle and re-create is at the saved coordinates (which may mix-up vehicle-id's).
As Power said.Can someone edit my /park command so it works?

CMD:

Код:
if(strcmp(cmd, "/park", true) == 0)
    {
        new Float:X, Float:Y, Float:Z, Float:Rot;
        if(!IsPlayerInVehicle(playerid, Vehicle[playerid]))
        {
        SendClientMessage(playerid, 0xFFFFFFAA, "You are not in a car that you own.");
        return 1;
        }
        new file[256], name[24];
        GetVehiclePos(Vehicle[playerid], X, Y, Z);
        GetVehicleZAngle(Vehicle[playerid], Rot);
        VehicleInfo[playerid][Model] = GetVehicleModel(playerid);
        VehicleInfo[playerid][CarX] = X;
        VehicleInfo[playerid][CarY] = Y;
        VehicleInfo[playerid][CarZ] = Z;
        VehicleInfo[playerid][CarRot] = Rot;
        GetPlayerName(playerid, name, 24);
        format(file,sizeof(file),"Cars/%s.ini", name);
        dini_IntSet(file, "Model", VehicleInfo[playerid][Model]);
        dini_IntSet(file, "Price", VehicleInfo[playerid][Price]);
        dini_FloatSet(file, "X", VehicleInfo[playerid][CarX]);
        dini_FloatSet(file, "Y", VehicleInfo[playerid][CarY]);
        dini_FloatSet(file, "Z", VehicleInfo[playerid][CarZ]);
        dini_FloatSet(file, "Rot", VehicleInfo[playerid][CarRot]);
        dini_IntSet(file, "Locked", VehicleInfo[playerid][Locked]);
        dini_Set(file, "Plate", VehPlate[Vehicle[playerid]]);
        dini_IntSet(file, "mod1", VehicleInfo[playerid][mod1]);
        dini_IntSet(file, "mod2", VehicleInfo[playerid][mod2]);
        dini_IntSet(file, "mod3", VehicleInfo[playerid][mod3]);
        dini_IntSet(file, "mod4", VehicleInfo[playerid][mod4]);
        dini_IntSet(file, "mod5", VehicleInfo[playerid][mod5]);
        dini_IntSet(file, "mod6", VehicleInfo[playerid][mod6]);
        dini_IntSet(file, "mod7", VehicleInfo[playerid][mod7]);
        dini_IntSet(file, "mod8", VehicleInfo[playerid][mod8]);
        dini_IntSet(file, "mod9", VehicleInfo[playerid][mod9]);
        dini_IntSet(file, "mod10", VehicleInfo[playerid][mod10]);
        dini_IntSet(file, "mod11", VehicleInfo[playerid][mod11]);
        dini_IntSet(file, "mod12", VehicleInfo[playerid][mod12]);
        dini_IntSet(file, "mod13", VehicleInfo[playerid][mod13]);
        dini_IntSet(file, "mod14", VehicleInfo[playerid][mod14]);
        dini_IntSet(file, "mod15", VehicleInfo[playerid][mod15]);
        dini_IntSet(file, "mod16", VehicleInfo[playerid][mod16]);
        dini_IntSet(file, "mod17", VehicleInfo[playerid][mod17]);
        dini_IntSet(file, "paintjob", VehicleInfo[playerid][paintjob]);
        dini_IntSet(file, "color1", VehicleInfo[playerid][colora]);
        dini_IntSet(file, "color2", VehicleInfo[playerid][colorb]);
        SendClientMessage(playerid, 0xFFFF00FF, "Car parked successfully, it'll respawn at your parked location.");
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)