Help please
#1

hey guys. I made a /wanted command but I also want a /gpi command that shows a list with wanted people.

SO for example:

*/gpi*
Wanted People:
Name
name2
name3


That person also has to be a cop.
This is my wanted command:
Код:
dcmd_wanted(playerid, params[])
{
 if(PlayerInfo[playerid][SAPD] >= 0)
  {
   new tmp[256], tmp2[256], Index;
   tmp = strtok(params,Index),
   tmp2 = strtok(params,Index);
   if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /wanted [playerid] [level]");
   new player1, level, playername[MAX_PLAYER_NAME], string[128];
   player1 = strval(tmp);
   if(!strlen(tmp2)) return SendClientMessage(playerid, red, "USAGE: /wanted [playerid] [level]");
   level = strval(tmp2);
   GetPlayerName(player1,playername,sizeof(playername));

  format(string,sizeof(string),"You have made %s wanted level %d",playername,level);
  SendClientMessage(playerid,red,string);
	SetPlayerWantedLevel(player1,level);
	format(string,sizeof(string),"You are now wanted level %d",level);
	SendClientMessage(player1,red,string);
  }
  else SendClientMessage(playerid,red,"You are not a cop!");

	return 1;
}
Plaese help to make the /gpi
Reply
#2

anyone?
Reply
#3

if by help you expect us to hand out code then by reading my post i will not help you that much.

well first of all you should know how to check if something is true. first of all you should check if the player, using the command, is a cop. Do the check, output some text saying something like: "Wanted:", then create a loop to loop through player ids (0 to max players) (the for loop has the best design for this job) and inside that loop check if a player's wanted level is above 0 and then print out his name and the level using format and sendclientmessage. (if i recall things that well). close the loops, write any additional text if wanted and that is about it.
you can also perform checks for different colors for different wanted levels, if so then do it INSIDE the loop before printing the name. That should do the theory. Take it to practise
Reply
#4

please give an example anyone.
Reply
#5

Here you go:

Код:
dcmd_gpi(playerid, params[])
{
	if(PlayerInfo[playerid][SAPD] > 0)
	{
		
		new playername[256]; new string[128]; 
		SendClientMessage(playerid,red,"WANTED PLAYERS:");
		for(new i=0; i<MAX_PLAYERS;i++)
		{
			
			if(GetPlayerWantedLevel(playerid)>0)
			{
				GetPlayerName(i,playername,sizeof(playername));
				format(string,sizeof(string),"%s Wanted Level: %d",playername,GetPlayerWantedLevel(i));
				SendClientMessage(playerid,red,string);
			}
		}
	}
	else SendClientMessage(playerid,red,"You are not a cop!");
	return 1;
}
Reply
#6

one thing: >= 0? doesn't that include those who aren't SAPD too?
Reply
#7

Quote:
Originally Posted by Izanagi
one thing: >= 0? doesn't that include those who aren't SAPD too?
Pff yea I just forgot to edit that part. I have modified my post.
Reply
#8

well it was that way in the first post so you just used the check the way he did it, and he had done it with error, so... anyway
keep helping them fellows
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)