SA-MP Forums Archive
Get Vehicle ID..... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Get Vehicle ID..... (/showthread.php?tid=128974)



Get Vehicle ID..... - Fedee! - 20.02.2010

How can I get each vehicle ID on the server? I have like 40 vehicles right now...

Vehicle ID 1 equals to the first car added under OnGameModeInit?

Example:
pawn Код:
AddStaticVehicle(522,-1919.2992,1789.9838,209.3784,50.1049,8,82);//ID 1
AddStaticVehicle(522,-1922.7979,1784.3138,209.3821,51.3585,8,82);//ID 2
AddStaticVehicle(522,-1927.3228,1779.3625,209.3804,53.7146,8,82);//ID 3 etc...



Re: Get Vehicle ID..... - smeti - 20.02.2010

No.

AddStaticVehicle(522,-1919.2992,1789.9838,209.3784,50.1049,8,82);// ID 0
AddStaticVehicle(522,-1922.7979,1784.3138,209.3821,51.3585,8,82);// ID 1
AddStaticVehicle(522,-1927.3228,1779.3625,209.3804,53.7146,8,82);// ID 2 etc...



Re: Get Vehicle ID..... - Fedee! - 20.02.2010

Quote:
Originally Posted by Phento
No.

pawn Код:
AddStaticVehicle(522,-1919.2992,1789.9838,209.3784,50.1049,8,82);// ID 0
AddStaticVehicle(522,-1922.7979,1784.3138,209.3821,51.3585,8,82);// ID 1
AddStaticVehicle(522,-1927.3228,1779.3625,209.3804,53.7146,8,82);// ID 2 etc...
Ohh yea, I forgot about 0

Thanks !


Re: Get Vehicle ID..... - Correlli - 20.02.2010

No, your example is correct:
Quote:
Originally Posted by Fedee!
pawn Код:
AddStaticVehicle(522,-1919.2992,1789.9838,209.3784,50.1049,8,82);//ID 1
AddStaticVehicle(522,-1922.7979,1784.3138,209.3821,51.3585,8,82);//ID 2
AddStaticVehicle(522,-1927.3228,1779.3625,209.3804,53.7146,8,82);//ID 3 etc...
First vehicle is assigned to the ID 1, second to the ID 2 and so on. (GetPlayerVehicleID returns 0 if player isn't in any vehicle)


Re: Get Vehicle ID..... - Fedee! - 20.02.2010

Quote:
Originally Posted by Don Correlli
No, your example is correct:
Quote:
Originally Posted by Fedee!
pawn Код:
AddStaticVehicle(522,-1919.2992,1789.9838,209.3784,50.1049,8,82);//ID 1
AddStaticVehicle(522,-1922.7979,1784.3138,209.3821,51.3585,8,82);//ID 2
AddStaticVehicle(522,-1927.3228,1779.3625,209.3804,53.7146,8,82);//ID 3 etc...
First vehicle is assigned to the ID 1, second to the ID 2 and so on. (GetPlayerVehicleID returns 0 if player isn't in any vehicle)
Oh lol... thank you


Re: Get Vehicle ID..... - smeti - 21.02.2010

Sorry.

test code:
pawn Код:
#include <a_samp>

public OnGameModeInit()
{
    printf("vehicleid: %d",AddStaticVehicle(416,2030.1577,-1435.2174,17.3632,180.0,1,3));
    printf("vehicleid: %d",AddStaticVehicle(416,2020.1577,-1435.2174,17.3632,180.0,1,3));
    printf("vehicleid: %d",AddStaticVehicle(416,2010.1577,-1435.2174,17.3632,180.0,1,3));
    return 1;
}
vehicleid: 1
vehicleid: 2
vehicleid: 3



Re: Get Vehicle ID..... - [LSR]State_Trooper - 21.02.2010

This is a good imple cmd!!

Код:
if(strcmp(cmd, "/carid", true) == 0) {

    if(IsPlayerInAnyVehicle(playerid)) {
		if (IsPlayerConnected(playerid)) {
			format(string, sizeof(string), "(INFO) The ID of this vehicle is: %d.",GetPlayerVehicleID(playerid));
			SendClientMessage(playerid, COLOR_YELLOW, string);
		}
		}

		return 1;
	}