Get the vehicleid by the Owner name? - 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: Get the vehicleid by the Owner name? (
/showthread.php?tid=455101)
Get the vehicleid by the Owner name? -
Magic_Time - 31.07.2013
How can I do that??
PHP код:
enum vInfo
{
Owner[24],
Model,
Float: PosX,
Float: PosY,
Float: PosZ
};
new VehicleInfo[MAX_DVEHICLES][vInfo];
Re: Get the vehicleid by the Owner name? -
dEcooR - 31.07.2013
Im not sure but try that
Код:
new vehicle;
vehicle = GetPlayerVehicleID(VehicleInfo[vehicleid][Owner]);
Re: Get the vehicleid by the Owner name? -
Konstantinos - 31.07.2013
You insert the playerid as a parameter, it takes player's name and it loops through the vehicles. If the vehicle exists, it checks if the player's name is the same with the owner's name. If it matches, it returns the vehicleid. If not, it returns INVALID_VEHICLE_ID.
pawn Код:
native IsValidVehicle( vehicleid );
stock GetVehicleIDFromOwner( playerid )
{
new
name[ MAX_PLAYER_NAME ]
;
GetPlayerName( playerid, name, MAX_PLAYER_NAME );
for( new v = 0; v < MAX_VEHICLES; v++ )
{
if( IsValidVehicle( v ) )
{
if( !strcmp( VehicleInfo[ v ][ Owner ], name, true, MAX_PLAYER_NAME ) )
{
return v;
}
}
}
return INVALID_VEHICLE_ID;
}
Quote:
Originally Posted by dEcooR
Im not sure but try that
Код:
new vehicle;
vehicle = GetPlayerVehicleID(VehicleInfo[vehicleid][Owner]);
|
Check what type this functions should have please. It needs an integer and you're using a string.
Re: Get the vehicleid by the Owner name? -
dEcooR - 31.07.2013
Yeh sorry..