19.07.2010, 12:42
Hello people,
currently I`m updating our vehicle system, and I need function from the title. Currently I have:
But sometimes it gives error in this function, it sends message "ERROR"
How should I change the function GetPlayerClosestOwnedVehicle, so it would work as it should?
Thanks in advance
currently I`m updating our vehicle system, and I need function from the title. Currently I have:
pawn Код:
stock GetClosestOwnedVehicleID( playerid )
{
new
vehid = MAX_VEHICLES;
for ( new i = 0; i < MAX_OWNABLE_VEHICLES; i++ )
{
if ( VehInfo [ playerid ][ i ][ vSpawned ] )
{
for ( new v = 0; v < MAX_VEHICLES; v++ )
{
if ( SVehInfo [ v ][ vDBID ] == VehInfo [ playerid ][ i ][ vDBID ] )
{
if ( CheckPlayerDistanceToVehicle( 10.0, playerid, v ) )
{
id = v;
}
}
}
}
}
return id;
}
pawn Код:
else if ( !strcmp( result, "lock", true ) )
{
new
id = GetClosestOwnedVehicleID( playerid );
if ( id == MAX_VEHICLES )
return SendClientMessage ( playerid, COLOR_GREY, " You don`t have spawned vehicle, our you are too far away from her." );
new
slot = GetSlotOfCarID( playerid, id );
if ( slot < MAX_OWNABLE_VEHICLES )
{
if ( id < MAX_VEHICLES )
{
if ( CheckPlayerDistanceToVehicle( 5.0, playerid, id ) )
{
if ( VehInfo[ playerid ][ slot ][ vLock ] < 1 )
return SendClientMessage( playerid, COLOR_GREY, " You don`t have lock." );
if ( SVehInfo[ id ][ vLock ] > 0 )
{ // Transporto priemonл yra uюrakinta
SVehInfo[ id ][ vLock ] = 0;
LockVehicleForPlayers( id, false );
ShowInfoText ( playerid, "~g~Vehicle unlocked", 3000 );
}
else
{ // Transporto priemonл yra atrakinta
SVehInfo[ id ][ vLock ] = VehInfo[ playerid ][ slot ][ vLock ];
LockVehicleForPlayers( id, true );
ShowInfoText ( playerid, "~r~Vehicle locked", 3000 );
}
}
else
SendClientMessage( playerid, COLOR_GREY, " You are not near your vehicle" );
}
else
SendClientMessage( playerid, COLOR_RED, "ERROR" );
}
else
SendClientMessage( playerid, COLOR_GREY, " You don`t have spawned vehicle." );
}
Thanks in advance