Stats in textdraws - targetid help
#1

Hi all, I'm making player statistics in textraws, and it's going very well, but there is a bug.

When I typed my command to show stats (/account profile) it show stats normally, but when other player type /account profile I'm watching his stats. I changed targetid with playerid because it show me error: undefined targetid.
Please help.



Код:
        TextDrawShowForPlayer(playerid, StatsTacke);
        format(string,sizeof string,"---------------------");
        TextDrawSetString(StatsTacke,string);

        TextDrawShowForPlayer(playerid, StatsLevel);
        format(string,sizeof string,"LEVEL: %d",PlayerInfo[playerid][pLevel]);
        TextDrawSetString(StatsLevel,string);

        TextDrawShowForPlayer(playerid, StatsRespekti);
        new nxtlevel = PlayerInfo[playerid][pLevel]+1;
        new expamount = nxtlevel*levelexp;
        format(string,sizeof string,"RESPEKTI: %d/%d",PlayerInfo[playerid][pExp], expamount);
        TextDrawSetString(StatsRespekti,string);

        TextDrawShowForPlayer(playerid, StatsDoRespekta);
        format(string,sizeof string,"DO RESPEKTA: %d/60", PlayerInfo[playerid][pMinutePayDay]);
        TextDrawSetString(StatsDoRespekta,string);

        TextDrawShowForPlayer(playerid, StatsNovac);
        format(string,sizeof string,"NOVAC: %d$", PlayerInfo[playerid][pCash]);
        TextDrawSetString(StatsNovac,string);

        TextDrawShowForPlayer(playerid, StatsBanka);
        format(string,sizeof string,"BANKA: %d$", PlayerInfo[playerid][pAccount]);
        TextDrawSetString(StatsBanka,string);

        TextDrawShowForPlayer(playerid, StatsOrg);
        format(string,sizeof string,"ORG: %d", PlayerInfo[playerid][pMember]);
        TextDrawSetString(StatsOrg,string);
Reply
#2

Show me your /account command
Reply
#3

Код:
if(strcmp(cmd, "/account", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new trolol[256];
trolol = strtok(cmdtext, idx);

if(!strlen(trolol))
{
SendClientMessage(playerid, COLOR_DGOLD,"KORISTI: /account [profile/password]");
return 1;
}

if(strcmp(trolol,"profile",true) == 0)
{
        TextDrawShowForPlayer(playerid, StatsTacke);
        format(string,sizeof string,"---------------------");
        TextDrawSetString(StatsTacke,string);

        TextDrawShowForPlayer(playerid, StatsLevel);
        format(string,sizeof string,"LEVEL: %d",PlayerInfo[playerid][pLevel]);
        TextDrawSetString(StatsLevel,string);

        TextDrawShowForPlayer(playerid, StatsRespekti);
        new nxtlevel = PlayerInfo[playerid][pLevel]+1;
        new expamount = nxtlevel*levelexp;
        format(string,sizeof string,"RESPEKTI: %d/%d",PlayerInfo[playerid][pExp], expamount);
        TextDrawSetString(StatsRespekti,string);

        TextDrawShowForPlayer(playerid, StatsDoRespekta);
        format(string,sizeof string,"DO RESPEKTA: %d/60", PlayerInfo[playerid][pMinutePayDay]);
        TextDrawSetString(StatsDoRespekta,string);

        TextDrawShowForPlayer(playerid, StatsNovac);
        format(string,sizeof string,"NOVAC: %d$", PlayerInfo[playerid][pCash]);
        TextDrawSetString(StatsNovac,string);

        TextDrawShowForPlayer(playerid, StatsBanka);
        format(string,sizeof string,"BANKA: %d$", PlayerInfo[playerid][pAccount]);
        TextDrawSetString(StatsBanka,string);

        TextDrawShowForPlayer(playerid, StatsOrg);
        format(string,sizeof string,"ORG: %d", PlayerInfo[playerid][pMember]);
        TextDrawSetString(StatsOrg,string);
}
}
return 1;
}
You can see, there is playerid.
Reply
#4

If I understood well, once other player uses the comand you see his/her stats?
Reply
#5

Jeste, vidim da si iz hrvatske, ali pricat cu engleski radi pravila xd.

When I typed /account profile I see my stats, but when someone else type /account profile I see his/her stats.
Reply
#6

Try this:

Код:
if (strcmp (cmdtext, "/account", true) == 0)
{
if (IsPlayerConnected (playerid))
{
TextDrawShowForPlayer(playerid, StatsTacke);
        format(string,sizeof string,"---------------------");
        TextDrawSetString(StatsTacke,string);

        TextDrawShowForPlayer(playerid, StatsLevel);
        format(string,sizeof string,"LEVEL: %d",PlayerInfo[playerid][pLevel]);
        TextDrawSetString(StatsLevel,string);

        TextDrawShowForPlayer(playerid, StatsRespekti);
        new nxtlevel = PlayerInfo[playerid][pLevel]+1;
        new expamount = nxtlevel*levelexp;
        format(string,sizeof string,"RESPEKTI: %d/%d",PlayerInfo[playerid][pExp], expamount);
        TextDrawSetString(StatsRespekti,string);

        TextDrawShowForPlayer(playerid, StatsDoRespekta);
        format(string,sizeof string,"DO RESPEKTA: %d/60", PlayerInfo[playerid][pMinutePayDay]);
        TextDrawSetString(StatsDoRespekta,string);

        TextDrawShowForPlayer(playerid, StatsNovac);
        format(string,sizeof string,"NOVAC: %d$", PlayerInfo[playerid][pCash]);
        TextDrawSetString(StatsNovac,string);

        TextDrawShowForPlayer(playerid, StatsBanka);
        format(string,sizeof string,"BANKA: %d$", PlayerInfo[playerid][pAccount]);
        TextDrawSetString(StatsBanka,string);

        TextDrawShowForPlayer(playerid, StatsOrg);
        format(string,sizeof string,"ORG: %d", PlayerInfo[playerid][pMember]);
        TextDrawSetString(StatsOrg,string);
}
return true;
}
Reply
#7

I used DCMD & SSCANF to make this command.
pawn Код:
dcmd_stats(playerid, params[])
{
    new profilepass[6];
    if(sscanf(params,"s[6]", profilepass)) {
        SendClientMessage(playerid, COLOR_GRAD2, "[{EE5555}USAGE{FFFFFF}]: /stats [profile/password]");
        return 1;
    }
    if(strcmp(params,"profile",true) == 0) {
        TextDrawShowForPlayer(playerid, StatsTacke);
        format(string,sizeof string,"---------------------");
        TextDrawSetString(StatsTacke,string);

        TextDrawShowForPlayer(playerid, StatsLevel);
        format(string,sizeof string,"LEVEL: %d",PlayerInfo[playerid][pLevel]);
        TextDrawSetString(StatsLevel,string);

        TextDrawShowForPlayer(playerid, StatsRespekti);
        new nxtlevel = PlayerInfo[playerid][pLevel]+1;
        new expamount = nxtlevel*levelexp;
        format(string,sizeof string,"RESPEKTI: %d/%d",PlayerInfo[playerid][pExp], expamount);
        TextDrawSetString(StatsRespekti,string);

        TextDrawShowForPlayer(playerid, StatsDoRespekta);
        format(string,sizeof string,"DO RESPEKTA: %d/60", PlayerInfo[playerid][pMinutePayDay]);
        TextDrawSetString(StatsDoRespekta,string);

        TextDrawShowForPlayer(playerid, StatsNovac);
        format(string,sizeof string,"NOVAC: %d$", PlayerInfo[playerid][pCash]);
        TextDrawSetString(StatsNovac,string);

        TextDrawShowForPlayer(playerid, StatsBanka);
        format(string,sizeof string,"BANKA: %d$", PlayerInfo[playerid][pAccount]);
        TextDrawSetString(StatsBanka,string);

        TextDrawShowForPlayer(playerid, StatsOrg);
        format(string,sizeof string,"ORG: %d", PlayerInfo[playerid][pMember]);
        TextDrawSetString(StatsOrg,string);

    }
    return 1;
}
Reply
#8

Won't work, again it show me stats of another player.
When I type it, show me my statistics, but when somebody else type command I see his/her stats.
Reply
#9

BUMP*
Reply
#10

How do you hide textdraws, once you have shown them? Example: if I type /account profile i will see my stats, but somehow I need to move them away from my screen.

Solution: Use PlayerTextDraws if the textdraw with same name(variable) is different for each player. Normal TextDraws use only if they are same for each player( for example: Website of your forum ).

OFF TOPIC: Pozdrav brate
Reply
#11

https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw ??

I hide them by pressing KEY_FIRE, which I made already
Reply
#12

You have to create a textdraw for each player!

For ex:
pawn Код:
new StatsLevel[MAX_PLAYERS];

    StatsLevel[playerid] = TextDrawCreate(440.000000,388.000000, " ");
    TextDrawAlignment(StatsLevel[playerid], 2);
    TextDrawBackgroundColor(StatsLevel[playerid], 255);
    TextDrawFont(StatsLevel[playerid], 2);
    TextDrawLetterSize(StatsLevel[playerid], 0.160000, 0.599999);
    TextDrawColor(StatsLevel[playerid], 0xE81010FF);
    TextDrawSetOutline(StatsLevel[playerid], 1);
    TextDrawSetProportional(StatsLevel[playerid], 1);


    TextDrawShowForPlayer(playerid, StatsLevel[playerid]);
    format(string, sizeof string, "LEVEL: %d", PlayerInfo[playerid][pLevel]);
    TextDrawSetString(StatsLevel[playerid], string);
Reply
#13

It gave me error:

I already defined

new Text:StatsLevel
Reply
#14

...edit that thing into EDIT::
pawn Код:
new Text:StatsLevel[MAX_PLAYERS]; // my fault
All your TD;s
Reply
#15

Won't work, Now it show me another textdraw (some time Textdraw), what to do now ?
Reply
#16

Quote:
Originally Posted by Anonym2009
Посмотреть сообщение
You have to create a textdraw for each player!

For ex:
pawn Код:
new StatsLevel[MAX_PLAYERS];

    StatsLevel[playerid] = TextDrawCreate(440.000000,388.000000, " ");
    TextDrawAlignment(StatsLevel[playerid], 2);
    TextDrawBackgroundColor(StatsLevel[playerid], 255);
    TextDrawFont(StatsLevel[playerid], 2);
    TextDrawLetterSize(StatsLevel[playerid], 0.160000, 0.599999);
    TextDrawColor(StatsLevel[playerid], 0xE81010FF);
    TextDrawSetOutline(StatsLevel[playerid], 1);
    TextDrawSetProportional(StatsLevel[playerid], 1);


    TextDrawShowForPlayer(playerid, StatsLevel[playerid]);
    format(string, sizeof string, "LEVEL: %d", PlayerInfo[playerid][pLevel]);
    TextDrawSetString(StatsLevel[playerid], string);
No, no, no. Don't do this. There is a limit of 2048 TextDraws. If you do this way, you will lose 500 of them, and that's 1/4 of the maximum.
Use PlayerTextdraws. They are made for this reason!
Reply
#17

Can you do this for me, just as example:


Here is what I done:


Код:
new Text:StatsLevel;


        TextDrawShowForPlayer(playerid, StatsLevel);
        format(string,sizeof string,"LEVEL: %d",PlayerInfo[targetid][pLevel]);
        TextDrawSetString(StatsLevel,string);

	format(cordsstring, sizeof(cordsstring),"LEVEL: %d", PlayerInfo[playerid][pLevel]);
	StatsLevel = TextDrawCreate(16 ,205, cordsstring);
	TextDrawAlignment(StatsLevel,1);
	TextDrawFont(StatsLevel,2);
	TextDrawLetterSize(StatsLevel,0.22, 1.0);
	TextDrawColor(StatsLevel,0xffffffFF);
	TextDrawSetOutline(StatsLevel,1);
	TextDrawSetProportional(StatsLevel,1);
	TextDrawSetShadow(StatsLevel,1);


 if(PRESSED(KEY_FIRE))
	{
TextDrawHideForPlayer(playerid, StatsLevel);
	}
Reply
#18

Quote:
Originally Posted by Saddin
Посмотреть сообщение
Can you do this for me, just as example:


Here is what I done:


Код:
new Text:StatsLevel;


        TextDrawShowForPlayer(playerid, StatsLevel);
        format(string,sizeof string,"LEVEL: %d",PlayerInfo[targetid][pLevel]);
        TextDrawSetString(StatsLevel,string);

	format(cordsstring, sizeof(cordsstring),"LEVEL: %d", PlayerInfo[playerid][pLevel]);
	StatsLevel = TextDrawCreate(16 ,205, cordsstring);
	TextDrawAlignment(StatsLevel,1);
	TextDrawFont(StatsLevel,2);
	TextDrawLetterSize(StatsLevel,0.22, 1.0);
	TextDrawColor(StatsLevel,0xffffffFF);
	TextDrawSetOutline(StatsLevel,1);
	TextDrawSetProportional(StatsLevel,1);
	TextDrawSetShadow(StatsLevel,1);


 if(PRESSED(KEY_FIRE))
	{
TextDrawHideForPlayer(playerid, StatsLevel);
	}
I will do it for you in about 3 hours. Now going to sea.
Reply
#19

Thanks man, I appreciate that
Reply
#20

pawn Код:
//top of the script
new PlayerText:StatsTacke[MAX_PLAYERS];
new PlayerText:StatsLevel[MAX_PLAYERS];
new PlayerText:StatsRespekti[MAX_PLAYERS];
new PlayerText:StatsDoRespekta[MAX_PLAYERS];
new PlayerText:StatsNovac[MAX_PLAYERS];
new PlayerText:StatsBanka[MAX_PLAYERS];
new PlayerText:StatsOrg[MAX_PLAYERS];

//OnPlayerCommandText
if(!strcmp(cmd, "/account", true,8))
{
    if(!IsPlayerConnected(playerid))return 1;
    if(cmd[8]!=' ')SendClientMessage(playerid, COLOR_DGOLD,"KORISTI: /account [profile/password]"),return 1;
    new str[20];
    strcat(str,cmd[9]);
    if(!strlen(str))SendClientMessage(playerid, COLOR_DGOLD,"KORISTI: /account [profile/password]"),return 1;
    if(strcmp(str,"profile",true) == 0)
    {
        PlayerTextDrawSetString(playerid,StatsTacke[playerid],"---------------------");
        PlayerTextDrawShow(playerid, StatsTacke[playerid]);

        format(string,sizeof string,"LEVEL: %d",PlayerInfo[playerid][pLevel]);
        PlayerTextDrawSetString(StatsLevel[playerid],string);
        PlayerTextDrawShow(playerid, StatsLevel[playerid]);

        new nxtlevel = PlayerInfo[playerid][pLevel]+1;
        new expamount = nxtlevel*levelexp;
        format(string,sizeof string,"RESPEKTI: %d/%d",PlayerInfo[playerid][pExp], expamount);
        PlayerTextDrawSetString(StatsRespekti[playerid],string);
        PlayerTextDrawShow(playerid, StatsRespekti[playerid]);

        format(string,sizeof string,"DO RESPEKTA: %d/60", PlayerInfo[playerid][pMinutePayDay]);
        PlayerTextDrawSetString(StatsDoRespekta[playerid],string);
        PlayerTextDrawShow(playerid, StatsDoRespekta[playerid]);

        format(string,sizeof string,"NOVAC: %d$", PlayerInfo[playerid][pCash]);
        PlayerTextDrawSetString(StatsNovac[playerid],string);
        PlayerTextDrawShow(playerid, StatsNovac[playerid]);

        format(string,sizeof string,"BANKA: %d$", PlayerInfo[playerid][pAccount]);
        PlayerTextDrawSetString(StatsBanka[playerid],string);
        PlayerTextDrawShow(playerid, StatsBanka[playerid]);
       
        format(string,sizeof string,"ORG: %d", PlayerInfo[playerid][pMember]);
        PlayerTextDrawSetString(StatsOrg[playerid],string);
        PlayerTextDrawShow(playerid, StatsOrg[playerid]);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)