SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 07/06/2014, 08:08 AM   #1
AiRaLoKa
Huge Clucker
 
AiRaLoKa's Avatar
 
Join Date: Aug 2013
Location: Indonesia! Nickname: [MP]AiRa_
Posts: 400
Reputation: 27
Default Vehicle ID

hi all...

i have a little bit bug here... i want to make a vehicle spawner, and when i test it alone, it's work fine.
but when i try it with some of my friends, it's got bugged. What i want is destroy previouse player's spawned vehicle. but it's destroy my friend's vehicle can somebody help me?

pawn Code:
//
if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vid);
        if(VehicleSpawn[playerid]==0)
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = AddStaticVehicle(model, x, y, z+1, a, -1, -1);
            PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
            SetVehicleHealth(pInfo[playerid][pSpawnVehicle],  1000.0);
            LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        }
    }
__________________
sorry for my fucking bad english... becouse i'm Indonesian!
~~> Find all threads started by AiRaLoKa <~~

AiRaLoKa is offline   Reply With Quote
Old 07/06/2014, 08:20 AM   #2
Rittik
Huge Clucker
 
Rittik's Avatar
 
Join Date: May 2014
Location: github.com/RittikVerma
Posts: 450
Reputation: 33
Default Re: Vehicle ID

I guess AddStaticvehicle only works under GameModeInit.
AddStaticVehicle
Rittik is offline   Reply With Quote
Old 07/06/2014, 08:21 AM   #3
BroZeus
High-roller
 
BroZeus's Avatar
 
Join Date: Jan 2014
Location: India
Posts: 1,398
Reputation: 173
Default Re: Vehicle ID

is this under a command?
__________________


"Be the change that you wish to see in the world."

Check out my Github profile!
BroZeus is offline   Reply With Quote
Old 07/06/2014, 08:23 AM   #4
AiRaLoKa
Huge Clucker
 
AiRaLoKa's Avatar
 
Join Date: Aug 2013
Location: Indonesia! Nickname: [MP]AiRa_
Posts: 400
Reputation: 27
Default Re: Vehicle ID

Quote:
Originally Posted by BroZeus View Post
is this under a command?

no
this is the full script

pawn Code:
public VehicleSpawner(playerid,model)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid);
        DestroyVehicle(vid);
        if(VehicleSpawn[playerid]==0)
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = AddStaticVehicleEx(model, x, y, z+1, a, -1, -1, -1);
            PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
            SetVehicleHealth(pInfo[playerid][pSpawnVehicle],  1000.0);
            LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        }
    }
    else
    {
        if(VehicleSpawn[playerid]==0)
        {
            new Float:x,Float:y,Float:z,Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = AddStaticVehicleEx(model, x, y, z+1, a, -1, -1, -1);
            PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
            SetVehicleHealth(pInfo[playerid][pSpawnVehicle],  1000.0);
            LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        }
    }
    return 1;
}
__________________
sorry for my fucking bad english... becouse i'm Indonesian!
~~> Find all threads started by AiRaLoKa <~~

AiRaLoKa is offline   Reply With Quote
Old 07/06/2014, 08:25 AM   #5
SupaFool
Guest
 
Posts: n/a
Default Re: Vehicle ID

Maybe make it out of stock?
  Reply With Quote
Old 07/06/2014, 08:26 AM   #6
BroZeus
High-roller
 
BroZeus's Avatar
 
Join Date: Jan 2014
Location: India
Posts: 1,398
Reputation: 173
Default Re: Vehicle ID

were u in ur friend's vehicle
or
your friend was in your vehicle when u tried that?
__________________


"Be the change that you wish to see in the world."

Check out my Github profile!
BroZeus is offline   Reply With Quote
Old 07/06/2014, 08:28 AM   #7
AiRaLoKa
Huge Clucker
 
AiRaLoKa's Avatar
 
Join Date: Aug 2013
Location: Indonesia! Nickname: [MP]AiRa_
Posts: 400
Reputation: 27
Default Re: Vehicle ID

Quote:
Originally Posted by BroZeus View Post
were u in ur friend's vehicle
or
your friend was in your vehicle when u tried that?
no, my friend is in another vehicle,, when i use the command to spawn the vehicle, his vehicle gone.
__________________
sorry for my fucking bad english... becouse i'm Indonesian!
~~> Find all threads started by AiRaLoKa <~~

AiRaLoKa is offline   Reply With Quote
Old 08/06/2014, 06:07 AM   #8
AiRaLoKa
Huge Clucker
 
AiRaLoKa's Avatar
 
Join Date: Aug 2013
Location: Indonesia! Nickname: [MP]AiRa_
Posts: 400
Reputation: 27
Default Re: Vehicle ID

sorry for bumping, but i still have this bug can somebody help me?
__________________
sorry for my fucking bad english... becouse i'm Indonesian!
~~> Find all threads started by AiRaLoKa <~~

AiRaLoKa is offline   Reply With Quote
Old 08/06/2014, 08:23 AM   #9
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,122
Reputation: 529
Default Re: Vehicle ID

I don't know where you're using VehicleSpawner, but this should work:
pawn Code:
public VehicleSpawner(playerid, model)
{
    if(!VehicleSpawn[playerid]) //Dunno what this means, but oh well.
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new vid = GetPlayerVehicleID(playerid);
            if(vid) SetVehicleToRespawn(vid);
        }
        new Float:x, Float:y, Float:z, Float:a;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(pInfo[playerid][pSpawnVehicle] != INVALID_VEHICLE_ID)
        {
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = INVALID_VEHICLE_ID;
        }
        pInfo[playerid][pSpawnVehicle] = CreateVehicle(model, x, y, z + 1, a, -1, -1, -1);
        PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
        LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        return pInfo[playerid][pSpawnVehicle];
    }
    return INVALID_VEHICLE_ID;
}
__________________


Kar's Cops and Robbers 2020
Threshold is offline   Reply With Quote
Old 08/06/2014, 09:12 AM   #10
AiRaLoKa
Huge Clucker
 
AiRaLoKa's Avatar
 
Join Date: Aug 2013
Location: Indonesia! Nickname: [MP]AiRa_
Posts: 400
Reputation: 27
Default Re: Vehicle ID

Quote:
Originally Posted by BenzoAMG View Post
I don't know where you're using VehicleSpawner, but this should work:
pawn Code:
public VehicleSpawner(playerid, model)
{
    if(!VehicleSpawn[playerid]) //Dunno what this means, but oh well.
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new vid = GetPlayerVehicleID(playerid);
            if(vid) SetVehicleToRespawn(vid);
        }
        new Float:x, Float:y, Float:z, Float:a;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(pInfo[playerid][pSpawnVehicle] != INVALID_VEHICLE_ID)
        {
            DestroyVehicle(pInfo[playerid][pSpawnVehicle]);
            pInfo[playerid][pSpawnVehicle] = INVALID_VEHICLE_ID;
        }
        pInfo[playerid][pSpawnVehicle] = CreateVehicle(model, x, y, z + 1, a, -1, -1, -1);
        PutPlayerInVehicle(playerid, pInfo[playerid][pSpawnVehicle], 0);
        LinkVehicleToInterior(pInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
        return pInfo[playerid][pSpawnVehicle];
    }
    return INVALID_VEHICLE_ID;
}
yeah, i think it will work, by reading the code...
going to test it

EDIT:
it's work! thanks BenzoAMG and +REP
__________________
sorry for my fucking bad english... becouse i'm Indonesian!
~~> Find all threads started by AiRaLoKa <~~


Last edited by AiRaLoKa; 09/06/2014 at 03:21 AM.
AiRaLoKa is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] tAxI's Xtreme Vehicle Management - Advanced Vehicle Ownership and Administration Menu CJay9209 Filterscripts 13 16/10/2015 07:21 AM
No driver bug while putting player directly from RC vehicle to normal vehicle. KovaNovik Bug Reports 1 27/07/2015 05:24 PM
Angle Issues: Setting a attached object on a vehicle to face a vehicle Kar Scripting Help 2 11/07/2012 12:37 AM
[FilterScript] [FS] tAxI's Vehicle Streamer [v0.2] - add unlimited vehicle spawns and models!!! cptnsausage Filterscripts 205 31/07/2010 05:29 AM


All times are GMT. The time now is 04:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.