SA-MP Forums Archive
Lock/Unlock Car from outside - 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: Lock/Unlock Car from outside (/showthread.php?tid=529769)



Lock/Unlock Car from outside - Steve1312 - 03.08.2014

As title says i need function that checks if player is near car.. (searched on forums non of them worked :/) Anyway i realy need this.

And other thing would be how to chek if player is near cars boot? <---Searched this aswell with n working results.


Re: Lock/Unlock Car from outside - IstuntmanI - 03.08.2014

http://pastebin.com/4p3c0wba


Re: Lock/Unlock Car from outside - Steve1312 - 04.08.2014

And how do i use it?I am a bit confused now


Re: Lock/Unlock Car from outside - Stanford - 04.08.2014

The function that was given returns the ID of the closest vehicle within a certain range.
For example this:

pawn Код:
new carid = GetClosestVehicle(playerid, 5.0);



Re: Lock/Unlock Car from outside - Steve1312 - 04.08.2014

What i am doing wrong
Код:
command(vehtest, playerid, params[])
{
	new carid = GetClosestVehicle(playerid, 5.0);
	new Float:cx, Float:cy, Float:cz;
	GetVehiclePos(carid, cz, cy, cz);
	GetPlayerPos
	if(IsPlayerInRangeOfPoint(playerid, 5.0, cx,cy,cz))
	{
		SendClientMessage(playerid, WHITE, "YMessage.");
	}
	return 1;
}



Re: Lock/Unlock Car from outside - Stanford - 04.08.2014

First remove GetPlayerPos.
Second use this:
GetVehiclePos(carid, cx, cy, cz);
Be careful.


Re: Lock/Unlock Car from outside - Steve1312 - 04.08.2014

Getplayerpos wasnt finished.
Anyway still isnt working
Код:
command(vehtest, playerid, params[])
{
	new carid = GetClosestVehicle(playerid, 5.0);
	new Float:cx, Float:cy, Float:cz;
        GetVehiclePos(carid, cx, cy, cz);
	if(IsPlayerInRangeOfPoint(playerid, 5.0, cx,cy,cz))
	{
		SendClientMessage(playerid, WHITE, "Y.");
	}
	return 1;
}



Re: Lock/Unlock Car from outside - IstuntmanI - 04.08.2014

Quote:
Originally Posted by Steve1312
Посмотреть сообщение
Getplayerpos wasnt finished.
Anyway still isnt working
Код:
command(vehtest, playerid, params[])
{
	new carid = GetClosestVehicle(playerid, 5.0);
	new Float:cx, Float:cy, Float:cz;
        GetVehiclePos(carid, cx, cy, cz);
	if(IsPlayerInRangeOfPoint(playerid, 5.0, cx,cy,cz))
	{
		SendClientMessage(playerid, WHITE, "Y.");
	}
	return 1;
}
Are you sure that you are near a vehicle ?
Код:
command(vehtest, playerid, params[])
{
	new carid = GetClosestVehicle(playerid, 5.0),
		Float:cx, Float:cy, Float:cz;

	GetVehiclePos(carid, cx, cy, cz);

	if(carid == INVALID_VEHICLE_ID)
		return SendClientMessage(playerid, WHITE, "You aren't close to any vehicle !");

	if(IsPlayerInRangeOfPoint(playerid, 5.0, cx,cy,cz))
	{
		SendClientMessage(playerid, WHITE, "Y.");
	}
	return 1;
}



Re: Lock/Unlock Car from outside - Steve1312 - 04.08.2014

Jup standing near my car. Spawned another one and still no result.


Re: Lock/Unlock Car from outside - Stanford - 04.08.2014

I don't know the code is alright nothing is wrong in it!..