PDA

View Full Version : tdm score count problem


Aldrago
16/06/2017, 11:16 AM
guys i made this script But onplayer killerid kills playerid textdraw shows value in 1000 another kill 2000 like this need help

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

JasonRiggs
16/06/2017, 01:07 PM
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?

Aldrago
16/06/2017, 01:28 PM
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

JasonRiggs
16/06/2017, 02:23 PM
I see the problem isn't in the script upwards, Show me the Magma_Score and Aqua_Score in your script..

Aldrago
16/06/2017, 03:02 PM
1st
new Magma_score;
new Aqua_score;

and

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

Toroi
16/06/2017, 03:14 PM
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.

Aldrago
16/06/2017, 03:16 PM
can you give example plz

Toroi
16/06/2017, 03:18 PM
No. I pretty much explained what you have to do, make a bit of effort to understand and apply.

Aldrago
16/06/2017, 03:18 PM
is this error is coming b/c i use this for(new i = 0;i<MAX_PLAYERS;i++)
{

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(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(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(playerid));
SendClientMessage(i,COLOR_ORANGE,string);
format(td,sizeof(td),"~b~Aqua~n~Score (%i)",Aqua_score);
TextDrawSetString(SCORE_TD[1],td);
TextDrawShowForPlayer(playerid, SCORE_TD[1]);
GivePlayerMoney(i,500);
}
}
}

Toroi
16/06/2017, 03:27 PM
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:
for(new i = 0;i<MAX_PLAYERS;i++)

Whenever the conditional statements apply, this is you eating a slice of pie:
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.

Aldrago
16/06/2017, 03:30 PM
so i think i should remove
for(new i = 0;i<MAX_PLAYERS;i++)

and then check what u say

Aldrago
16/06/2017, 03:32 PM
i +rep you Ty for help im sure this will work MYBE

Aldrago
16/06/2017, 03:35 PM
Thanks So Much You Are Awsome its Working now