MMB to arrest (REP)
#1

I tried to make MMB for cops to arrest, so basically you don't need to write anything just click MMB and they arrest the nearest person.
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) 
{ 
    if(newkeys == KEY_LOOK_BEHIND) 
    { 
    COMMAND_arrest(playerid, (GetClosestPlayerID); 
    return 1; 
    }
But yeah it didn't work, so maybe someone can help me out with this and get it work?

My arrest command:
Код:
COMMAND:arrest(playerid, params[])
{
	new otherID, msg[512];
	if(sscanf(params, "u", otherID))
	{
		Usage(playerid, "arrest <playerid>");
	}
	else
	{
		if(inTied(playerid))
		{
			if(Player[playerid][english])
				Server(playerid, "You can't use this command while tied.");
			else
				Server(playerid, "Kamu tidak bisa menggunakan perintah ini ketika di ikat.");
			return 1;
		}
		
		if(IsPlayerInAnyVehicle(playerid))
		{
			if(Player[playerid][english])
				Server(playerid, "You can't do this command while in vehicle.");
			else
				Server(playerid, "Kamu tidak bisa menggunakan perintah ini ketika di dalam kendaraan.");
			return 1;
		}

		if(IsPlayerInAnyVehicle(otherID))
		{
			if(Player[playerid][english])
				Server(playerid, "That player is in vehicle.");
			else
				Server(playerid, "Player itu sedang di dalam kendaraan.");
			return 1;
		}

		if(inJail(playerid))
		{
			if(Player[playerid][english])
				Server(playerid, "You can't use this command while jailed.");
			else
				Server(playerid, "Kamu tidak bisa menggunakan perintah ini ketika di penjara.");
			return 1;
		}
		
		if(!isLEO(playerid))
		{
			if(Player[playerid][english])
				Server(playerid, "This command only for LEO classes.");
			else
				Server(playerid, "Perintah ini hanya untuk LEO.");
			return 1;
		}
		
		if(isMe(playerid, otherID))
		{
			if(Player[playerid][english])
				Server(playerid, "You can't use this command to yourself.");
			else
				Server(playerid, "Kamu tidak bisa menggunakan perintah ini ke dirimu sendiri.");
			return 1;
		}
		
		if(!isConnected(otherID))
		{
			if(Player[playerid][english])
				Server(playerid, "That player isn't logged in!.");
			else
				Server(playerid, "Player tidak login.");
			return 1;
		}
		
		if(Player[otherID][playerWanted] < 6)
		{
			if(Player[playerid][english])
				Server(playerid, "That player does not have a high enough wanted level.");
			else
				Server(playerid, "Player itu bukan kriminal.");
			return 1;
		}
		
		if(isCuffed(otherID))
		{
			if(GetDistanceBetweenPlayers(playerid, otherID) < 5.0)
			{
				new time, total;
				time = Player[otherID][playerWanted] * 5;
				total = Player[otherID][playerWanted] * 150;
				Player[otherID][jailTime] = time;
				Player[playerid][playerArrest]++;
				switch(Player[playerid][playerArrest])
				{
					case 1:
					{
						if(Player[playerid][english])
							showAchievements(playerid, "Great, it's first time you arrested criminal", 1000);
						else
							showAchievements(playerid, "Hebat, kamu telah menangkap kriminal pertamamu", 1000);
					}
					case 100:
					{
						if(Player[playerid][english])
							showAchievements(playerid, "You're a great cop, you've arrested 100 criminals", 3000);
						else
							showAchievements(playerid, "Kamu polisi hebat, kamu telah menangkap 100 kriminal", 3000);
					}
					case 500:
					{
						if(Player[playerid][english])
							showAchievements(playerid, "Nice, you've arrested 500 criminals", 5000);
						else
							showAchievements(playerid, "Hebat, kamu telah menangkap 500 kriminal", 5000);
					}
					case 1000:
					{
						if(Player[playerid][english])
							showAchievements(playerid, "Good Job General, you've arrested 1000 criminals", 50000);
						else
							showAchievements(playerid, "Habat Jenderal, kamu telah menangkap 1000 kriminal", 50000);
					}
				}
				if(isTazed(otherID))
				{
					tazed(otherID);
				}
				format(msg, sizeof(msg), CHAT_YELLOW"%s"CHAT_WHITE" has been arrested by "CHAT_YELLOW"%s"CHAT_WHITE" for"CHAT_YELLOW" %d"CHAT_WHITE" seconds.", GetName(otherID), GetName(playerid), time);
				foreach(new i :Player)
				{
					Server(i, msg);
				}
				if(Player[playerid][english])
					format(msg, sizeof(msg), CHAT_WHITE"You earnt "CHAT_YELLOW"$%s"CHAT_WHITE" for arresting"CHAT_YELLOW" %s"CHAT_WHITE".", FormatNumber(total), GetName(otherID));
				else
					format(msg, sizeof(msg), CHAT_WHITE"Kamu mendapatkan "CHAT_YELLOW"$%s"CHAT_WHITE" karena menangkap"CHAT_YELLOW" %s"CHAT_WHITE".", FormatNumber(total), GetName(otherID));
				Info(playerid, msg);
				SetPlayerCuffed(otherID, false);
				Player[otherID][cuffed] = false;
				jail(otherID);
				giveXP(playerid, 10);
				giveScore(playerid, 3);
			}
			else
			{
				if(Player[playerid][english])
					Server(playerid, "You're not near that player.");
				else
					Server(playerid, "Kamu tidak dekat dengan player itu.");
			}
		}
		else
		{
			if(Player[playerid][english])
				Server(playerid, "That player is not cuffed.");
			else
				Server(playerid, "Kamu harus memborgol player itu terlebih dahulu.");
		}
	}
	return 1;
}
Ill rep who helps me out.
Reply
#2

What is the bug
Explain : What happened when u click MMB?
Reply
#3

Im just getting errors after compiling if i add this to OnPlayerKeyStateChange
Reply
#4

Anyone?
Reply
#5

You need to get the closest player first, and then convert it to a string, so you can use it in the command.
Also, it's cmd_something, not COMMAND_something.
Reply
#6

Could anyone help me do that? I can't figure it out
Reply
#7

Quote:
Originally Posted by Stinged
Посмотреть сообщение
You need to get the closest player first, and then convert it to a string, so you can use it in the command.
Also, it's cmd_something, not COMMAND_something.
This guy means use something like cmd_arrest:
//Code here
return 1;

As much as i know
Reply
#8

Well yeah, i know that but i can't make it work while clicking MMB..
Reply
#9

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys

    if(
newkeys == KEY_LOOK_BEHIND
    { 
    
cmd_arrest(playerid""); 
    return 
1
    } 
Getting the players range should already be in the command.
Reply
#10

It works yeah, but it tells me now i need to write an ID while pressing it, aswell player needs to be cuffed, i did remove is(Cuffed) But still it asks for it..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)