SA-MP Forums Archive
Textdraw scoring - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Textdraw scoring (/showthread.php?tid=85526)



Textdraw scoring - Rhemsis - 08.07.2009

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



Re: Textdraw scoring - troy52192 - 08.07.2009

get rid of return1; and just use }


Re: Textdraw scoring - Ignas1337 - 08.07.2009

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)