#1

why is this showing "Error: Unmatched Tilde"
instead of the players whom have a hit contract on them.

pawn Code:
CMD:hits(playerid, params[])
{
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && HasHit[i] == 1)
        {

            format(string, sizeof(string), "%s(%d)~n~%s(%d)~n~%s(%d)~n~%s(%d)~n~%s(%d)", GetName(i), i,GetName(i), i,GetName(i), i,GetName(i), i,GetName(i), i);
            TextDrawSetString(List[playerid], string);
            TextDrawShowForPlayer(playerid, List[playerid]);
        }
    }
    return 1;
}
Reply
#2

Well the problem is in your format,check out if this works.

Code:
format(string, sizeof(string), "%s(%d)",GetName(i),i);
Reply
#3

<removed>
Reply
#4

Code:
CMD:hits(playerid, params[])
{
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && HasHit[i] == 1)
        {

            format(string, sizeof(string), "%s(%i)~n~%s(%i)~n~%s(%i)~n~%s(%i)~n~%s(%i)", GetName(i), i,GetName(i), i,GetName(i), i,GetName(i), i,GetName(i), i);
            TextDrawSetString(List[playerid], string);
            TextDrawShowForPlayer(playerid, List[playerid]);
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by DavidBilla
View Post
Well the problem is in your format,check out if this works.

Code:
format(string, sizeof(string), "%s(%d)",GetName(i),i);
i tried this before, it worked but it only show 1 player name.
what if more than 1 player have a hit contract ? it only shows 1 player's name
Reply
#6

Quote:
Originally Posted by Rittik
View Post
Code:
CMD:hits(playerid, params[])
{
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && HasHit[i] == 1)
        {

            format(string, sizeof(string), "%s(%i)~n~%s(%i)~n~%s(%i)~n~%s(%i)~n~%s(%i)", GetName(i), i,GetName(i), i,GetName(i), i,GetName(i), i,GetName(i), i);
            TextDrawSetString(List[playerid], string);
            TextDrawShowForPlayer(playerid, List[playerid]);
        }
    }
    return 1;
}
worked but there is another problem now.
"Error: unmatched tilde" is solved now, but here is the problem:

if more than 1 player has a hit contract, it chooses the last player that has been contracted and shows it like:

Code:
Player(0)
Player(0)
Player(0)
Player(0)
Player(0)
it also happens if there is just 1 player that has a hit contract.
Reply
#7

Try this.
Code:
CMD:hits(playerid, params[])
{
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && HasHit[i] == 1)
        {

            format(string, sizeof(string), "%s(%i)~n~", GetName(i), i);
            TextDrawSetString(List[playerid], string);
            TextDrawShowForPlayer(playerid, List[playerid]);
        }
    }
    return 1;
}
Reply
#8

didn't work
Reply
#9

pawn Code:
CMD:hits(playerid, params[])
{
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && HasHit[i] == 1)
        {

            format(string, sizeof(string), "%s~n~%s(%d)~n~", string, GetName(i), i);
            TextDrawSetString(List[playerid], string);
            TextDrawShowForPlayer(playerid, List[playerid]);
        }
    }
    return 1;
}
Haven't tested, should work though.
EDIT: You can use "HasHit[i]" instead of "HasHit[i] == 1".
+, if that doesn't still work, try using the "TextDrawShowForPlayer" OUTSIDE THE LOOP.
Example:
pawn Code:
CMD:hits(playerid, params[])
{
    new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && HasHit[i] == 1)
        {

            format(string, sizeof(string), "%s~n~%s(%d)~n~", string, GetName(i), i);
            TextDrawSetString(List[playerid], string);
        }
    }
   TextDrawShowForPlayer(playerid, List[playerid]); //outside loop!
    return 1;
}
Reply
#10

it worked thank you, rep+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)