SA-MP Forums Archive
How to compare vehicle and player's interior? - 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: How to compare vehicle and player's interior? (/showthread.php?tid=646861)



How to compare vehicle and player's interior? - Ritzy2K - 25.12.2017

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.


Re: How to compare vehicle and player's interior? - RogueDrifter - 25.12.2017

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.


Re: How to compare vehicle and player's interior? - Ritzy2K - 25.12.2017

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


Re: How to compare vehicle and player's interior? - MEW273 - 25.12.2017

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.


Re: How to compare vehicle and player's interior? - rfr - 25.12.2017

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


Re: How to compare vehicle and player's interior? - RIDE2DAY - 25.12.2017

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


Re: How to compare vehicle and player's interior? - JustNothing - 25.12.2017

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



Re: How to compare vehicle and player's interior? - NaS - 25.12.2017

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.


Re: How to compare vehicle and player's interior? - Ritzy2K - 25.12.2017

Thanks everybody for your input.
Fixed, thanks.