Variables. += Dosn't work.
#1

I created Variable :
new Kills = 1;

When I write command /add , Variable doesn't incerace by 2.
Quote:

if (strcmp("/add", cmdtext, true, 10) == 0)
{
Kills += 2;
return 1;
}

I check with :

Quote:

new statistic[128];
format(statistic,sizeof(statistic), "Team 1 Score: %d",Kills );
SendClientMessage(playerid,COLOR,statistic);

and it's still 1.

Maybe can anyone help or say how to incerace value of variable Kills ?
Please help, Thanx.
Reply
#2

pawn Код:
if (strcmp("/add", cmdtext, true, 10) == 0)
{
Kills += 2;
new statistic[128];
format(statistic,sizeof(statistic), "Team 1 Score: %d",Kills );
SendClientMessage(playerid,COLOR,statistic);
return 1;
}
Try with this code.
Reply
#3

Did you make the 'new Kills = 1;' in OnPlayerCommandText, and the checking function somewhere else?
Reply
#4

MadeMan code working. I trying to do it with TextDraw and it wont work. theres my script :
Quote:

new Text:Textdraw0;
new Text:Textdraw1;
new zNuzudimai = 1;
new mNuzudimai = 1;

Quote:

public OnGameModeInit()
{
new statistika[128];
format(statistika,sizeof(statistika), "~g~Team Green Score: %d",zNuzudimai);
Textdraw0 = TextDrawCreate(432.000000, 366.000000,statistika);
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, -1);
TextDrawSetOutline(Textdraw0, 0);
TextDrawSetProportional(Textdraw0, 1);
TextDrawSetShadow(Textdraw0, 1);
TextDrawUseBox(Textdraw0, 1);
TextDrawBoxColor(Textdraw0, 255);
TextDrawTextSize(Textdraw0, 628.000000, 0.000000);
new statistika1[128];
format(statistika1,sizeof(statistika1), "~b~TEAM Blue Score: %d",mNuzudimai);
Textdraw1 = TextDrawCreate(432.000000, 381.000000, statistika1);
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 1);
TextDrawLetterSize(Textdraw1, 0.500000, 1.000000);
TextDrawColor(Textdraw1, -1);
TextDrawSetOutline(Textdraw1, 0);
TextDrawSetProportional(Textdraw1, 1);
TextDrawSetShadow(Textdraw1, 1);
TextDrawUseBox(Textdraw1, 1);
TextDrawBoxColor(Textdraw1, 255);
TextDrawTextSize(Textdraw1, 628.000000, 0.000000);

for(new i; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
TextDrawShowForPlayer(i, Textdraw0);
TextDrawShowForPlayer(i, Textdraw1);
}
}
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
if (gTeam[playerid] == TEAM_M)
{
mNuzudimai += 1;
}
else if (gTeam[playerid] == TEAM_Z)
{
zNuzudimai += 1;
}
return 1;
}

When player die or I write command to incerace value the TextDraw doesn't write new variable value. Maybe I have to update Text draw Somehow ?
Reply
#5

Quote:
Originally Posted by Ernis456
Посмотреть сообщение
MadeMan code working. I trying to do it with TextDraw and it wont work. theres my script :



When player die or I write command to incerace value the TextDraw doesn't write new variable value. Maybe I have to update Text draw Somehow ?
Update it using a timer. (Hide, and then re-show the textdraw)
Reply
#6

Use SetTimer and TextDrawSetString
Reply
#7

Ok , I'll try, going to create and test is it work. Thanx for help.
Reply
#8

What's the point of using a timer to update a textdraw which will change it's text only when OnPlayerDeath gets called for some player?

Just update the textdraw under OnPlayerDeath.
Reply
#9

It doesn't work. Theres script :
On top of GM:
Quote:

new Text:Textdraw0;
new Text:Textdraw1;
new zNuzudimai = 1;
new mNuzudimai = 1;

public OnGameModeInit() // ,zNuzudimai,mNuzudimai %d
{
new statistika[128];
format(statistika, sizeof(statistika), "~g~TEAM1 Score: %d ", mNuzudimai);
TextDrawSetString(Textdraw0, statistika);

new statistika1[128];
format(statistika1, sizeof(statistika1), "~b~TEAM2 Scor: %d", zNuzudimai);
TextDrawSetString(Textdraw1, statistika1);
// Zaliuju
Textdraw0 = TextDrawCreate(432.000000, 366.000000,statistika);
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, -1);
TextDrawSetOutline(Textdraw0, 0);
TextDrawSetProportional(Textdraw0, 1);
TextDrawSetShadow(Textdraw0, 1);
TextDrawUseBox(Textdraw0, 1);
TextDrawBoxColor(Textdraw0, 255);
TextDrawTextSize(Textdraw0, 628.000000, 0.000000);
// Melinuju
Textdraw1 = TextDrawCreate(432.000000, 381.000000, statistika1);
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 1);
TextDrawLetterSize(Textdraw1, 0.500000, 1.000000);
TextDrawColor(Textdraw1, -1);
TextDrawSetOutline(Textdraw1, 0);
TextDrawSetProportional(Textdraw1, 1);
TextDrawSetShadow(Textdraw1, 1);
TextDrawUseBox(Textdraw1, 1);
TextDrawBoxColor(Textdraw1, 255);
TextDrawTextSize(Textdraw1, 628.000000, 0.000000);

return 1;
}
public OnPlayerSpawn(playerid)
{
SetTimer("StatistikaU",2000,true);

public OnPlayerDeath(playerid, killerid, reason)
{
if (gTeam[playerid] == TEAM_M)
{
mNuzudimai += 1;
}
else if (gTeam[playerid] == TEAM_Z)
{
zNuzudimai += 1;
}
forward StatistikaU();
public StatistikaU()
{
TextDrawHideForAll(Textdraw0);
TextDrawHideForAll(Textdraw1);

TextDrawShowForAll(Textdraw0);
TextDrawShowForAll(Textdraw1);
}

And one more problem, Textdraw0 doesn't creates.
Reply
#10

You shouldn't use += at all, for kills you need to keep counting, in this way you have to use Kills++;, it simply counts your kills up
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)