25.03.2014, 15:23
(
Последний раз редактировалось Battlezone; 25.03.2014 в 15:50.
Причина: SOLVED
)
I have never tried to do this before:
These are 3 player classes, by default, the player has the first one, that does mean total classes = 1, so we will get this:
When the player makes progress in-game, he can unlock more classes.
For example, he will unlock sniper class, which does mean that total classes are equal to 2, so we will get this:
ok, now im gonna send the total classes number in a client message to the player.
My problem is how to count them?
SOLUTION:
[QUOTE=Konstantinos;2966974]I wouldn't use:
but:
When you want to make the string empty, use the above instead of "".
Now it's null so:
and
pawn Код:
PlayerInfo[playerid][soldier]
PlayerInfo[playerid][sniper]
PlayerInfo[playerid][assault]
pawn Код:
PlayerInfo[playerid][soldier] = "Soldier"
PlayerInfo[playerid][sniper] = ""
PlayerInfo[playerid][assault] = ""
For example, he will unlock sniper class, which does mean that total classes are equal to 2, so we will get this:
pawn Код:
PlayerInfo[playerid][soldier] = "Soldier"
PlayerInfo[playerid][sniper] = "Sniper"
PlayerInfo[playerid][assault] = ""
My problem is how to count them?
SOLUTION:
[QUOTE=Konstantinos;2966974]I wouldn't use:
pawn Код:
PlayerInfo[playerid][sniper] = "";
pawn Код:
PlayerInfo[playerid][sniper][0] = EOS;
// OR
PlayerInfo[playerid][sniper][0] = '\0';
Now it's null so:
pawn Код:
new
count; // it doesn't need to be an array as you said in your above post.
if (!isnull(PlayerInfo[playerid][soldier])) ++count;
if (!isnull(PlayerInfo[playerid][sniper])) ++count;
if (!isnull(PlayerInfo[playerid][assault])) ++count;
// format(...);
// Using "count" as argument will give the total classes.
pawn Код:
#if !defined isnull
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif