SA-MP Forums Archive
Players Number - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Players Number (/showthread.php?tid=632027)



Players Number - IceSKull - 08.04.2017

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


Re: Players Number - LEOTorres - 08.04.2017

This should be good.

Код:
new deathcount;

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



Re: Players Number - Odeath - 08.04.2017

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


Re: Players Number - IceSKull - 08.04.2017

Who killed them!


Re: Players Number - LEOTorres - 08.04.2017

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;
}



Re: Players Number - IceSKull - 08.04.2017

I also want to Get a number of Players:

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


Re: Players Number - LEOTorres - 08.04.2017

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);



Re: Players Number - IceSKull - 08.04.2017

Thank u very much :P im just a beginner


Re: Players Number - Odeath - 08.04.2017

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);
}




Re: Players Number - LEOTorres - 08.04.2017

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.