Arrest cmd.Help... +1 rep
#1

Hi all,i want to make a cops and robbers server.But i have stuck /arrest command.I dont know how to make it.For example when someone is at lspd team and its near to a suspect then he can use command /ar [player id] for arrest him.How i can make it?


Thanks for helping
Reply
#2

Alright, read this list and think about how to do it:


1. Check if the players is LSPD
2. Check if the player is near the other player
3. Set the position of the arrested player.
4. Set a timer to unjail him
Reply
#3

yea,but how i can ID for example,/arrest ID?
Reply
#4

Use ZCMD/DCMD/YCMD (command processor) and sscanf to split the params.

@ n00b_scripter: That won't even work, lol.
Reply
#5

Код:
COMMAND:arrest(playerid, params[])
{
	if(PlayerInfo[playerid][pCop] == 1)
	{
		new targetid;
		if(!sscanf(params, "u", targetid))
		{
		    if(PlayerInfo[targetid][pWanted] >= 1)
		    {
		        new Float:targetX, Float:targetY, Float:targetZ;
		        GetPlayerPos(targetid, targetX, targetY, targetZ);
				if(IsPlayerInRangeOfPoint(playerid, 5, targetX, targetY, targetZ))
				{
				    if(PlayerInfo[targetid][pCuffed] == 1)
				    {
				        if(IsPlayerInRangeOfPoint(playerid, 5, //the pos for the LSPD garage or whatever...))
				        {
				            SetPlayerPos(targetid, //pos for the jail);
				            //OPTIONAL: SetPlayerColor(targetid, colorForJailedPeople);
				            PlayerInfo[targetid][pJailed] = 1;
				        }
				    }
				}
		    }
		}
	}
	return 1;
}
NOTE: for this, you need to learn about Enums, and set an enum for pCuffed, pJailed, pCop...
Good luck!
Also, you need ZCMD, and SSCANF2.
Reply
#6

My command:

Код:
CMD:arrest(playerid, params[])
{
	if(PlayerInfo[playerid][Fmember] == 1)
	{
		new toplayer;
		new jailtime;
		new price;
		if(!sscanf(params, "uii", toplayer, jailtime, price))
		{
			    if((jailtime >= 1 && jailtime <= 10))
			    {
					if(IsPlayerInRangeOfPoint(toplayer, 20.0, 221.9771, 121.3747, 999.0156))
					{
						if(IsPlayerInRangeOfPoint(playerid, 20.0, 221.9771, 121.3747, 999.0156))
						{
								new string[128];
								new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
								GetPlayerName(playerid, name, sizeof(name));
								GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
								format(string, sizeof(string), "You are jailed for %d days by %s!", jailtime * 60000, name);
								SCM(toplayer, COLOR_BLUE, string);
								SetPlayerPos(toplayer, 219.3402, 110.0057, 999.0156);
								SetPlayerInterior(toplayer, 10);
								ResetPlayerWeapons(toplayer);
								jailed[toplayer] = 1;
           	        	  	    SetTimerEx("unjail", jailtime * 60000, false, "i", toplayer);
           	        	  	    GivePlayerCash(toplayer, -price);
           	        	  	   	PlayerInfo[toplayer][Suspect] = sus_no;
								SetPlayerColor(toplayer, COLOR_WHITE);
						}
				 		else return SendClientMessage(playerid, 0x2641FEAA, "You are not near the jail!");
					}
					else return SendClientMessage(playerid, 0x2641FEAA, "No suspect near the jail!");
				}
				else return SendClientMessage(playerid, 0x2641FEAA, "Jailtime cant be shorter then 1 or longer then 10");
		}
		else return SendClientMessage(playerid, 0x2641FEAA, "USAGE: /arrest [Playername] [JailTime] [price]");
	}
	else return SendClientMessage(playerid, 0x2641FEAA, "You are not a cop!");
	return 1;
}
Reply
#7

Quote:
Originally Posted by milanosie
Посмотреть сообщение
My command:

Код:
CMD:arrest(playerid, params[])
{
	if(PlayerInfo[playerid][Fmember] == 1)
	{
		new toplayer;
		new jailtime;
		new price;
		if(!sscanf(params, "uii", toplayer, jailtime, price))
		{
			    if((jailtime >= 1 && jailtime <= 10))
			    {
					if(IsPlayerInRangeOfPoint(toplayer, 20.0, 221.9771, 121.3747, 999.0156))
					{
						if(IsPlayerInRangeOfPoint(playerid, 20.0, 221.9771, 121.3747, 999.0156))
						{
								new string[128];
								new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
								GetPlayerName(playerid, name, sizeof(name));
								GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
								format(string, sizeof(string), "You are jailed for %d days by %s!", jailtime * 60000, name);
								SCM(toplayer, COLOR_BLUE, string);
								SetPlayerPos(toplayer, 219.3402, 110.0057, 999.0156);
								SetPlayerInterior(toplayer, 10);
								ResetPlayerWeapons(toplayer);
								jailed[toplayer] = 1;
           	        	  	    SetTimerEx("unjail", jailtime * 60000, false, "i", toplayer);
           	        	  	    GivePlayerCash(toplayer, -price);
           	        	  	   	PlayerInfo[toplayer][Suspect] = sus_no;
								SetPlayerColor(toplayer, COLOR_WHITE);
						}
				 		else return SendClientMessage(playerid, 0x2641FEAA, "You are not near the jail!");
					}
					else return SendClientMessage(playerid, 0x2641FEAA, "No suspect near the jail!");
				}
				else return SendClientMessage(playerid, 0x2641FEAA, "Jailtime cant be shorter then 1 or longer then 10");
		}
		else return SendClientMessage(playerid, 0x2641FEAA, "USAGE: /arrest [Playername] [JailTime] [price]");
	}
	else return SendClientMessage(playerid, 0x2641FEAA, "You are not a cop!");
	return 1;
}
Ah, I forgot to add a timer and bail price, my bad, good job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)