Making a command to lock/unlock the owners car in a radius.
#1

Hey all,

I'm trying to make a command that will allow the user to lock/unlock their vehicle within a small radius of the car they own but i'm having trouble getting the radius to work, the player can lock/unlock their vehicle when they are sat inside it, but not outside, here's the code I have right now:

Код:
command(lock, playerid, params[])
{
	new Float:cX, Float:cY, Float:cZ;
	new vehicleid = GetPlayerVehicleID(playerid);
	GetVehiclePos(vehicleid, cX, cY, cZ);
	new string[128];
	new engine,lights,alarm,doors,bonnet,boot,objective;
	GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
	if(IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
    {
        if(doors == 1)
        {
            doors = 1;
            SetVehicleParamsEx(vehicleid,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
            format(string, sizeof(string), "{9d21ad}* %s unlocks the vehicle.", GetName(playerid));
            NearByMessage(playerid, NICESKY, string);
            return 1;
        }
        else
        {
            doors = 0;
	        SetVehicleParamsEx(vehicleid,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
	        format(string, sizeof(string), "{9d21ad}* %s locks the vehicle.", GetName(playerid));
	        NearByMessage(playerid, NICESKY, string);
	        return 1;
        }
    }
	else if(!IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
		{
		    SendClientMessage(playerid, WHITE, "You are not near a vehicle!");
		    return 1;
		}
	return doors;
}
Any help with this would be greatly appreciated!
Reply


Messages In This Thread
Making a command to lock/unlock the owners car in a radius. - by TryHardSnipr - 30.10.2014, 21:56
Re: Making a command to lock/unlock the owners car in a radius. - by dominik523 - 30.10.2014, 22:22
Re: Making a command to lock/unlock the owners car in a radius. - by TryHardSnipr - 30.10.2014, 22:25
Re: Making a command to lock/unlock the owners car in a radius. - by TryHardSnipr - 31.10.2014, 09:31

Forum Jump:


Users browsing this thread: 1 Guest(s)