Buggy command
#1

Hello people I'm wanting urgent help someone, and I have to fix this, is this is this following command buggy auto park the vehicle:

Код:
    if(strcmp(cmd, "/autoestacionar", true) == 0)
	{
	    if(PlayerInfo[playerid][pCarro] == 255)
	    {
	       SendClientMessage(playerid, COLOR_GREY,"You do not own a vehicle.");
	       return 1;
	    }
		if(!IsPlayerInAnyVehicle(playerid))
		{
			SendClientMessage(playerid,COLOR_GREY,"You need to be on your vehicle.");
			return 1;
		}
	   	new Float:x,Float:y,Float:z;
		new Float:a;
		new carid;
		new getcarid;
		if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
		{
  			getcarid = GetPlayerVehicleID(playerid);
			GetPlayerName(playerid, playername, sizeof(playername));
			GetVehiclePos(carid, x, y, z);
			GetVehicleZAngle(carid, a);
          	if(getcarid == carid)
			{
				CarInfo[carid][cLocationx] = x;
				CarInfo[carid][cLocationy] = y;
				CarInfo[carid][cLocationz] = z;
				CarInfo[carid][cAngle] = a;
				GameTextForPlayer(playerid, "Your vehicle will respawn here.", 10000, 3);
				OnPropUpdate();
				OnPlayerUpdate(playerid);
                DestroyVehicle(carid);
				CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz],CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
				TogglePlayerControllable(playerid,1);
				SaveCars();
				return true;
  			}
			return true;
		}
		return true;
	}
But where is the bug? I do not know when I give /autoestacionar the vehicle or face moves nothing happens, I tried to get more gamemodes did not work, someone help me is urgent and important personal? !!
Reply
#2

Okay, first off.
pawn Код:
if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
You have this, but right above it you already check to see if a player is in a vehicle.

Secondly,
OnPlayerUpdate(playerid) is called every second, meaning you don't even need this there.

Thirdly, what is carid defined as? I believe your command should be checking for ownership of the vehicle
pawn Код:
if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
should be checking if the vehicle is owned by the player or not, which the line above isn't right to check that.

Fourthly, I recommend ZCMD as it's faster/quicker to code, and less lines.
Reply
#3

So as I keep my codes? could not help me here please !?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)