Two questions
#21

Quote:
Originally Posted by Proxus
Посмотреть сообщение
Thanks but that wasn't what I was asking. I wanted to get the amount of wanted players and then change this 0 to the amount of wanted players. If there are 4 people with a wanted level, it will show 4. If there is 1 person with a wanted level, it would show 1, etc, etc.
https://imgur.com/a/40WnVL4 - image

Edit: Realised you might be talking about the other question or to someone else. Not sure though.
PHP код:
new str[20], count 0;
for(new 
0GetPlayerPoolSize(); <= ji++)
{
    if(
GetPlayerWantedLevel(i) < 1) continue;
    
count ++;
}
format(str20"%d wanted players"count);
TextDrawSetString(textdrawstr); 
Reply
#22

Quote:
Originally Posted by Bolex_
Посмотреть сообщение
'Faster and Easier' ?

Take a knife and stab yourself, something like this isn't even for a half-star.
Quote:
Originally Posted by Dayrion
Посмотреть сообщение
And the way you answered him is worse than everything. Moderate your language, please.
Worse than most things? Maybe. Worse than everything? Absolutely not - I can show you at least one thing that is worse than their reply:

Quote:
Originally Posted by MEGADETHS
Посмотреть сообщение
There is probably a faster and easier way but this works.

This will show 20 playernames with wanted level lowest playerID ontop.

PHP код:

#define DIALOG_WANTEDPLAYERS 1
public OnPlayerCommandText(playeridcmdtext[])
{
if(!
strcmp(cmdtext"/wantedplayers"true))
{
new 
TotalWantedPlayers 0;
new 
PlayerCheck 0;
new 
StringSlot 1;
new 
NameSlot1[64];
new 
NameSlot2[64];
new 
NameSlot3[64];
new 
NameSlot4[64];
new 
NameSlot5[64];
new 
NameSlot6[64];
new 
NameSlot7[64];
new 
NameSlot8[64];
new 
NameSlot9[64];
new 
NameSlot10[64];
new 
NameSlot11[64];
new 
NameSlot12[64];
new 
NameSlot13[64];
new 
NameSlot14[64];
new 
NameSlot15[64];
new 
NameSlot16[64];
new 
NameSlot17[64];
new 
NameSlot18[64];
new 
NameSlot19[64];
new 
NameSlot20[64];
while(
PlayerCheck<MAX_PLAYERS && StringSlot 21)
{
if(
GetPlayerWantedLevel(PlayerCheck) > 0)
{
if(
StringSlot == 1)
{
GetPlayerName(playeridNameSlot1MAX_PLAYER_NAME+1);
}
if(
StringSlot == 2)
{
GetPlayerName(playeridNameSlot2MAX_PLAYER_NAME+1);
}
if(
StringSlot == 3)
{
GetPlayerName(playeridNameSlot3MAX_PLAYER_NAME+1);
}
if(
StringSlot == 4)
{
GetPlayerName(playeridNameSlot4MAX_PLAYER_NAME+1);
}
if(
StringSlot == 5)
{
GetPlayerName(playeridNameSlot5MAX_PLAYER_NAME+1);
}
if(
StringSlot == 6)
{
GetPlayerName(playeridNameSlot6MAX_PLAYER_NAME+1);
}
if(
StringSlot == 7)
{
GetPlayerName(playeridNameSlot7MAX_PLAYER_NAME+1);
}
if(
StringSlot == 8)
{
GetPlayerName(playeridNameSlot8MAX_PLAYER_NAME+1);
}
if(
StringSlot == 9)
{
GetPlayerName(playeridNameSlot9MAX_PLAYER_NAME+1);
}
if(
StringSlot == 10)
{
GetPlayerName(playeridNameSlot10MAX_PLAYER_NAME+1);
}
if(
StringSlot == 11)
{
GetPlayerName(playeridNameSlot11MAX_PLAYER_NAME+1);
}
if(
StringSlot == 12)
{
GetPlayerName(playeridNameSlot12MAX_PLAYER_NAME+1);
}
if(
StringSlot == 13)
{
GetPlayerName(playeridNameSlot13MAX_PLAYER_NAME+1);
}
if(
StringSlot == 14)
{
GetPlayerName(playeridNameSlot14MAX_PLAYER_NAME+1);
}
if(
StringSlot == 15)
{
GetPlayerName(playeridNameSlot15MAX_PLAYER_NAME+1);
}
if(
StringSlot == 16)
{
GetPlayerName(playeridNameSlot16MAX_PLAYER_NAME+1);
}
if(
StringSlot == 17)
{
GetPlayerName(playeridNameSlot17MAX_PLAYER_NAME+1);
}
if(
StringSlot == 18)
{
GetPlayerName(playeridNameSlot18MAX_PLAYER_NAME+1);
}
if(
StringSlot == 19)
{
GetPlayerName(playeridNameSlot19MAX_PLAYER_NAME+1);
}
if(
StringSlot == 20)
{
GetPlayerName(playeridNameSlot20MAX_PLAYER_NAME+1);
}
StringSlot StringSlot+1;
TotalWantedPlayers TotalWantedPlayers+1;
}
PlayerCheck PlayerCheck+1;
}
new 
string[256];
format(string,sizeof(string),"Total wanted players: %d"TotalWantedPlayers);
SendClientMessage(playerid,-1,string);
new 
TwentyNamesString[1280];
format(TwentyNamesString,sizeof TwentyNamesString,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",NameSlot1,NameSlot2,NameSlot3,NameSlot4,NameSlot5,NameSlot6,NameSlot7,NameSlot8,NameSlot9,NameSlot10,NameSlot11,NameSlot12,NameSlot13,NameSlot14,NameSlot15,NameSlot16,NameSlot17,NameSlot18,NameSlot19,NameSlot20);
ShowPlayerDialog(playeridDIALOG_WANTEDPLAYERSDIALOG_STYLE_MSGBOX"Wanted Players"TwentyNamesString"Close""");
return 
1;
}
return 
0;

Reply
#23

Quote:
Originally Posted by Y_Less
Посмотреть сообщение
Worse than most things? Maybe. Worse than everything? Absolutely not - I can show you at least one thing that is worse than their reply:
I get it, you're all NASA programmers, stop bragging about it. I also didn't know flaming was encouraged on this forum, especially by a beta tester, nice one.
Reply
#24

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Because his code is bad, we must encourage him to commit suicide? That's nice from a forum moderator/beta tester and also, as an humain being.
I didn't say they should commit suicide, and neither did the original post. I even acknowledged that the post was bad, just pointed out that your assertion that it was the worst thing ever was wrong:

Quote:
Originally Posted by Y_Less
Посмотреть сообщение
Worse than most things? Maybe. Worse than everything? Absolutely not
There are many worse things, of which I merely gave one example. Feel free to (silently) come up with your own list.

In the future, read more carefully. And if you feel a post violates the rules, report it, don't take it on yourself to moderate.
Reply
#25

Quote:
Originally Posted by Kasichok
Посмотреть сообщение
PHP код:
new str[20], count 0;
for(new 
0GetPlayerPoolSize(); <= ji++)
{
    if(
GetPlayerWantedLevel(i) < 1) continue;
    
count ++;
}
format(str20"%d wanted players"count);
TextDrawSetString(textdrawstr); 
I assume this works but where can I put it in the code? I've tried multiple places but I can't seem to find a place to fit the code in.
Reply
#26

Maaan what the frick this is one easy thing but people are talking about it more than 3 days and one suggestion: use foreach include it is easy with it. Just foreach(Player, i)
{ If(wanted(playerid) > 0)
//Show that player where you want
}
Reply
#27

Quote:
Originally Posted by Proxus
Посмотреть сообщение
I assume this works but where can I put it in the code? I've tried multiple places but I can't seem to find a place to fit the code in.
1. Dump it in OnPlayerUpdate (if you're lazy and inefficient).

2. Store the wanted level code under a function, and use a repeating SetTimer under OnGameModeInit (or wherever you like that WILL get called early on during script initialization) that calls the function every x seconds. Don't forget to kill the timer once the player disconnects though. (much better)
Reply
#28

Quote:
Originally Posted by ComDuck
Посмотреть сообщение
1. Dump it in OnPlayerUpdate (if you're lazy and inefficient).

2. Store the wanted level code under a function, and use a repeating SetTimer under OnGameModeInit (or wherever you like that WILL get called early on during script initialization) that calls the function every x seconds. Don't forget to kill the timer once the player disconnects though. (much better)
Number 1 sounds like me but I'm going to do 2 (obviously). Thanks for your help again!
Reply
#29

The code now has a warning: warning 213: tag mismatch

Код:
forward CheckAmountOfWanted();

public CheckAmountOfWanted()
{
	new str[20], count = 0;
	for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
	{
    	if(GetPlayerWantedLevel(i) < 1) continue;
    	count ++;
	}
	format(str, 20, "%d wanted players", count);
	TextDrawSetString(MissionText, str); <-- this line (this isn't in the code, just this is the line where the error is)
}
Also, do I need to make the timer for the playerid or just SetTimer("CheckAmountOfWanted", 1000, true);
Reply
#30

You probably declared it without Text tag

it has to be like this:

PHP код:
new Text:MissionText
Reply
#31

Wow, this is the SA-MP forums now. Greatness awaits.
Maybe Kye should really shut this down tbh
Reply
#32

Hey, I managed to fix the amount of wanted players tag mismatch, it was my bad. Thanks for your help.
Has anyone found an efficient way of putting the wanted players into a list dialog? It seems like there has been quite a bit of a debate on it and I'm not sure which one is the best.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)