Problem with vehicle
#1

Hello, I have a problem with vehicle locking. When I try to lock vehicle inside, vehicle locks perfect, but when i try to lock outside it do not lock. Code:
Код:
COMMAND:lock(playerid,params[])
{
	if(IsPlayerInAnyVehicle(playerid))
	{
	    new const vehicleid = GetPlayerVehicleID(playerid);
	    if(PlayerInfo[playerid][Keys] != VehicleInfo[vehicleid][VehicleID])
	    {
		    if(VehicleInfo[vehicleid][OwnerID] != playerid || VehicleInfo[vehicleid][VehicleID] == -1)
				return ErrorMsg(playerid,"This vehicle is not yours.");
		}
		else
		{
		    if(VehicleInfo[vehicleid][VehicleID] == -1) return ErrorMsg(playerid,"This vehicle is not yours.");
		}
		if(!VehicleInfo[vehicleid][Locked])
		{
		    VehicleInfo[vehicleid][Locked] = true;
		    VehicleTurn(vehicleid,DOORS);
		    SuccessMsg(playerid,"Vehicle locked.");
		    PlayerAction(playerid,"lock vehicle");
		}
		else
		{
		    VehicleInfo[vehicleid][Locked] = false;
		    VehicleOff(vehicleid,DOORS);
		    SuccessMsg(playerid,"Vehicle unlocked.");
		    PlayerAction(playerid,"unlock vehicle");
		}
	}
	else
	{
	    new vehicleid = -1,Float:tPoz[3];
	    for(new i=0;i<MAX_VEHICLES;i++)
	    {
	        if(VehicleInfo[i][VehicleID] != -1)
	        {
				GetVehiclePos(i,tPoz[0],tPoz[1],tPoz[2]);
				if(IsPlayerInRangeOfPoint(playerid,3.0,tPoz[0],tPoz[1],tPoz[2])) vehicleid = i;
	        }
	    }
	    if(vehicleid == -1) return ErrorMsg(playerid,"Vehicle is too far.");
	    else if(VehicleInfo[vehicleid][OwnerID] != playerid && PlayerInfo[playerid][Keys] != VehicleInfo[vehicleid][VehicleID])
		{
			ErrorMsg(playerid,"This vehicle is not yours.");
			return 1;
		}
		if(!VehicleInfo[vehicleid][Locked])
		{
		    VehicleInfo[vehicleid][Locked] = true;
		    VehicleTurn(vehicleid,DOORS);
		    SuccessMsg(playerid,"Vehicle locked");
		    PlayerAction(playerid,"lock vehicle");
		}
		else
		{
		    VehicleInfo[vehicleid][Locked] = false;
		    VehicleOff(vehicleid,DOORS);
		    SuccessMsg(playerid,"Vehicle unlocked");
		    PlayerAction(playerid,"unlock vehicle");
		}
		ApplyAnimation(playerid,"GANGS","DEALER_DEAL",4.000000,0,0,0,0,-1);
	}
	return 1;
}
Reply
#2

Bump..
Reply
#3

UPP.
Reply
#4

Anyone?
Reply
#5

Do you get the message "Vehicle is too far."?
Reply
#6

Quote:
Originally Posted by MattyG
Посмотреть сообщение
Do you get the message "Vehicle is too far."?
When I am near to vehicle no.
Reply
#7

Debug it to make sure. Print the vehicle ID and use /dl in-game. Does it match with the one it is displayed by /dl?
Reply
#8

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Debug it to make sure. Print the vehicle ID and use /dl in-game. Does it match with the one it is displayed by /dl?
No it doesn't matches. What can I do?
Reply
#9

pawn Код:
stock GetClosestVehicle(playerid, Float: fRadius) // by RyDeR`
{
    new
        iClosestID = INVALID_VEHICLE_ID,
        Float: fFinalDistance,
        Float: fDistance,
        Float: fX,
        Float: fY,
        Float: fZ;
    GetPlayerPos(playerid, fX, fY, fZ);
    fFinalDistance = fRadius;

    for(new i; i != MAX_VEHICLES; i++)
    {
        if((fDistance = GetVehicleDistanceFromPoint(i, fX, fY, fZ)) < fFinalDistance)
        {
            fFinalDistance = fDistance;
            iClosestID = i;
        }
    }
    return iClosestID;
}
Reply
#10

Doesn't work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)