[Help] Park problem
#1

Hello all... I have problem when i park car it spawns other vehicle .... I tried to put carid, instead of CarInfo[carid][cModel]

Here is the code

pawn Код:
else if(strcmp(x_nr,"park",true) == 0)
            {
                new Float:x,Float:y,Float:z;
                new Float:a;
                new carid;
                new getcarid;
                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
                else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid = PlayerInfo[playerid][pPcarkey3]; }
                else { return 1; }
                getcarid = GetPlayerVehicleID(playerid);
                carid = GetPlayerVehicleID(playerid);
                GetPlayerName(playerid, playername, sizeof(playername));
                GetVehiclePos(carid, x, y, z);
                GetVehicleZAngle(carid, a);
                if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
                {
                    if(PlayerInfo[playerid][pPcarkey] == 999 && PlayerInfo[playerid][pPcarkey2] == 999 & PlayerInfo[playerid][pPcarkey3])
                    {
                        SendClientMessage(playerid, BOJA_SIVA, "Ne posedujete auto.");
                        return 1;
                    }
                    if(getcarid == carid)
                    {
                        CarInfo[carid][cLocationx] = x;
                        CarInfo[carid][cLocationy] = y;
                        CarInfo[carid][cLocationz] = z;
                        CarInfo[carid][cAngle] = a;
                        format(string, sizeof(string), "~n~ Parkirali ste vozilo na ovoj lokaciji ~n~");
                        GameTextForPlayer(playerid, "Parkirali ste vozilo na ovoj lokaciji. Respawnovace se ovde!.", 10000, 3);
                        OnPropUpdate();
                        OnPlayerUpdate(playerid);
                        DestroyVehicle(carid);
                        CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                        TogglePlayerControllable(playerid, 1);
                        return 1;
                    }
                }
            }
Reply
#2

Bump..
Reply
#3

The model writes the model of the car, right? if model == carid then you've done it wrong.
Reply
#4

What should do this piece of code
Reply
#5

CarInfo[carid][cModel] reads carid ... i've tried change CarInfo[carid][cModel] to carid... Then car won't spawn

@Vykintas When the player enter /v park .. vehicle is get position where he is and saving it.. then it destroys the car and spawn it again on that position
Reply
#6

I think this is that you need. Am I wrong?


pawn Code:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/v park", cmdtext, true) == 0)
	{
		new Float: Pos[3], carid;
		// Get Vehicle ID
		carid=GetPlayerVehicleID(playerid);
		// Get Vehicle Pos
		GetVehiclePos(carid,Pos[0],Pos[1],Pos[2]);  
		// Save Vehicle Pos
		CarInfo[carid][cLocationx] = Pos[0];
  		CarInfo[carid][cLocationy] = Pos[1];
        CarInfo[carid][cLocationz] = Pos[2];
        // Get Vehicle Rotation
        GetVehicleZAngle(carid,Pos[0];
		// Save Vehicle Rotation
        CarInfo[carid][cAngle] = Pos[0];
        // Destroy Vehicle
        DestroyVehicle(carid);
        // Recreate Vehicle In Saved Position
		CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
		return 1;
	}
	return 0;
}
Reply
#7

man.. there are more /v commands like /v list, /v lock, /v sell etc..

do you see that there is else if(strcmp

bug is when i park the car, it spawns other vehicle .. not vehicle i parked .. understand?
Reply
#8

You can fix it by adding this line before vehicle spawning:
Код:
CarInfo[carid][cModel]=GetVehicleModel(carid);
Reply
#9

nope.. solved .. didn't changed ownablecars id's .. ty anyway .. k+
Reply
#10

YAY! EVERYBODY WINS!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)