SA-MP Forums Archive
Problem with /drag command - 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: Problem with /drag command (/showthread.php?tid=486213)



Problem with /drag command - AustinWeerdGuy - 07.01.2014

Hello guys.

I have a problem with my /drag command for LEOs.

Here is the code:

Код:
CMD:drag(playerid, params[])
{
	if(IsACop(playerid))
	{
		new string[128], giveplayerid;
		if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(GetPVarInt(giveplayerid, "PlayerCuffed") == 2)
			{
				if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");
				if(GetPVarInt(giveplayerid, "BeingDragged") == 1)
				{
					SendClientMessageEx(playerid, COLOR_WHITE, " That player is already being dragged. ");
					return 1;
				}
                new Float:dX, Float:dY, Float:dZ;
				GetPlayerPos(giveplayerid, dX, dY, dZ);
				if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ))
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, " That suspect is not near you.");
					return 1;
				}
				format(string, sizeof(string), "* %s has is now dragging you.", GetPlayerNameEx(playerid));
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				format(string, sizeof(string), "* You are now dragging %s, you may move them now.", GetPlayerNameEx(giveplayerid));
				SendClientMessageEx(playerid, COLOR_WHITE, string);
				format(string, sizeof(string), "* %s grabs ahold of %s and begins to move them.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessageEx(playerid, COLOR_WHITE, "You are now dragging the suspect, press the '{AA3333}FIRE{FFFFFF}' button to stop.");
				SetPVarInt(giveplayerid, "BeingDragged", playerid);
				SetPVarInt(playerid, "DraggingPlayer", 1);
			}
			else
			{
				SendClientMessageEx(playerid, COLOR_WHITE, " The specified player is not cuffed !");
			}
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GREY, "   You are not a LEO ! ");
		return 1;
	}
	return 0;
}
And this is the problem. First I cuff them and all. Then I type in /drag [ID] after that it says "Click on the FIRE button to move him".

So I move and click on the FIRE button. But nothing happens. Can someone tell me the wrong with the code?

Kind Regards,
Austin


Re: Problem with /drag command - Abagail - 07.01.2014

Do you have something in OnPlayerKeyPress? You have to tell the game-mode you want to stop dragging them when you press the FIRE Button. If you already do, then show us the code. Also I noticed a little typo, where it says "has is" should be "is".