Players Number
#1

Hello guys! need a bit help!

---- if(IsPlayerInArea....) die ----
I want the total number of players die in the area!

+ Give him the score same to the numbers of Players died
Reply
#2

This should be good.

Код:
new deathcount;

public OnPlayerDeath(playerid, killerid, reason)
{
	if (IsPlayerInArea (playerid, ...))
	{
		deathcount++;
		SetPlayerScore (playerid, deathcount);
	}
	
	return 1;
}
Reply
#3

You want to give score to the players who die or to the player who killed them ?
Reply
#4

Who killed them!
Reply
#5

Quote:
Originally Posted by IceSKull
Посмотреть сообщение
Who killed them!
In that case:

Код:
new deathcount;

public OnPlayerDeath(playerid, killerid, reason)
{
	if (IsPlayerInArea (playerid, ...))
	{
		deathcount++;

		if(killerid != INVALID_PLAYER_ID)
		{
			SetPlayerScore (killerid, deathcount);
		}
	}
	
	return 1;
}
Reply
#6

I also want to Get a number of Players:

Код:
format(String,sizeof(String),"*%s Players Has been killed.",deathcount);
But that Gives error!
Reply
#7

Quote:
Originally Posted by IceSKull
Посмотреть сообщение
I also want to Get a number of Players:

Код:
format(String,sizeof(String),"*%s Players Has been killed.",deathcount);
But that Gives error!
deathcount is an integer, in this case, you would use:

Код:
format (String, sizeof(String), "%i players have been killed.", deathcount);
Reply
#8

Thank u very much :P im just a beginner
Reply
#9

Don't use
Quote:

new deathcount;

public OnPlayerDeath(playerid, killerid, reason)
{
if (IsPlayerInArea (playerid, ...))
{
deathcount++;

if(killerid != INVALID_PLAYER_ID)
{
SetPlayerScore (killerid, deathcount);
}
}

return 1;
}

it will not increment the player's score it will initialize the score and then set it to deathcount
for example if you killed 4 players and you had 5 score you score will be 4 not 9
Quote:

if(killerid != INVALID_PLAYER_ID)
{
new Score = GetPlayerScore(killerid) + 1;
SetPlayerScore (killerid, Score);
}

Reply
#10

Quote:
Originally Posted by Odeath
Посмотреть сообщение
Don't use

it will not increment the player's score it will initialize the score and then set it to deathcount
for example if you killed 4 players and you had 5 score you score will be 4 not 9
Perhaps I'm not understanding his English, but I was under the impression that's what he said he wanted.

If it isn't, you can simply do:

Код:
SetPlayerScore (killerid, GetPlayerScore(killerid) + deathcount);
The code you provided only increases the score by one, it doesn't take into account the other players dead within the area, which if someone else were to kill, wouldn't be added onto the killer's score.

Again, I'm assuming that is what he wants, your interpretation may be correct.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)