command without id
#1

i want to make command for my cops and robbers gm but it takes to long to do and id. i want to know how to make a command when the cop tickets the a player all they do is /tk and the wanted player gets a ticket. also if you can tell me how to make numbers like 2 to ticket instead of command
Reply
#2

anyone know?
Reply
#3

Just tell your cops to type faster, since there's no way to check all keys a player can press.

You could do some loops at OnPlayerKeyStateChange, for example if the player presses KEY_SUBMISSION (Whatever it is), that it performs the command.
Reply
#4

r u using if(cmd..... or dcmd_......
Reply
#5

My bad, mis-read it.

pawn Код:
if(!strcmp(cmdtext,"/tk",true))
{
  if(!IsPlayerCop(playerid)) return SendClientMessage(playerid,0x0000ff00,"You aint a cop!");
  new Float:x,Float:y,Float:z;
  GetPlayerPos(playerid,x,y,z);
  for(new i; i < MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i,5,x,y,z) && !IsPlayerCop(i))
    {
       //Ticket code
       return 1;
    }
  }
  return SendClientMessage(playerid,0x00ff00,"You aren't near a player!");
}
Reply
#6

Well you can try /TK check closest player if he wanted and if in range then it gives him ticket
Reply
#7

well this is my command maybe you can fix it or give me a better idea

Код:
if(strcmp(cmd, "/tk", true) == 0)
	{
		if(gTeam[playerid] == TEAM_COPS)
		{
			new id;
			tmp = strtok(cmdtext, idx);
			if(strlen(tmp))
			{
				id = strval(tmp);
				if(IsPlayerConnected(id))
				{
					if(Jailed[id] == false)
					{
						if(GetPlayerWantedLevel(id) >= 1 && GetPlayerWantedLevel(id) <= 3)
 						{
                if(GetDistanceBetweenPlayers(playerid,id) < 15)
					    	{
					    	    if(playerspawned[playerid] == true)
								{
						    	    GetPlayerName(id,sName, MAX_PLAYER_NAME);
									GetPlayerName(playerid,fName, MAX_PLAYER_NAME);
									format(string, sizeof(string), "You have gave a ticket to Suspect %s [%i]",sName,id);
									SendClientMessage(playerid, 0xE4BC1BFF,string);
									format(string, sizeof(string), "Officer %s [%i] have fined you $3000. You have paid the ticket.",fName,playerid);
									SendClientMessage(id, 0xE4BC1BFF,string);
									format(string, sizeof(string), "Suspect %s [%i] has been fined by %s [%i].",sName,id,fName,playerid);
									SendClientMessageToAll(0x80FF00FF,string);
	                                SetPlayerWantedLevel(id, 0);
						    	    GivePlayerMoney(id, -3000);
						    	    GivePlayerMoney(playerid, 3000);
						    	    SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
       						 	}
       						 	else
       						 	{
      						 		SendClientMessage(playerid, 0xFF0000AA, "You are dead, you cannot arrest a suspect.");
       						 	}
							}
                        	else
							{
								SendClientMessage(playerid, 0xFF0000AA, "Player is not close enough to ticket!");
							}
						}
						else
						{
							SendClientMessage(playerid, 0xFF0000AA, "Player is not ticketable!");
						}
					}
					else
					{
    					SendClientMessage(playerid, 0xFF0000AA, "This player is in jail, you cannot ticket him.");
					}
				}
				else
				{
					SendClientMessage(playerid, RED, "Player Not Found.");
				}
			}
			else
			{
				SendClientMessage(playerid, 0xFF0000AA, "USAGE: /tk [id]");
			}
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "Only Law enforcement agents can use this command!");
		}
		return 1;
	}
Reply
#8

Try this out:

Код:
if(!strcmp(cmdtext, "/tk", true))
{
	if(gTeam[playerid] != TEAM_COPS) return SendClientMessage(playerid, 0xFF0000AA, "Only Law enforcement agents can use this command!");
	if(playerspawned[playerid] == false) return SendClientMessage(playerid, 0xFF0000AA, "You are dead, you cannot arrest a suspect.");	

	for(new id=0;id<GetMaxPlayers();id++)
	{
		if(Jailed[id] == true) continue;
	
		if(GetPlayerWantedLevel(id) < 1 && GetPlayerWantedLevel(id) > 3) continue;
		
		if(GetDistanceBetweenPlayers(playerid,id) > 15) continue;
			
		GetPlayerName(id,sName, MAX_PLAYER_NAME);
		GetPlayerName(playerid,fName, MAX_PLAYER_NAME);
		format(string, sizeof(string), "You have gave a ticket to Suspect %s [%i]",sName,id);
		SendClientMessage(playerid, 0xE4BC1BFF,string);
		format(string, sizeof(string), "Officer %s [%i] have fined you $3000. You have paid the ticket.",fName,playerid);
		SendClientMessage(id, 0xE4BC1BFF,string);
		format(string, sizeof(string), "Suspect %s [%i] has been fined by %s [%i].",sName,id,fName,playerid);
		SendClientMessageToAll(0x80FF00FF,string);
		SetPlayerWantedLevel(id, 0);
		GivePlayerMoney(id, -3000);
		GivePlayerMoney(playerid, 3000);
		SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
	}

	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)