Destroy wrong vehicle
#1

I make ownvehicle.
i use CreateVehicle. But not work correctly.
In cmd i use CreateXVehicle2(ID , car);
My code:
PHP код:
CreateVehicle2(playeridmodelid)
{
    new 
Float:x,Float:y,Float:z,Float:angulo;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playeridangulo);
    if(
SpawnedVehicle[playerid] != INVALID_VEHICLE_IDDestroyVehicle(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 -----
Reply
#2

I Didnt get it do u have problems with the sent message or with destroying the vehicle or the spawn position ?
Reply
#3

When i (playerid 10) use CMD. Server destroy vehicle playerid 13 Because SpawnedVehicle is 480.

in sometimes work correctly:
PHP код:
2. playerid:----- SpawnedVehicle:482
2. playerid
:----- SpawnedVehicle:481 
Reply
#4

UP .........
Reply
#5

You should add this :

PHP код:
public OnPlayerConnect(playerid)
{
   
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
}
//also
public OnPlayerDisconnect(playeridreason)
{
 
DestroyVehicle(SpawnedVehicle[playerid]);
 
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;

I hope that will work.
Reply
#6

Quote:
Originally Posted by haikalbintang
Посмотреть сообщение
You should add this :

PHP код:
public OnPlayerConnect(playerid)
{
   
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;
}
//also
public OnPlayerDisconnect(playeridreason)
{
 
DestroyVehicle(SpawnedVehicle[playerid]);
 
SpawnedVehicle[playerid] = INVALID_VEHICLE_ID;

I hope that will work.
Not work
Reply
#7

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(playeridreason)
{
 
DestroyVehicle(PlayerInfo[playerid][pVehicle]);
 
PlayerInfo[playerid][pVehicle] = INVALID_VEHICLE_ID;
}
CreateXVehicle2(playeridmodelid)
{
    new 
Float:x,Float:y,Float:z,Float:angulo;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playeridangulo);
    if(
PlayerInfo[playerid][pVehicle] != INVALID_VEHICLE_IDDestroyVehicle(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;

Reply
#8

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(playeridreason)
{
 
DestroyVehicle(PlayerInfo[playerid][pVehicle]);
 
PlayerInfo[playerid][pVehicle] = INVALID_VEHICLE_ID;
}
CreateXVehicle2(playeridmodelid)
{
    new 
Float:x,Float:y,Float:z,Float:angulo;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playeridangulo);
    if(
PlayerInfo[playerid][pVehicle] != INVALID_VEHICLE_IDDestroyVehicle(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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)