Textdraw scoring
#1

In my gamemode, I've scripted a DM arena, which works with two teams (red and blue)
Id like to make their scores visible via textdraws that update on a player dying. This is the code I have below, it is under my onplayerdeath. The GM compiles without error, but when I die in game,the game crashes. Does anyone see what is wrong, and could you help me fix it?

pawn Код:
if(gTeam[killerid] == TEAM_BLUEDM && gTeam[playerid] == TEAM_BLUEDM){
      bluescore -= 1;
      format(string, sizeof(string), "Blue Team: %d", bluescore);
        TextDrawSetString(bluescoretxt, string);
        TextDrawAlignment(bluescoretxt, 1);
        TextDrawFont(bluescoretxt, 0);
        TextDrawLetterSize(bluescoretxt, 0.1, 0.1);
        TextDrawColor(bluescoretxt, 0x0000C1FF);
        return 1;
        }
      if(gTeam[killerid] == TEAM_BLUEDM && gTeam[playerid] == TEAM_REDDM){
      bluescore += 1;
      format(string, sizeof(string), "Blue Team: %d", bluescore);
        TextDrawSetString(bluescoretxt, string);
        TextDrawAlignment(bluescoretxt, 1);
        TextDrawFont(bluescoretxt, 0);
        TextDrawLetterSize(bluescoretxt, 0.1, 0.1);
        TextDrawColor(bluescoretxt, 0x0000C1FF);
        return 1;
        }
      if(gTeam[killerid] == TEAM_REDDM && gTeam[playerid] == TEAM_REDDM){
      redscore -= 1;
      format(string, sizeof(string), "Red Team: %d", redscore);
        TextDrawSetString(redscoretxt, string);
        TextDrawAlignment(redscoretxt, 1);
        TextDrawFont(redscoretxt, 0);
        TextDrawLetterSize(redscoretxt, 0.1, 0.1);
        TextDrawColor(redscoretxt, 0xAD0000FF);
        return 1;
        }
      if(gTeam[killerid] == TEAM_REDDM && gTeam[playerid] == TEAM_BLUEDM){
      redscore += 1;
        format(string, sizeof(string), "Red Team: %d", redscore);
        TextDrawSetString(redscoretxt, string);
        TextDrawAlignment(redscoretxt, 1);
        TextDrawFont(redscoretxt, 0);
        TextDrawLetterSize(redscoretxt, 0.1, 0.1);
        TextDrawColor(redscoretxt, 0xAD0000FF);
        return 1;
        }
Reply
#2

get rid of return1; and just use }
Reply
#3

yes, it would return 1 anyway because you don't use else-if and onlly if- statements. if you were using else-if statements then the return 1; would be unreachable code. (OnPlayerDeath I mean)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)