Simple question, - Need for multiple strings?
#1

pawn Код:
CMD:cops(playerid, params[])
{
    new string[200];
    SendClientMessage(playerid, pink, " - - - - - <<<<<< Cop's Online on --- >>>>>>  - - - - - ");
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(GetPVarInt(i, "cophidden") == 0)
        {
            if(cop[i][level] == 8)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            if(cop[i][level] == 7)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            if(cop[i][level] == 6)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            if(cop[i][level] == 5)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            if(cop[i][level] == 4)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            if(cop[i][level] == 3)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            if(cop[i][level] == 2)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            if(cop[i][level] == 1)
            {
                format(string, sizeof(string), "%s %s [ID: %d] Rank: %d", CopRank(i), PlayerName(i), GetPlayerID(PlayerName(i)), cop[i][level]);
                SendClientMessage(playerid, blue, string);
            }
            else if(cop[i][level] == 0 || GetPVarInt(i, "cophidden") == 1)
                return SendClientMessage(playerid, pink, ">>>>> No Cops Found Online! <<<<<");
        }
    }
    return 1;
}
Okay, look at the code, i have defined the "string[200]" on the top, but i am not sure how it will act when i use this command, and there is multiple cops online.. Is there need for different strings all over the code here, or is it enough with one, simple string for it all ?

Please explain
Thanks alot!
Reply
#2

1 string for it all is fine.
Reply
#3

Quote:
Originally Posted by Nuke547
Посмотреть сообщение
1 string for it all is fine.
Thanks for reply, i thought so too. But is this because the string is used once per player ?
Reply
#4

Quote:
Originally Posted by airplanesimen
Посмотреть сообщение
Thanks for reply, i thought so too. But is this because the string is used once per player ?
This works fine because samp is single threaded. Nothing else than what is currently running can change the string.
Reply
#5

Question for you: why do you have 9 if-statements, while the output will always be the same, regardless of the player's level? Also this is retarded:

pawn Код:
GetPlayerID(PlayerName(i))
Get the name of a playerid you know, then use that name to determine the playerid that you knew in the first place.
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
Question for you: why do you have 9 if-statements, while the output will always be the same, regardless of the player's level? Also this is retarded:

pawn Код:
GetPlayerID(PlayerName(i))
Get the name of a playerid you know, then use that name to determine the playerid that you knew in the first place.
Oh, yea, that was kind of stupid of me, i could have used only "i" there xD


And about this: Question for you: why do you have 9 if-statements, while the output will always be the same, regardless of the player's level?

That is because the "CopRank" wont be the same in all the statements, and i want the ranks Sorted ^^


Thanks FunExtreme
Quote:

This works fine because samp is single threaded. Nothing else than what is currently running can change the string.

Reply
#7

In that case you still need 8 separate loops, because this won't work as you'd expect.
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
In that case you still need 8 separate loops, because this won't work as you'd expect.
Okay, thanks, then i will attempt to make it work :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)