SA-MP Forums Archive
Need distance help! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need distance help! (/showthread.php?tid=251750)



Need distance help! - Admigo - 28.04.2011

Heey guys
I want to make a kidnap command in area of 5 meter or something. But when i do /kidnap it can kidnap someone in the whole server.
Code:
Code:
dcmd_kidnap(playerid, params[])
{
	new id;
	if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kidnap <playerid>\"");
	else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "[Server] Player not found");
	else
	{
			new vehicleid;
			vehicleid = GetPlayerVehicleID(playerid);
			if(GetPlayerSkin(playerid) == 116)
	    	{
				new Float:x,Float:y,Float:z;
				GetPlayerPos(playerid, x, y, z);
				if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
	        	{
					PutPlayerInVehicle(id,vehicleid,1);
					TogglePlayerControllable(id,0);
					SendClientMessage(id, COLOR_RED, "[Server] You have been kidnapped");
					SendClientMessage(playerid, 0x00FF00AA, "[Server] You kidnapped someone");
				}
				else
				{
			    	SendClientMessage(playerid, COLOR_RED, "[Server] You must be near the player you want to kidnap");
				}
			}
			else { SendClientMessage(playerid, COLOR_RED, "[Server] You are not a kidnapper!"); }
	}
	return 1;
}
Pls help!


Re: Need distance help! - Cameltoe - 28.04.2011

Change
pawn Code:
GetPlayerPos(playerid, x, y, z);
to:
pawn Code:
GetPlayerPos(id, x, y, z);



Re: Need distance help! - Admigo - 28.04.2011

Quote:
Originally Posted by Cameltoe
View Post
Change
pawn Code:
GetPlayerPos(playerid, x, y, z);
to:
pawn Code:
GetPlayerPos(id, x, y, z);
and playerid in if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) ?


Re: Need distance help! - Antonio144 - 28.04.2011

[REMOVED]


Re: Need distance help! - Admigo - 28.04.2011

What removed?


Re: Need distance help! - Cameltoe - 28.04.2011

Quote:
Originally Posted by admigo
View Post
and playerid in if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) ?
Nope.

pawn Code:
GetPlayerPos(id, x, y, z); // get the cordinates of id processed by sscanf
if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) // Check if playerid is within 5 ( feets ? ) of the id processed by sscanf.