Counting up
#1

Код:
I want to make a system that if you enter a good answer you get 1 point, this points stack up and form a result.

At the position where an answer is given it says:

DrivingTheoryPoints[playerid] ++;
	       format(string, sizeof(string), "%s points",DrivingTheoryPoints[playerid]);
	       SendClientMessage(playerid, COLOR_RED, string);
And at the end:

Код:
	        switch(DrivingTheoryPoints[playerid])
	        {
	            case 0: ttext = "0";
	            case 1: ttext = "20";
	            case 2: ttext = "40";
	            case 3: ttext = "60";
	            case 4: ttext = "80";
	            case 5: ttext = "100";
			}
format(string, sizeof(string), "%s points",ttext);
Unfortunately this doesn't work.
Both formats give wrong outcomes (and the first format gives nothing).
Reply
#2

Update:

Putting the switch inside a different if(...) code doesn't work either, so I still got the same problem.
Reply
#3

pawn Код:
format(string, sizeof(string), "%s points",DrivingTheoryPoints[playerid]);
Change %s to %d.

pawn Код:
format(string, sizeof(string), "%d points",DrivingTheoryPoints[playerid]);
Reply
#4

Gives me very weird things.
If the DrivingtheoryPoints ++ has been called 3 times, it gives different variables.
sometimes 11 sometimes 4.. very odd.
Reply
#5

I did it

pawn Код:
DrivingTheoryPoints[playerid]++;
format(string, sizeof(string), "%i points",DrivingTheoryPoints[playerid]);
SendClientMessage(playerid, COLOR_RED, string);


//The second code
new prhase[4];
switch(DrivingTheoryPoints[playerid])
{
    case 0: format(prhase,4,"0");
    case 1: format(prhase,4,"20");
    case 2: format(prhase,4,"40");
    case 3: format(prhase,4,"60");
    case 4: format(prhase,4,"80");
    case 5: format(prhase,4,"100");
}
format(string, sizeof(string), "%s points",prhase);
I hope that i have helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)