Re: Two questions -
Kasichok - 09.02.2019
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 i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(GetPlayerWantedLevel(i) < 1) continue;
count ++;
}
format(str, 20, "%d wanted players", count);
TextDrawSetString(textdraw, str);
Re: Two questions -
Y_Less - 09.02.2019
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(playerid, cmdtext[])
{
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(playerid, NameSlot1, MAX_PLAYER_NAME+1);
}
if(StringSlot == 2)
{
GetPlayerName(playerid, NameSlot2, MAX_PLAYER_NAME+1);
}
if(StringSlot == 3)
{
GetPlayerName(playerid, NameSlot3, MAX_PLAYER_NAME+1);
}
if(StringSlot == 4)
{
GetPlayerName(playerid, NameSlot4, MAX_PLAYER_NAME+1);
}
if(StringSlot == 5)
{
GetPlayerName(playerid, NameSlot5, MAX_PLAYER_NAME+1);
}
if(StringSlot == 6)
{
GetPlayerName(playerid, NameSlot6, MAX_PLAYER_NAME+1);
}
if(StringSlot == 7)
{
GetPlayerName(playerid, NameSlot7, MAX_PLAYER_NAME+1);
}
if(StringSlot == 8)
{
GetPlayerName(playerid, NameSlot8, MAX_PLAYER_NAME+1);
}
if(StringSlot == 9)
{
GetPlayerName(playerid, NameSlot9, MAX_PLAYER_NAME+1);
}
if(StringSlot == 10)
{
GetPlayerName(playerid, NameSlot10, MAX_PLAYER_NAME+1);
}
if(StringSlot == 11)
{
GetPlayerName(playerid, NameSlot11, MAX_PLAYER_NAME+1);
}
if(StringSlot == 12)
{
GetPlayerName(playerid, NameSlot12, MAX_PLAYER_NAME+1);
}
if(StringSlot == 13)
{
GetPlayerName(playerid, NameSlot13, MAX_PLAYER_NAME+1);
}
if(StringSlot == 14)
{
GetPlayerName(playerid, NameSlot14, MAX_PLAYER_NAME+1);
}
if(StringSlot == 15)
{
GetPlayerName(playerid, NameSlot15, MAX_PLAYER_NAME+1);
}
if(StringSlot == 16)
{
GetPlayerName(playerid, NameSlot16, MAX_PLAYER_NAME+1);
}
if(StringSlot == 17)
{
GetPlayerName(playerid, NameSlot17, MAX_PLAYER_NAME+1);
}
if(StringSlot == 18)
{
GetPlayerName(playerid, NameSlot18, MAX_PLAYER_NAME+1);
}
if(StringSlot == 19)
{
GetPlayerName(playerid, NameSlot19, MAX_PLAYER_NAME+1);
}
if(StringSlot == 20)
{
GetPlayerName(playerid, NameSlot20, MAX_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(playerid, DIALOG_WANTEDPLAYERS, DIALOG_STYLE_MSGBOX, "Wanted Players", TwentyNamesString, "Close", "");
return 1;
}
return 0;
}
|
Re: Two questions -
MEGADETHS - 09.02.2019
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.
Re: Two questions -
Y_Less - 09.02.2019
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.
Re: Two questions -
Proxus - 09.02.2019
Quote:
Originally Posted by Kasichok
PHP код:
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(textdraw, str);
|
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.
Re: Two questions -
TokicMajstor - 09.02.2019
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
}
Re: Two questions -
ComDuck - 09.02.2019
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)
Re: Two questions -
Proxus - 09.02.2019
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!
Re: Two questions -
Proxus - 09.02.2019
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);
Re: Two questions -
Kasichok - 10.02.2019
You probably declared it without Text tag
it has to be like this:
PHP код:
new Text:MissionText;
Re: Two questions -
J0sh... - 11.02.2019
Wow, this is the SA-MP forums now. Greatness awaits.
Maybe Kye should really shut this down tbh
Re: Two questions -
Proxus - 11.02.2019
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.