SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 08/06/2010, 05:43 AM   #1
bartje01
High-roller
 
Join Date: Jan 2009
Posts: 1,419
Reputation: 6
Default Help please

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:
Code:
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
bartje01 is offline  
Old 08/06/2010, 02:45 PM   #2
bartje01
High-roller
 
Join Date: Jan 2009
Posts: 1,419
Reputation: 6
Default Re: Help please

anyone?
bartje01 is offline  
Old 08/06/2010, 03:50 PM   #3
Ignas1337
Gangsta
 
Join Date: Jul 2007
Posts: 546
Reputation: 1
Default Re: Help please

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
Ignas1337 is offline  
Old 08/06/2010, 10:57 PM   #4
bartje01
High-roller
 
Join Date: Jan 2009
Posts: 1,419
Reputation: 6
Default Re: Help please

please give an example anyone.
bartje01 is offline  
Old 09/06/2010, 08:40 AM   #5
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,152
Reputation: 3
Default Re: Help please

Here you go:

Code:
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;
}
__________________
DJDhan is offline  
Old 09/06/2010, 10:04 AM   #6
Ignas1337
Gangsta
 
Join Date: Jul 2007
Posts: 546
Reputation: 1
Default Re: Help please

one thing: >= 0? doesn't that include those who aren't SAPD too?
Ignas1337 is offline  
Old 09/06/2010, 10:07 AM   #7
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,152
Reputation: 3
Default Re: Help please

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.
__________________
DJDhan is offline  
Old 09/06/2010, 10:09 AM   #8
Ignas1337
Gangsta
 
Join Date: Jul 2007
Posts: 546
Reputation: 1
Default Re: Help please

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
Ignas1337 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 07:03 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.