SA-MP Forums Archive
Destroy wrong vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Destroy wrong vehicle (/showthread.php?tid=626993)



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(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 -----


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:----- SpawnedVehicle:482
2. playerid
:----- 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(playeridreason)
{
 
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(playeridreason)
{
 
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(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;




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(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.