score help
#1

i made a team death match and i made a text draw Team1 : [score] || Team2: [score] , my question is how to make this score get +1 when a player from team1 kill player from team2 and when score reach 10 SendRconCommand("gmx") ?
Reply
#2

Something like

pawn Код:
new TeamScore[2];

public OnPlayerDeath(playerid, killerid, reason)
{
  if(/*opposite teams check*/)
  {
     TeamScore(/*killers team*/);
  }
  else /*it was a team kill, do whatever you do*/;
}

public TeamScore(team)
{
  TeamScore[team]++;
  TextDrawSetString(yourtextid, "Team1 : [%d] || Team2: [%d]", TeamScore[0], TeamScore[1]);
  TextDrawShowForAll(yourtextid);
  if(TeamScore[team] >= 10) SendRconCommand("gmx");
}
Reply
#3

can u explain more cause i am kinda new in scripting
Reply
#4

Basically you need to keep a variable for a teams score:
new TeamScore[2];

I assume you have a team system, so just as an example
new Team[MAX_PLAYERS];

When a player is killed you get the callback
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
//So here we check that it wasn't a team kill
  if(Team[playerid]==Team[killerid])
  {
    //They are the same team, punish the killer how you will, example:
    SetPlayerHealth(killerid, 0);
    SendClientMessage(killerid, 0xAA0000AA, "No Team Killing");
  }else
  {
    //killerid has killed playerid, increase his teams score
    TeamScorePlus(Team[killerid]); //calls the function below
  }
}

//This is called when someone scores a kill
stock TeamScorePlus(team)
{
  //Increase the teams score
  TeamScore[team]++;
  //Here you reset your textdraw string to have the new scores
  TextDrawSetString(yourtextid, "Team1 : [%d] || Team2: [%d]", TeamScore[0], TeamScore[1]);
  //Now show all the players this updated textdraw
  TextDrawShowForAll(yourtextid);
  //Here we check to see if a score has reached 10 and send your command
  if(TeamScore[team] >= 10) SendRconCommand("gmx");
}

Reply
#5

i made something and want to know if it works :

Код:
new Text:Textdraw2;
new lsscore;
new lvscore;
Код:
public OnPlayerDeath(playerid, killerid, reason)
{

  	if(GetPlayerTeam(killerid) == 1)
		{
			lvscore++;
		}
		else
		{
		if(GetPlayerTeam(killerid) == 2)
		{
			lsscore++;
		}
		if(lsscore == 20 || lvscore == 20)
		{
			SendRconCommand("gmx");

		}
	 	return 1;

 		}
		return 1;
}
Код:
public OnGameModeInit()
{
  Textdraw2 = TextDrawCreate(394.000000,1.000000,"LS:[%s]|| LV:[%s]");
  new string[128];
	format(string, sizeof(string), "LS: %d || LV: %d", lsscore, lvscore);
	TextDrawSetString(Textdraw2, string);
	TextDrawAlignment(Textdraw2,0);
	TextDrawBackgroundColor(Textdraw2,0x0000ffcc);
 	TextDrawFont(Textdraw2,3);
	TextDrawLetterSize(Textdraw2,0.399999,1.100000);
	TextDrawColor(Textdraw2,0xffffffff);
	TextDrawSetOutline(Textdraw2,1);
	TextDrawSetProportional(Textdraw2,1);
	TextDrawSetShadow(Textdraw2,1);
Reply
#6

Yep that looks like it should work.
Except you haven't updated the textdraw when the scores update.
And you don't check for team kills.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{

  	if(GetPlayerTeam(killerid) == 1)
		{
			if(GetPlayerTeam(killerid) != GetPlayerTeam(playerid)) lvscore++;
		}
		else
		{
		if(GetPlayerTeam(killerid) == 2)
		{
			if(GetPlayerTeam(killerid) != GetPlayerTeam(playerid)) lsscore++;
		}
		if(lsscore == 20 || lvscore == 20)
		{
			SendRconCommand("gmx");

		}
	 	return 1;
	 	format(string, sizeof(string), "LS: %d || LV: %d", lsscore, lvscore);
	 	TextDrawSetString(Textdraw2, string);
	 	TextDrawShowForAll(Textdraw2);
 		}
		return 1;
}
Reply
#7

thnx very much but 1 more question plz , i want to add a SendClientMessageToAll when a team win the round (Team Won The Round ,, Restarting)
Reply
#8

Код:
if(lsscore == 20 || lvscore == 20)
		{
            new teamwin[2] = lssscore==20 ? "LS" : "LV";
            SendClientMessageToAll(0XAA0000AA, "%s has won the round, LS: %d || LV: %d", teamwin, lsscore, lvscore);
			SendRconCommand("gmx");

		}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)