Get the vehicleid by the Owner name?
#1

How can I do that??

PHP код:
enum vInfo
{
    
Owner[24],
    
Model,
    
FloatPosX,
    
FloatPosY,
    
FloatPosZ
};
new 
VehicleInfo[MAX_DVEHICLES][vInfo]; 
Reply
#2

Im not sure but try that

Код:
new vehicle;
vehicle = GetPlayerVehicleID(VehicleInfo[vehicleid][Owner]);
Reply
#3

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.
Reply
#4

Yeh sorry..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)