How to compare vehicle and player's interior?
#1

Native for player is available.
GetPlayerInterior(playerid)

But theres no GetVehicleInterior so im not sure how'd I compare a vehicle's and a player's a interior.
Reply
#2

Create it manually, basically before you do LinkVehicleToInterior save that interior into a variable and compare that variable to the player's interior u wanna compare to.
Reply
#3

Uh, I don't think so.
I don't want to set it's interior, I just want to retrieve it's current interior.
Reply
#4

There is no native function to return the vehicle's interior and from a quick search I can't find any plugin/extensions that claim to do so.

As RogueDrifter stated you need to store the interior variable when you use LinkVehicleToInterior and use that variable later.

By default when you create a vehicle it is set to interior 0, so unless you specify otherwise you can assume that the interior is always 0. If you add a variable to your vehicle enumerator that stores the interior ID even if it is 0 you can just retrieve that value to compare the interior.
Reply
#5

PHP код:
#include <a_samp>
#include <izcmd>
#include <sscanf2>
new vInt[MAX_PLAYERS] = 0;
CMD:vehicleint(playeridparms[]) {
    new 
vehicle AddStaticVehicle(5592543.7505, -21.834527.189952.6054, -1, -1);
    
vInt[playerid] = LinkVehicleToInterior(vehicle6);
    if(
GetPlayerInterior(playerid) == vInt[playerid])
    {
        
//execute code here
    
}
    return 
1;

idk

or

PHP код:
CMD:vehicleint1(playeridparms[]) {
    new 
vehicle AddStaticVehicle(5592543.7505, -21.834527.189952.6054, -1, -1);
    
vInt[playerid] = LinkVehicleToInterior(vehicle6);
    new 
string[64];
    
format(stringsizeof(string),"vehicle interior is %i.",vInt[playerid]);
    
SendClientMessage(playerid, -1string);
    return 
1;

idk
Reply
#6

vSync provides that function.
https://sampforum.blast.hk/showthread.php?tid=642022

You can see the full list of available functions here:
https://sampwiki.blast.hk/wiki/Vehicle_Synchronization
Reply
#7

Quote:
Originally Posted by rfr
Посмотреть сообщение
PHP код:
#include <a_samp>
#include <izcmd>
#include <sscanf2>
new vInt[MAX_PLAYERS] = 0;
CMD:vehicleint(playeridparms[]) {
    new 
vehicle AddStaticVehicle(5592543.7505, -21.834527.189952.6054, -1, -1);
    
vInt[playerid] = LinkVehicleToInterior(vehicle6);
    if(
GetPlayerInterior(playerid) == vInt[playerid])
    {
        
//execute code here
    
}
    return 
1;

idk

or

PHP код:
CMD:vehicleint1(playeridparms[]) {
    new 
vehicle AddStaticVehicle(5592543.7505, -21.834527.189952.6054, -1, -1);
    
vInt[playerid] = LinkVehicleToInterior(vehicle6);
    new 
string[64];
    
format(stringsizeof(string),"vehicle interior is %i.",vInt[playerid]);
    
SendClientMessage(playerid, -1string);
    return 
1;

idk
https://sampwiki.blast.hk/wiki/LinkVehicleToInterior
your code wont work properly because function not returns new id lol

this should work:

Код HTML:
new interiorVehicle[ MAX_VEHICLES ];

#if defined _ALS_LinkVehicleToInterior
    #undef LinkVehicleToInterior
#else
    #define _ALS_LinkVehicleToInterior
#endif
#define LinkVehicleToInterior interiorVehicle[ %0 ] = %1



// usage interiorVehicle[ vehicleid ] xdd
Reply
#8

Just create a new global array and update it everytime you set a vehicle's interior.
Remember vehicle ids start at 1 and not 0, so you have to access the array with vehicleid - 1 or declare the array with MAX_VEHICLES + 1.

Код:
new gVehicleInteriorIDs[MAX_VEHICLES];

n_LinkVehicleToInterior(vehicleid, interior)
{
    LinkVehicleToInterior(vehicleid, interior),
    gVehicleInteriorIDs[vehicleid - 1] = interior;
}
#define LinkVehicleToInterior n_LinkVehicleToInterior

GetVehicleInterior(vehicleid)
{
    return gVehicleInteriorIDs[vehicleid - 1];
}
Make sure to reset the variable when you create new vehicles, otherwise the array could still contain another interior if that slot was used before.
Reply
#9

Thanks everybody for your input.
Fixed, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)