Need someone to explain me
#1

Hey there people!

So I'm adding something to a DM script and I'm kind of stuck,I need some help.
Well the thing I'm trying to do is getting the player's position in the server,by the amount of kills.
This is what I have under OnPlayerDeath:
pawn Код:
pInfo[killerid][Kills]++;
    pInfo[playerid][Deaths]++; // Doesn't matter at the moment
Well firstly I need to know a way to get how much players are connected,and then getting the position of the player by the amount of his kills.

Any help appreciated.
Reply
#2

So you want to know who has got the most kills in a list with from high to low or something?

pawn Код:
new Pname[24];
for(new i; i<MAX_PLAYERS; i++)
{
   GetPlayerName(i, Pname, 24);
   if(pInfo[i][Kills] >= otherones)....
}
Lol, I started with something but I don't know... sorry
Reply
#3

Quote:
Originally Posted by CAR
Посмотреть сообщение
So you want to know who has got the most kills in a list with from high to low or something?

pawn Код:
new Pname[24];
for(new i; i<MAX_PLAYERS; i++)
{
   GetPlayerName(i, Pname, 24);
   if(pInfo[i][Kills] >= otherones)....
}
Lol, I started with something but I don't know... sorry
So you don't know? xD..

Anyway no,what I meant is,I have three textdraws at the bottom of the screen,Kills,Deaths,and Position.

The position should be something like: PositionFromKills out of Number of Players,and should look like:
(if for example there are 7 players on the server)

3/7

Hope you got it now
Reply
#4

All right but I don't know how to get the position of the playerid by all that stuff, maybe by kills...
pawn Код:
//top
new Position[MAX_PLAYERS];
new Text:Textdraw[MAX_PLAYERS];

//onplayerupdate or something
for(new i; i<MAX_PLAYERS; i++)
{
   if(pInfo[playerid][Kills] < playerid[i][Kills]) return Position[playerid]++;
}
TextdrawDestroy(Textdraw[playerid]);
Textdraw[playerid] = TextDrawCreate(100,100, Position[playerid]);
TextDrawShowForPlayer(Textdraw[playerid]);
Hope you got a little idea oh and OnPlayerConnect, you must set Position[playerid] = 1; because you get position 0 if you are first :P
Reply
#5

Wait I don't get what you've given me,what is this code doing?
And what is GetPlayerName for? o.O
Reply
#6

Oh I remove GetPlayerName, but the function is looking for someone who has got more kills than you and if someone gots the position goes lower, so if it's like this:
some3one 0 kills
You 1 kill
someone 2 kills
some2one 3 kills

You get 3 position because 2 people got more kills and 1 just not
Reply
#7

So this is the part that gets how much players are in the server? xD
Sorry if I get on your nerves,I'm really confused right now o.O
Reply
#8

Yeah this:
for(new i; i<MAX_PLAYERS; i++)
Checks all the players
Reply
#9

I'd guess you'd need a loop inside a loop.

For the amount of players online, you can either loop through all players and, if they're connected, update a variable, or simply update it with OnPlayer(Dis)Connect.

Maybe a small example of what you could do with listing highest players above:

pawn Код:
new pOnline = 0;
public OnPlayerConnect(playerid)
{
  pOnline++;
  return 1;
}

public OnPlayerConnect(playerid,reason)
{
  pOnline--;
  return 1;
}

//Unsure about this, you might try to edit it. I'm not used to this.
new blub[MAX_PLAYERS]; // Why I named it that? No idea.
for(new i; i < MAX_PLAYERS; i++)
{
  if(!IsPlayerConnected(i)) continue;
  for(new bla; bla < MAX_PLAYERS; bla++)
  {
    if(GetPlayerMoney(playerid) > GetPlayerMoney(blub[bla]) && GetPVarInt(playerid,"Checked") != 1)
    {
      for(new bla2; bla2 < MAX_PLAYERS: bla2--)
      {
      while(bla != bla2) {
      if(bla2 == 0) continue;
      blub[bla2] = blub[bla2-1];
      }}
      blub[bla] = i;
      SetPVarInt(playerid,"Checked",1)
    }
  }
DeletePVar(i,"Checked")
Something like that. It won't be RAM-friendly, and it probably won't work either. But give it a try. This shows the ID with the highest amount of money in the first thingy (blub[0]) and the player with the lowest money in blub[499].

Be sure to check for non-connected players though

As for O_x: You and I share a lot in common for some reason. I'm confused as well.
Reply
#10

Hiddos,your code is fatass xD
Thanks =P,
but can I change GetPlayerMoney to pInfo[playerid][Kills]?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)