Destroy wrong vehicle -
MRM - 22.01.2017
I make ownvehicle.
i use CreateVehicle. But not work correctly.
In cmd i use CreateXVehicle2(ID , car);
My code:
PHP код:
CreateVehicle2(playerid, modelid)
{
new Float:x,Float:y,Float:z,Float:angulo;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angulo);
if(SpawnedVehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(SpawnedVehicle[playerid]);
SpawnedVehicle[playerid] = CreateVehicle(modelid,x+0.5,y+3,z,angulo,-1,-1,9000);
printf("2. playerid:%d ----- SpawnedVehicle:%d -----",playerid,SpawnedVehicle[playerid]);
return 1;
}
2. playerid:13 ----- SpawnedVehicle:480 -----
2. playerid:10 ----- SpawnedVehicle:480 -----
Re: Destroy wrong vehicle -
aymane123 - 22.01.2017
I Didnt get it do u have problems with the sent message or with destroying the vehicle or the spawn position ?
Re: Destroy wrong vehicle -
MRM - 23.01.2017
When i (playerid 10) use CMD. Server destroy vehicle playerid 13 Because SpawnedVehicle is 480.
in sometimes work correctly:
PHP код:
2. playerid:8 ----- SpawnedVehicle:482
2. playerid:9 ----- SpawnedVehicle:481
Re: Destroy wrong vehicle -
MRM - 31.01.2017
UP .........
Re: Destroy wrong vehicle -
haikalbintang - 31.01.2017
You should add this :
PHP код:
public OnPlayerConnect(playerid)
{
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
}
//also
public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicle(SpawnedVehicle[playerid]);
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
}
I hope that will work.
Re: Destroy wrong vehicle -
MRM - 01.02.2017
Quote:
Originally Posted by haikalbintang
You should add this :
PHP код:
public OnPlayerConnect(playerid)
{
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
}
//also
public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicle(SpawnedVehicle[playerid]);
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
}
I hope that will work.
|
Not work
Re: Destroy wrong vehicle -
haikalbintang - 01.02.2017
Quote:
Originally Posted by MRM
Not work
|
Or change the SpawnVehicle[playerid] with this :
PHP код:
enum pInfo
{
pVehicle
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pVehicle] = INVALID_VEHICLE_ID;
}
&
public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicle(PlayerInfo[playerid][pVehicle]);
PlayerInfo[playerid][pVehicle] = INVALID_VEHICLE_ID;
}
CreateXVehicle2(playerid, modelid)
{
new Float:x,Float:y,Float:z,Float:angulo;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angulo);
if(PlayerInfo[playerid][pVehicle] != INVALID_VEHICLE_ID) DestroyVehicle(PlayerInfo[playerid][pVehicle]);
PlayerInfo[playerid][pVehicle] = CreateVehicle(modelid,x+0.5,y+3,z,angulo,-1,-1,9000);
printf("2. playerid:%d ----- SpawnedVehicle:%d -----",playerid,PlayerInfo[playerid][pVehicle]);
return 1;
}
Re: Destroy wrong vehicle -
MRM - 03.06.2017
Quote:
Originally Posted by haikalbintang
Or change the SpawnVehicle[playerid] with this :
PHP код:
enum pInfo
{
pVehicle
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pVehicle] = INVALID_VEHICLE_ID;
}
&
public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicle(PlayerInfo[playerid][pVehicle]);
PlayerInfo[playerid][pVehicle] = INVALID_VEHICLE_ID;
}
CreateXVehicle2(playerid, modelid)
{
new Float:x,Float:y,Float:z,Float:angulo;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angulo);
if(PlayerInfo[playerid][pVehicle] != INVALID_VEHICLE_ID) DestroyVehicle(PlayerInfo[playerid][pVehicle]);
PlayerInfo[playerid][pVehicle] = CreateVehicle(modelid,x+0.5,y+3,z,angulo,-1,-1,9000);
printf("2. playerid:%d ----- SpawnedVehicle:%d -----",playerid,PlayerInfo[playerid][pVehicle]);
return 1;
}
|
Problem again happend.