[Help] Park problem -
Stereotype - 29.12.2013
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;
}
}
}
Re: [Help] Park problem -
Stereotype - 30.12.2013
Bump..
Re: [Help] Park problem -
Mattakil - 30.12.2013
The model writes the model of the car, right? if model == carid then you've done it wrong.
Re: [Help] Park problem -
Vykintas - 30.12.2013
What should do this piece of code
Re: [Help] Park problem -
Stereotype - 30.12.2013
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
Re: [Help] Park problem -
Vykintas - 30.12.2013
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;
}
Re: [Help] Park problem -
Stereotype - 30.12.2013
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?
Re: [Help] Park problem -
Vykintas - 30.12.2013
You can fix it by adding this line before vehicle spawning:
Код:
CarInfo[carid][cModel]=GetVehicleModel(carid);
Re: [Help] Park problem -
Stereotype - 30.12.2013
nope.. solved .. didn't changed ownablecars id's .. ty anyway .. k+
Re: [Help] Park problem -
TheDarkOne - 30.12.2013
YAY! EVERYBODY WINS!