SA-MP Forums Archive
Cuff and Heal commands not working - 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: Cuff and Heal commands not working (/showthread.php?tid=107507)



Cuff and Heal commands not working - Jokel317 - 10.11.2009

Hello all im having trouble getting my cuff command and medic heal commands working wondering what could be wrong with em thanks for looking.

EDIT: Heal command has been fixed now it`s just the cuff one.

Код:
dcmd_cuff(playerid, params[])
{
  #pragma unused params

	new targetid = strval(params); new CurrentState = GetPlayerState(targetid);
	if (!Player[playerid][IsPlayerInGame])
		{
	  SMSpawn; GTFPSpawn; Deny;
		return 1;
		}
	if (strlen(params)==0)
	  {
	  SendClientMessage(playerid, PURPLE, "Usage: /cuff targetid."); Deny;
	  return 1;
	  }
	if (!IsPlayerConnected(targetid))
  	{
	  format(MyString, sizeof(MyString), "%i is not a valid player.", targetid); SendCMP; GameTFP;
	  Deny;
    return 1;
    }
  if (!Coppers(playerid) && !FBI(playerid) && !Army(playerid) && !CIA(playerid))
		{
		format(MyString, sizeof(MyString), "Only the police can hand cuff!."); SendCMG; GameTFP;
		Deny;
	  return 1;
  	}
	if (GetPlayerWantedLevel(playerid) < 3)
    {
	  format(MyString, sizeof(MyString), "Go hassle some real criminals.", playerid); SendCMP; GameTFP;
	  Deny;
	  return 1;
	  }
	if (!NearPlayer(2, playerid, targetid))
  	{
  	PNAME; TNAME; Deny;
    format(MyString, sizeof(MyString), "%s (%i) is too far away.", TargetName, targetid); GameTFP;
	  SendClientMessage(playerid, YELLOW, MyString);
	  return 1;
  	}
  if (CurrentState == PLAYER_STATE_PASSENGER || CurrentState == PLAYER_STATE_DRIVER)
    {
	  format(MyString, sizeof(MyString), "You cannot cuff people in cars.", playerid); SendCMP; GameTFP;
	  Deny;
	  return 1;
	  }
	if (targetid == playerid)
	  {
	  Deny; SendClientMessage(playerid, PURPLE, "You cannot cuff yourself!");
	  GameTextForPlayer(playerid, "You cannot cuff yourself!", 3000, 3);
	  return 1;
  		}
	if (GetPlayerWantedLevel(playerid) > 3 && CurrentState == PLAYER_STATE_ONFOOT)
    {
	  format(MyString, sizeof(MyString), "You have been cuffed.", targetid); SendCMPT; GameTFPT;
	  DenyT; TPC(targetid, 0); Player[targetid][Cuffed] = 1;
	  return 1;
	  }
	return 1;
}



Re: Cuff and Heal commands not working - RoBo - 10.11.2009

I got to the 3rd line before realising you need to read the pawn manual.


Re: Cuff and Heal commands not working - Jokel317 - 10.11.2009

Ive read the pawno manual and other resources over the past year. Some of that stuff I don`t fully understand. I did not originally put that code together im just trying get it to work thanks.


Re: Cuff and Heal commands not working - Sew_Sumi - 11.11.2009

Quote:
Originally Posted by Jokel317
Ive read the pawno manual and other resources over the past year. Some of that stuff I don`t fully understand. I did not originally put that code together im just trying get it to work thanks.
You need to create a cuff command rather than copying someone elses work.

This is over-complicated...


Also, Whats this DenyT and Deny stuff


Example on why to re-do the command...

Код:
	if (!NearPlayer(2, playerid, targetid))
  	{
  	PNAME; TNAME; Deny;
    format(MyString, sizeof(MyString), "%s (%i) is too far away.", TargetName, targetid); GameTFP;
	  SendClientMessage(playerid, YELLOW, MyString);
	  return 1;
  	}
In this section, (I presume) it makes the playername, targetname, and still runs this "Deny"... Yet all it needs is the target name, Not the player who tried to cuff.

Yet all it needs is a...

return 1;

to deny, and client messaqges to actually "say" that it's denied.

Also, NearPlayer should be IsPlayerInRangeOfPoint... Update, and use the new functions.

and I'd also suggest to review what gamemode you are using for this, as it seems "outdated".

What gamemode are you using, I'll make something for you to make a cuff command. (It'll be WAY simple, Not over-complicated like this...)

Also, A simple search of "dcmd_cuff(playerid, params[])" in ****** pointed me to another thread that literally has most of it done already, Even in dcmd...

http://forum.sa-mp.com/index.php?top...8793#msg428793


Re: Cuff and Heal commands not working - Jokel317 - 11.11.2009

This gamemode right here sir is what im using it`s been edited up a bit by me. Id really appreciate the help.

http://forum.sa-mp.com/index.php?topic=121983.0


Re: Cuff and Heal commands not working - Sew_Sumi - 11.11.2009

It's complicated as, and now cos I seen the gamemode, The Deny and all those are making sense now.

Ok, It should work as it is...

If it's not, You should try to...


Try getting it to show the usage by just putting /cuff

Then, Try cuffing a non-existent ID...

Then try cuffing a player with lower than 3 wanted stars...

Then try cuffing a player with 4 or more stars.


Just try to note what happened when you done all this.


On a side note, What was the fix for heal?


Re: Cuff and Heal commands not working - Jokel317 - 11.11.2009

Actually it assigns random health values I adjusted it to 100 health for the random values is all I did. The cuff command returns "go hassle some real criminals" when me or somebody else tries to cuff. From the way I understand that`s only suppose to appear if the suspect is 3 or below wanted stars. It does show the usage /cuff (user id) although.


Re: Cuff and Heal commands not working - Sew_Sumi - 11.11.2009

Have you tried getting someone to six stars and trying then?

The info about the < 3 wanted level is good... It'll be sorted out.


Also, Nice choice of script... It takes a bit to read, But Jeeese... Someone was coding mad...


Re: Cuff and Heal commands not working - Jokel317 - 11.11.2009

Yep it`s been tried the message "go hassle some real criminals" just appears lol. I agree it`s very good first one i actually found fully working and compatible with 0.3a without no serious compile errors. I did have to rework the pickups to inside interiors and all but it`s very fine script. Thank`s appreciate it

EDIT: Just tried cuff my self and ya know what pop`s up "go hassle some real criminals"