tdm score count problem
#1

guys i made this script But onplayer killerid kills playerid textdraw shows value in 1000 another kill 2000 like this need help

PHP Code:
if(TDM[killerid] == 1)
    {
        new 
gTeam GetPlayerTeam(killerid);
        new 
eTeam GetPlayerTeam(playerid);
        for(new 
0;i<MAX_PLAYERS;i++)
        {
            if(
gTeam == Team_Magma && eTeam == Team_Aqua)
            {
                
Magma_score++;
                
format(string,sizeof(string),"{FFFFFF}Magma Killer {84F6D7}%s {FFFFFF}Has Killed Aqua Player {84F6D7}%s.",PlayerName(killerid),PlayerName(playerid));
                
SendClientMessage(i,COLOR_ORANGE,string);
                new 
td[128];
                
format(td,sizeof(td),"~r~Magma~n~Score (%d)",Magma_score);
                
TextDrawSetString(SCORE_TD[0],td);
                
TextDrawShowForPlayer(playeridSCORE_TD[0]);
                
GivePlayerMoney(i,500);
             }
             if(
gTeam == Team_Aqua && eTeam == Team_Magma)
             {
                 
Aqua_score++;
                 new 
td[128];
                 
format(string,sizeof(string),"{FFFFFF}Aqua Killer {84F6D7}%s {FFFFFF}Has Killed Magma Player {84F6D7}%s.",PlayerName(killerid),PlayerName(playerid));
                
SendClientMessage(i,COLOR_ORANGE,string);
                
format(td,sizeof(td),"~b~Aqua~n~Score (%d)",Aqua_score);
                
TextDrawSetString(SCORE_TD[1],td);
                
TextDrawShowForPlayer(playeridSCORE_TD[1]);
                
GivePlayerMoney(i,500);
             }
        }
    } 
Reply
#2

I believe you should make it under OnPlayerDeath, and set the score enum as a variable starts from 0 and increases when the person in that team kills another person from the other team... Got it? Or I should Post a code?
Reply
#3

its on under onplayerdeath
if these codes arew not under it then why its increasing when player death score + in value of 1000 expect the value of 1 i think the problem is in this %d which sign will work if varaibile is like this new score score++;
sorry for my bad english but i need help still
Reply
#4

I see the problem isn't in the script upwards, Show me the Magma_Score and Aqua_Score in your script..
Reply
#5

1st
Quote:

new Magma_score;
new Aqua_score;

and

Quote:

if(TDM[killerid] == 1)
{
new gTeam = GetPlayerTeam(killerid);
new eTeam = GetPlayerTeam(playerid);
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(gTeam == Team_Magma && eTeam == Team_Aqua)
{
Magma_score++;
format(string,sizeof(string),"{FFFFFF}Magma Killer {84F6D7}%s {FFFFFF}Has Killed Aqua Player {84F6D7}%s.",PlayerName(killerid),PlayerName(playe rid));
SendClientMessage(i,COLOR_ORANGE,string);
new td[128];
format(td,sizeof(td),"~r~Magma~n~Score (%d)",Magma_score);
TextDrawSetString(SCORE_TD[0],td);
TextDrawShowForPlayer(playerid, SCORE_TD[0]);
GivePlayerMoney(i,500);
}
if(gTeam == Team_Aqua && eTeam == Team_Magma)
{
Aqua_score++;
new td[128];
format(string,sizeof(string),"{FFFFFF}Aqua Killer {84F6D7}%s {FFFFFF}Has Killed Magma Player {84F6D7}%s.",PlayerName(killerid),PlayerName(playe rid));
SendClientMessage(i,COLOR_ORANGE,string);
format(td,sizeof(td),"~b~Aqua~n~Score (%d)",Aqua_score);
TextDrawSetString(SCORE_TD[1],td);
TextDrawShowForPlayer(playerid, SCORE_TD[1]);
GivePlayerMoney(i,500);
}
}
}

only here i used these
Reply
#6

I suppose your MAX_PLAYERS is defined as 1000, this being said, every loop you make you add 1 value to Magma_score or Aqua_score. At the end of the loop you'll have 1000+ on these values. Get that addition out of the loop.
Reply
#7

can you give example plz
Reply
#8

No. I pretty much explained what you have to do, make a bit of effort to understand and apply.
Reply
#9

is this error is coming b/c i use this for(new i = 0;i<MAX_PLAYERS;i++)
{

PHP Code:
for(new 0;i<MAX_PLAYERS;i++)
        {
            if(
gTeam == Team_Magma && eTeam == Team_Aqua)
            {
                
Magma_score++;
                
format(string,sizeof(string),"{FFFFFF}Magma Killer {84F6D7}%s {FFFFFF}Has Killed Aqua Player {84F6D7}%s.",PlayerName(killerid),PlayerName(playerid));
                
SendClientMessage(i,COLOR_ORANGE,string);
                new 
td[128];
                
format(td,sizeof(td),"~r~Magma~n~Score (%b)",Magma_score);
                
TextDrawSetString(SCORE_TD[0],td);
                
TextDrawShowForPlayer(playeridSCORE_TD[0]);
                
GivePlayerMoney(i,500);
             }
             if(
gTeam == Team_Aqua && eTeam == Team_Magma)
             {
                 
Aqua_score++;
                 new 
td[128];
                 
format(string,sizeof(string),"{FFFFFF}Aqua Killer {84F6D7}%s {FFFFFF}Has Killed Magma Player {84F6D7}%s.",PlayerName(killerid),PlayerName(playerid));
                
SendClientMessage(i,COLOR_ORANGE,string);
                
format(td,sizeof(td),"~b~Aqua~n~Score (%i)",Aqua_score);
                
TextDrawSetString(SCORE_TD[1],td);
                
TextDrawShowForPlayer(playeridSCORE_TD[1]);
                
GivePlayerMoney(i,500);
             }
        }
    } 
Reply
#10

No. There's no error to start with. If you count to 1000 and eat a slice of pie every addition (1,2,3,4,5,6...), you'll end up eating 1000 slices of pie. Simple logic.

This is a loop, this is you counting from 0 to 1000:
Code:
for(new i = 0;i<MAX_PLAYERS;i++)
Whenever the conditional statements apply, this is you eating a slice of pie:
Code:
Aqua_score++;
Magma_score++;
Now what would happen if, instead of eating a slice of pie every addition, you first eat a slice of pie and then count to 1000? You'd end up eating 1 slice of pie only.
Reply
#11

so i think i should remove
Quote:

for(new i = 0;i<MAX_PLAYERS;i++)

and then check what u say
Reply
#12

i +rep you Ty for help im sure this will work MYBE
Reply
#13

Thanks So Much You Are Awsome its Working now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)