SA-MP Forums Archive
Need 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)
+--- Thread: Need Help (/showthread.php?tid=626215)



Need Help - Disorder - 12.01.2017

Right here is the problem I'll post the script codes below.
When I wanna cuff someone I have to taze them and When they do /handsup i cannot /cuff because it says they are not Restrained.

CUFF CODE:

Код:
 if(strcmp(cmd, "/cuff", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(IsACop(playerid) || IsAnAgent(playerid) || IsASoldier(playerid))
			{
			    tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cuff [Playerid/PartOfName]");
					return 1;
				}
				if(IsPlayerInAnyVehicle(playerid))
				{
					SendClientMessage(playerid, COLOR_GREY, "   Cannot use this while in a Car !");
					return 1;
				}
				giveplayerid = ReturnUser(tmp);
			    if(IsPlayerConnected(giveplayerid))
				{
					if(IsACop(giveplayerid))
					{
						SendClientMessage(playerid, COLOR_GREY, "   You can't Cuff Cops !");
						return 1;
					}
					if(IsASoldier(giveplayerid))
					{
						SendClientMessage(playerid, COLOR_GREY, "   You can't Cuff a DoC Officer !");
						return 1;
					}
					if(PlayerTied[giveplayerid] > 0)
					{
						SendClientMessage(playerid, COLOR_GREY, "   That player is Tied up !");
						return 1;
					}
					if(PlayerCuffed[giveplayerid] > 1)
					{
						SendClientMessage(playerid, COLOR_GREY, "   That player is already Cuffed !");
						return 1;
					}
					if(IsPlayerInAnyVehicle(giveplayerid))
					{
						SendClientMessage(playerid, COLOR_GREY, "   Suspect is in a car, get him out first !");
						return 1;
					}
					if(PlayerCuffed[giveplayerid] == 1)
					{
							if(ProxDetectorS(8.0, playerid, giveplayerid))
							{
							    if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "   You can't Cuff yourself !"); return 1; }
						    	GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						    	GetPlayerName(playerid, sendername, sizeof(sendername));
						    	format(string, sizeof(string), "* You were Cuffed by Officer %s.", sendername);
						    	SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
								if(PlayerInfo[giveplayerid][pMask] == 1)
						    	{
								    format(string, sizeof(string), "* You Cuffed A Stranger.");
							    	SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							    	format(string, sizeof(string), "* %s Hand Cuffs A Stranger, so he wont go anywhere.", PlayerName(playerid));
							    	ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
								}
								else
								{
								    format(string, sizeof(string), "* You Cuffed %s.", giveplayer);
									SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
									format(string, sizeof(string), "* %s Hand Cuffs %s, so he wont go anywhere.", sendername ,giveplayer);
									ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
								}
								GameTextForPlayer(giveplayerid, "~r~Cuffed", 2500, 3);
				    			SetPlayerSpecialAction(giveplayerid, SPECIAL_ACTION_CUFFED);
    							SetPlayerAttachedObject(giveplayerid, 0, 19418, 6, -0.027999, 0.051999, -0.030000, -18.699926, 0.000000, 104.199928, 1.489999, 3.036000, 1.957999);
								PlayerCuffed[giveplayerid] = 2;
								PlayerCuffedTime[giveplayerid] = 300;
							}
							else
							{
						    	SendClientMessage(playerid, COLOR_GREY, "   That player is not near you !");
						    	return 1;
							}
					}
					else
					{
						SendClientMessage(playerid, COLOR_GREY, "   That player needs to be restrained first !");
						return 1;
					}
				}
				else
				{
				   SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
				   return 1;
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "   You are not a member of the LSPD / SASD !");
			}
		}
		return 1;
	}
UNCUFF:
Код:
	if(strcmp(cmd, "/uncuff", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(IsACop(playerid) || IsAnAgent(playerid) || IsASoldier(playerid))
			{
			    tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /uncuff [Playerid/PartOfName]");
					return 1;
				}
				giveplayerid = ReturnUser(tmp);
				if(IsPlayerConnected(giveplayerid))
				{
					if(giveplayerid != INVALID_PLAYER_ID)
					{
					    if(ProxDetectorS(8.0, playerid, giveplayerid))
						{
						    if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "   You can't Uncuff yourself !"); return 1; }
							if(PlayerCuffed[giveplayerid])
							{
							    GetPlayerName(playerid, sendername, sizeof(sendername));
							    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
							    format(string, sizeof(string), "* You were Uncuffed by %s.", sendername);
								SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
								if(PlayerInfo[giveplayerid][pMask] == 1)
						    	{
								    format(string, sizeof(string), "* You uncuffed A Stranger.");
							    	SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							    	format(string, sizeof(string), "* %s has uncuffed A Stranger.", PlayerName(playerid));
							    	ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
								}
								else
								{
								    format(string, sizeof(string), "* You uncuffed %s.", giveplayer);
									SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
									format(string, sizeof(string), "* %s has uncuffed %s.", sendername ,giveplayer);
									ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
								}
								GameTextForPlayer(giveplayerid, "~g~Uncuffed", 2500, 3);
								SetPlayerCuffed(giveplayerid, 0);
								PlayerCuffed[giveplayerid] = 0;
								SetPlayerSpecialAction(giveplayerid,SPECIAL_ACTION_NONE);
								RemovePlayerAttachedObject(giveplayerid, 0);
							    ClearAnimations(giveplayerid);
							}
							else
							{
							    SendClientMessage(playerid, COLOR_GREY, "   That player isn't Cuffed !");
							    return 1;
							}
						}
						else
						{
						    SendClientMessage(playerid, COLOR_GREY, "   That player is not near you !");
						    return 1;
						}
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
				    return 1;
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "   You are not a member of the LSPD / SASD !");
			}
		}
		return 1;
	}
HANDSUP:

Код:
	if(strcmp(cmd,"/handsup", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
			{
	  			SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
				return 1;
			}
			else
			{
		    	SetPlayerSpecialAction(playerid,SPECIAL_ACTION_HANDSUP);
			}
		}
		return 1;
	}



Re: Need Help - darkdrago - 12.01.2017

Код:
if(strcmp(cmd, "/cuff", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(IsACop(playerid) || IsAnAgent(playerid) || IsASoldier(playerid))
			{
			    tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cuff [Playerid/PartOfName]");
					return 1;
				}
				if(IsPlayerInAnyVehicle(playerid))
				{
					SendClientMessage(playerid, COLOR_GREY, "   Cannot use this while in a Car !");
					return 1;
				}
				giveplayerid = ReturnUser(tmp);
			    if(IsPlayerConnected(giveplayerid))
				{
					if(IsACop(giveplayerid))
					{
						SendClientMessage(playerid, COLOR_GREY, "   You can't Cuff Cops !");
						return 1;
					}
					if(IsASoldier(giveplayerid))
					{
						SendClientMessage(playerid, COLOR_GREY, "   You can't Cuff a DoC Officer !");
						return 1;
					}
					if(PlayerTied[giveplayerid] > 0)
					{
						SendClientMessage(playerid, COLOR_GREY, "   That player is Tied up !");
						return 1;
					}
					if(PlayerCuffed[giveplayerid] > 1)
					{
						SendClientMessage(playerid, COLOR_GREY, "   That player is already Cuffed !");
						return 1;
					}
					if(IsPlayerInAnyVehicle(giveplayerid))
					{
						SendClientMessage(playerid, COLOR_GREY, "   Suspect is in a car, get him out first !");
						return 1;
					}
							if(ProxDetectorS(8.0, playerid, giveplayerid))
							{
							    if(giveplayerid == playerid) { SendClientMessage(playerid,COLOR_GREY, "   You can't Cuff yourself !"); return 1; }
if(GetPlayerSpecialAction(giveplayerid) != SPECIAL_ACTION_HANDSUP) return SendClientMessage(playerid,COLOR_GREY,"He doesn't have his hands up");
						    	GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						    	GetPlayerName(playerid, sendername, sizeof(sendername));
						    	format(string, sizeof(string), "* You were Cuffed by Officer %s.", sendername);
						    	SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
								if(PlayerInfo[giveplayerid][pMask] == 1)
						    	{
								    format(string, sizeof(string), "* You Cuffed A Stranger.");
							    	SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							    	format(string, sizeof(string), "* %s Hand Cuffs A Stranger, so he wont go anywhere.", PlayerName(playerid));
							    	ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
								}
								else
								{
								    format(string, sizeof(string), "* You Cuffed %s.", giveplayer);
									SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
									format(string, sizeof(string), "* %s Hand Cuffs %s, so he wont go anywhere.", sendername ,giveplayer);
									ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
								}
								GameTextForPlayer(giveplayerid, "~r~Cuffed", 2500, 3);
				    			SetPlayerSpecialAction(giveplayerid, SPECIAL_ACTION_CUFFED);
    							SetPlayerAttachedObject(giveplayerid, 0, 19418, 6, -0.027999, 0.051999, -0.030000, -18.699926, 0.000000, 104.199928, 1.489999, 3.036000, 1.957999);
								PlayerCuffed[giveplayerid] = 2;
								PlayerCuffedTime[giveplayerid] = 300;
							}
							else
							{
						    	SendClientMessage(playerid, COLOR_GREY, "   That player is not near you !");
						    	return 1;
							}
				}
				else
				{
				   SendClientMessage(playerid, COLOR_GREY, "   That player is Offline !");
				   return 1;
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "   You are not a member of the LSPD / SASD !");
			}
		}
		return 1;
	}
Just checked the handsup with it
Код:
if(GetPlayerSpecialAction(giveplayerid) != SPECIAL_ACTION_HANDSUP) return SendClientMessage(playerid,COLOR_GREY,"He doesn't have his hands up");
And removed the
Код:
 if(PlayerCuffedTime[giveplayerid] == 1)
Since it was the cause of "That player needs to be restrained first !"
He of course wouldn't have a CuffedTime before getting cuffed


Re: Need Help - Disorder - 12.01.2017

Thank you dark, you were a very big help.


Re: Need Help - darkdrago - 12.01.2017

Quote:
Originally Posted by Disorder
ПоÑмотреть Ñообщение
Thank you dark, you were a very big help.
You're welcome, i just wrote what i've done to make u understand it for a next time, i hope it will be so