TextDraw Problem
#1

if an player uses my command /stats and he is seeing stats of player id 1 and then an other players types the same command and want's to see stats of playerid 2 the command will show everyone the stats of player id 2 even to those who are seeing of player id 1
pawn Код:
CMD:stats(playerid, params[])
{
        new TargetID;
        new string[500], str1[500], str[500];
        if(sscanf(params, "u", TargetID)) TargetID = playerid;
        if(TargetID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_RED, "*Player Is Not Connected.");
        new score =  GetPlayerScore(TargetID);
        new cash = GetPlayerMoney(TargetID);
        HideAllServerTextDraws(playerid);
        format(str1, sizeof(str1),"~P~%s (%d)~W~~N~Score: ~G~%d",pInfo[TargetID][playername],TargetID,score);
        TextDrawSetString(Stats[2], str1);
        TextDrawShowForPlayer(playerid,Stats[2]);
        format(string, sizeof(string),"~W~Kills~N~Deaths~N~Money~N~AD Pills Used~N~Raped~N~Got Raped~N~Times Flashed~N~Flash Kills~N~Insulted Kills~N~Flashed Deaths~N~Insulted Deaths~N~Money Bags Found");
        TextDrawSetString(Stats[3], string);
        TextDrawShowForPlayer(playerid,Stats[3]);
        format(str, sizeof(str),"~G~%d~N~%d~N~$%d~N~%d~N~%d~N~%d~N~%d~N~%d~N~%d~N~%d~N~%d~N~%d",pInfo[TargetID][Kills],pInfo[TargetID][Deaths],cash,pInfo[TargetID][ad],pInfo[TargetID][raped],pInfo[TargetID][gotraped],pInfo[TargetID][flash],pInfo[TargetID][flash_kills],pInfo[TargetID][flash_deaths],pInfo[TargetID][foff_kills],pInfo[TargetID][foff_deaths],pInfo[playerid][MoneyBag_Founded]);
        TextDrawSetString(Stats[4], str);
        TextDrawShowForPlayer(playerid,Stats[4]);
        TextDrawShowForPlayer(playerid,Stats[0]);
        TextDrawShowForPlayer(playerid,Stats[1]);
        TextDrawShowForPlayer(playerid,Stats[5]);
        Stats_viewing[playerid] =1;
        return 1;
}
Reply
#2

Because all players is using the same textdraw

use PlayerTextdraw
Reply
#3

pawn Код:
foreach(new playerid : Player)
    {
    Stats[0] = CreatePlayerTextDraw(playerid,118.000000, 122.000000, "~l~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~N~~N~~N~~N~~N~~N~");
    PlayerTextDrawAlignment(playerid,Stats[0], 2);
    PlayerTextDrawBackgroundColor(playerid,Stats[0], 255);
    PlayerTextDrawFont(playerid,Stats[0], 1);
    PlayerTextDrawLetterSize(playerid,Stats[0], 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,Stats[0], -1);
    PlayerTextDrawSetOutline(playerid,Stats[0], 0);
    PlayerTextDrawSetProportional(playerid,Stats[0], 1);
    PlayerTextDrawSetShadow(playerid,Stats[0], 1);
    PlayerTextDrawUseBox(playerid,Stats[0], 1);
    PlayerTextDrawBoxColor(playerid,Stats[0], 110);
    PlayerTextDrawTextSize(playerid,Stats[0], -1.000000, 212.000000);
    PlayerTextDrawSetSelectable(playerid,Stats[0], 0);
    }
this is under ongamemode init but all errors then tag miss match
Reply
#4

I suggest u to add it under onplayerconnect without a loop

it should be something like this

pawn Код:
new PlayerText:Stats[10][MAX_PLAYERS];

//OnPlayerConnect
    Stats[0][playerid] = CreatePlayerTextDraw(playerid,118.000000, 122.000000, "~l~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~N~~N~~N~~N~~N~~N~");
    PlayerTextDrawAlignment(playerid,Stats[0][playerid], 2);
    PlayerTextDrawBackgroundColor(playerid,Stats[0][playerid], 255);
    PlayerTextDrawFont(playerid,Stats[0][playerid], 1);
    PlayerTextDrawLetterSize(playerid,Stats[0][playerid], 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,Stats[0][playerid], -1);
    PlayerTextDrawSetOutline(playerid,Stats[0][playerid], 0);
    PlayerTextDrawSetProportional(playerid,Stats[0][playerid], 1);
    PlayerTextDrawSetShadow(playerid,Stats[0][playerid], 1);
    PlayerTextDrawUseBox(playerid,Stats[0][playerid], 1);
    PlayerTextDrawBoxColor(playerid,Stats[0][playerid], 110);
    PlayerTextDrawTextSize(playerid,Stats[0][playerid], -1.000000, 212.000000);
    PlayerTextDrawSetSelectable(playerid,Stats[0][playerid], 0);
P.S: I am on phone didnt compile it if theres any error tell me
Reply
#5

In you GameModeInit you dont need foreach because it textdraw already showed for everyone.

pawn Код:
new PlayerText:Stats[10][MAX_PLAYERS]; //On to top under includes
public OnGameModeInit()
{
    Stats[0] = (playerid,118.000000, 122.000000, "~l~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~N~~N~~N~~N~~N~~N~");
    PlayerTextDrawAlignment(playerid,Stats[0], 2);
    PlayerTextDrawBackgroundColor(playerid,Stats[0], 255);
    PlayerTextDrawFont(playerid,Stats[0], 1);
    PlayerTextDrawLetterSize(playerid,Stats[0], 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,Stats[0], -1);
    PlayerTextDrawSetOutline(playerid,Stats[0], 0);
    PlayerTextDrawSetProportional(playerid,Stats[0], 1);
    PlayerTextDrawSetShadow(playerid,Stats[0], 1);
    PlayerTextDrawUseBox(playerid,Stats[0], 1);
    PlayerTextDrawBoxColor(playerid,Stats[0], 110);
    PlayerTextDrawTextSize(playerid,Stats[0], -1.000000, 212.000000);
    PlayerTextDrawSetSelectable(playerid,Stats[0], 0);
    return 1;
    }

public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, Stats[0]);
return 1;
}
Reply
#6

Quote:
Originally Posted by MacT
Посмотреть сообщение
In you GameModeInit you dont need foreach because it textdraw already showed for everyone.

pawn Код:
public OnGameModeInit()
{
    Stats[0] = (playerid,118.000000, 122.000000, "~l~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~N~~N~~N~~N~~N~~N~");
    PlayerTextDrawAlignment(playerid,Stats[0], 2);
    PlayerTextDrawBackgroundColor(playerid,Stats[0], 255);
    PlayerTextDrawFont(playerid,Stats[0], 1);
    PlayerTextDrawLetterSize(playerid,Stats[0], 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,Stats[0], -1);
    PlayerTextDrawSetOutline(playerid,Stats[0], 0);
    PlayerTextDrawSetProportional(playerid,Stats[0], 1);
    PlayerTextDrawSetShadow(playerid,Stats[0], 1);
    PlayerTextDrawUseBox(playerid,Stats[0], 1);
    PlayerTextDrawBoxColor(playerid,Stats[0], 110);
    PlayerTextDrawTextSize(playerid,Stats[0], -1.000000, 212.000000);
    PlayerTextDrawSetSelectable(playerid,Stats[0], 0);
    return 1;
    }

public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, Stats[0]);
return 1;
}
he need a foreach if he want to add it in ongamemodeinit

because playerid isnt defined in OnGameModeInit
Reply
#7

Quote:
Originally Posted by JFF
Посмотреть сообщение
he need a foreach if he want to add it in ongamemodeinit

because playerid isnt defined in OnGameModeInit
No he dont need loop it because it's already showed for everyone. I also maked this way my speedomeeter. But if really need foreach, I make for him when
Reply
#8

Quote:
Originally Posted by MacT
Посмотреть сообщение
No he dont need loop it because it's already showed for everyone. I also maked this way my speedomeeter. But if really need foreach, I make for him when
try to compile the code that u posted

u will get an error playerid is not defined
Reply
#9

JEFF is right but why the hell tag miss match here
pawn Код:
Settings[playerid][0] = CreatePlayerTextDraw(playerid,118.000000, 122.000000, "~l~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~");
pawn Код:
new Text:Settings[MAX_PLAYERS][6]; // is my define for it
Reply
#10

You need to use PlayerText: not Text:
pawn Код:
new PlayerText:Settings[MAX_PLAYERS][6];
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)