SA-MP Forums Archive
Stats textdraw mixing names and info - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Stats textdraw mixing names and info (/showthread.php?tid=447857)



Stats textdraw mixing names and info - _Khaled_ - 01.07.2013

pawn Код:
public OnPlayerUpdate(playerid)
{
    PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
    PlayerInfo[playerid][pScore] = GetPlayerScore(playerid);
    //Stats Command
    new string[128];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,MAX_PLAYER_NAME);
    format(string, sizeof (string), "%s", pname);
    TextDrawSetString(StTextdraw0,string);
    TextDrawShowForPlayer(playerid, StTextdraw0);
    format(string, sizeof (string), "Score: %d",PlayerInfo[playerid][pScore]);
    TextDrawSetString(StTextdraw2,string);
    TextDrawShowForPlayer(playerid, StTextdraw2);
    format(string, sizeof (string), "Kills: %d",PlayerInfo[playerid][pKills]);
    TextDrawSetString(StTextdraw3,string);
    TextDrawShowForPlayer(playerid, StTextdraw3);
    format(string, sizeof (string), "Deaths: %d",PlayerInfo[playerid][pDeaths]);
    TextDrawSetString(StTextdraw4,string);
    TextDrawShowForPlayer(playerid, StTextdraw4);
    //GetPlayerIP
    new pIPp[16];
    GetPlayerIp(playerid, pIPp, sizeof(pIPp));
    PlayerInfo[playerid][pIP] =pIPp;
    //Anti Armour Hack.
    new Float:armour;
    GetPlayerArmour(playerid, armour);
    if(armour >= 100)
    {
        if(PlayerInfo[playerid][pAdmin] < 10)
       {
         new pName[MAX_PLAYER_NAME];
         GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
         format(string,sizeof(string),"[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
         SendClientMessageToAll(COLOR_PINK,string);

         format(string,sizeof(string),"1[ANTI CHEAT] Anti-Cheat has banned %s(%d). [Reason: Cheats Detected]",pName,playerid);
         IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
         IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
       
         format(string, sizeof(string), "~r~BANNED!");
         GameTextForPlayer(playerid, string, 3000, 1);

         new INI:File = INI_Open(UserPath(playerid));
         INI_SetTag(File,"Player's Data");
         INI_WriteString(File,"BanReason","Cheats Detected");
         INI_Close(File);
         PlayerInfo[playerid][pBanned] =1;
       
         SetTimerEx("KickPlayer",1000,false,"i",playerid);
         return 1;
        }
    }
    if(!IsPlayerInRangeOfPoint(playerid, 3.0, 586.52, 870.34, -42.50) && TOZN1CP[playerid] == 1)
    {
       if(gTeam[playerid] != TEAM_MEDIC)
       {
         SendClientMessage(playerid, COLOR_RED, "[TAKE OVER FAILED] You have left the checkpoint, You have failed to capture the Nuclear Base.");
         GangZoneStopFlashForAll(NuclearZone1);
         SendClientMessageToAll(COLOR_RED, "[TAKE OVER FAILED] Nuclear Base was not taken over.");
         KillTimer(TONZ1Timer);
         TOZN1CP[playerid] = 0;
         NZTAKENOVER =0;
       }
    }
    if(NZ1FORGANG == 0 && NZ1FORARMY == 0)
    {
       GangZoneShowForAll(NuclearZone1,0xFF80C096);
       format(string, sizeof (string), "Nuclear: N");
       TextDrawSetString(StTextdraw5,string);
       TextDrawShowForPlayer(playerid, StTextdraw5);
    }
    if(NZ1FORARMY == 1 && NZ1FORGANG == 0)
    {
       GangZoneShowForAll(NuclearZone1,COLOR_GREEN);
       format(string, sizeof (string), "Nuclear: ARMY");
       TextDrawSetString(StTextdraw5,string);
       TextDrawShowForPlayer(playerid, StTextdraw5);
    }
    if(NZ1FORGANG == 1 && NZ1FORARMY == 0)
    {
       GangZoneShowForAll(NuclearZone1,COLOR_RED);
       format(string, sizeof (string), "Nuclear: GANG");
       TextDrawSetString(StTextdraw5,string);
       TextDrawShowForPlayer(playerid, StTextdraw5);
    }
    if(InAdminMode[playerid] == 1)
    {
       SetPlayerColor(playerid,COLOR_PINK);
       GivePlayerWeapon(playerid,38,999999);
       SetPlayerHealth(playerid,999999);
       SetPlayerArmour(playerid,999999);
    }
    if(gTeam[playerid] == TEAM_MEDIC)
    {
        format(string, sizeof (string), "Rank: Medic");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
    }

    //Team_GREEN
    if(gTeam[playerid] == TEAM_GREEN)
    {
      if(GetPlayerScore(playerid) >= 1500)
      {
        IsGeneral[playerid] =1;
        format(string, sizeof (string), "Rank: General");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 1000)
      {
        IsColonel[playerid] =1;
        format(string, sizeof (string), "Rank: Colonel");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 800)
      {
        IsCaptain[playerid] =1;
        format(string, sizeof (string), "Rank: Captain");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 600)
      {
        IsSpecops[playerid] =1;
        format(string, sizeof (string), "Rank: Spec-ops");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 400)
      {
        IsMajor[playerid] =1;
        format(string, sizeof (string), "Rank: Major");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 250)
      {
        IsLieutenant[playerid] =1;
        format(string, sizeof (string), "Rank:Lieutenant");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 150)
      {
        IsSoldier[playerid] =1;
        format(string, sizeof (string), "Rank: Soldier");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 100)
      {
         IsPrivateFC[playerid] =1;
         format(string, sizeof (string), "Rank: PrivateFC");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
         return 1;
      }
      if(GetPlayerScore(playerid) >= 50)
      {
        IsPrivate[playerid] =1;
        format(string, sizeof (string), "Rank: Private");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) < 50)
      {
        IsNewbie[playerid] =1;
        format(string, sizeof (string), "Rank: Newbie");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
    }
   
    //Team_RED
    if(gTeam[playerid] == TEAM_RED)
    {
      if(GetPlayerScore(playerid) >= 1500)
      {
        IsGodFather[playerid] =1;
         format(string, sizeof (string), "Rank:GodFather");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 1000)
      {
        IsGodFatherBodyGuard[playerid] =1;
         format(string, sizeof (string), "Rank:Bodyguard");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 800)
      {
        IsLeader[playerid] =1;
         format(string, sizeof (string), "Rank: Leader");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 600)
      {
        IsCoLeader[playerid] =1;
         format(string, sizeof (string), "Rank: CoLeader");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 400)
      {
        IsTripleOriginalGangster[playerid] =1;
         format(string, sizeof (string), "Rank: Triple O");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 250)
      {
        IsDoubleOriginalGangster[playerid] =1;
         format(string, sizeof (string), "Rank: Double O");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 150)
      {
        IsOriginalGangster[playerid] =1;
         format(string, sizeof (string), "Rank: OriginalO");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 100)
      {
        IsOriginalBabyGangster[playerid] =1;
         format(string, sizeof (string), "Rank: OriginalB");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) >= 50)
      {
        IsBabyGangster[playerid] =1;
        format(string, sizeof (string), "Rank: Baby G");
        TextDrawSetString(StTextdraw1,string);
        TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
      if(GetPlayerScore(playerid) < 50)
      {
        IsTinyGangster[playerid] =1;
         format(string, sizeof (string), "Rank: Tiny G");
         TextDrawSetString(StTextdraw1,string);
         TextDrawShowForPlayer(playerid, StTextdraw1);
        return 1;
      }
    }
    return 1;
}
Thats all, It exchanges names ingame, switching my name with another player and keep on mixing names and info

anyone?


Re: Stats textdraw mixing names and info - arakuta - 01.07.2013

Because this is a global textdraw, it's the same for everyone.
If you wanna a per-player textdraw see this:

https://sampwiki.blast.hk/wiki/Textdraw#Per-Player_Textdraw


Re: Stats textdraw mixing names and info - DobbysGamertag - 01.07.2013

pawn Код:
new TextDrawName[MAX_PLAYERS]; //outside functions near includes.

//then where you need it (obviously change TextDrawName to what your TD's are.

TextDrawShowForPlayer(playerid,TextDrawName[playerid]);
That fixed an issue i had doing it that way. It was giving me ID 0's mission text instead of my own.


Re: Stats textdraw mixing names and info - _Khaled_ - 01.07.2013

didn't get iit so much, someone explain more please


Re: Stats textdraw mixing names and info - arakuta - 01.07.2013

A Global textdraw is just one, if you change it string, everybody will se the change (if the textdraw is shown, of course).

But with per-player textdraw it will not happen, because everyplayer has it own text:

See a example:

pawn Код:
new PlayerText:mytext[MAX_PLAYERS];
// creates a variable to store the per-player variable ID
Then, lets create it!

pawn Код:
public OnPlayerConnect(playerid)
{
    mytext[playerid] = CreatePlayerTextDraw(playerid,320,240,"Text 8D");
    PlayerTextDrawFont(playerid,hits[playerid],1);
    PlayerTextDrawLetterSize(playerid,hits[playerid],0.230000, 1.000000);
    // Other TextDraw configs...
    // Now show him his textdraw
    ShowPlayerTextDraw(playerid,mytext[playerid]);
Okay, now we have a textdraw, no lets update it with some infos:

pawn Код:
new iText[40];
format(iText,40,"Killed: %d",PlayerInfo[playerid][pKills]);
PlayerTextDrawSetString(playerid,mytext[playerid],iText);
See how easy and functional it is?


Re: Stats textdraw mixing names and info - _Khaled_ - 02.07.2013

Okay guys
pawn Код:
new StShowing[MAX_PLAYERS];
new PlayerText:StTextdraw0;
new PlayerText:StTextdraw1;
new PlayerText:StTextdraw2;
new PlayerText:StTextdraw3;
new PlayerText:StTextdraw4;
new PlayerText:StTextdraw5;
new PlayerText:StTextdraw6;
//========================================//
under OnPlayerConnect
//Stats Texts
    StShowing[playerid] =0;
   
    StTextdraw0 = CreatePlayerTextDraw(playerid,500.000000, 296.000000, "__");
    PlayerTextDrawBackgroundColor(playerid,StTextdraw0, 255);
    PlayerTextDrawFont(Stplayerid,Textdraw0, 1);
    PlayerTextDrawLetterSize(playerid,StTextdraw0, 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,StTextdraw0, -1);
    PlayerTextDrawSetOutline(playerid,StTextdraw0, 0);
    PlayerTextDrawSetProportional(playerid,StTextdraw0, 1);
    PlayerTextDrawSetShadow(playerid,StTextdraw0, 1);
    PlayerTextDrawUseBox(playerid,StTextdraw0, 1);
    PlayerTextDrawBoxColor(playerid,StTextdraw0, 102);
    PlayerTextDrawTextSize(playerid,StTextdraw0, 629.000000, 68.000000);
    PlayerTextDrawSetSelectable(playerid,StTextdraw0, 0);

    StTextdraw1 = CreatePlayerTextDraw(playerid,500.000000, 309.000000, "Rank:");
    PlayerTextDrawBackgroundColor(playerid,StTextdraw1, 255);
    PlayerTextDrawFont(playerid,StTextdraw1, 1);
    PlayerTextDrawLetterSize(playerid,StTextdraw1, 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,StTextdraw1, -1);
    PlayerTextDrawSetOutline(playerid,StTextdraw1, 0);
    PlayerTextDrawSetProportional(playerid,StTextdraw1, 1);
    PlayerTextDrawSetShadow(playerid,StTextdraw1, 1);
    PlayerTextDrawUseBox(playerid,StTextdraw1, 1);
    PlayerTextDrawBoxColor(playerid,StTextdraw1, 102);
    PlayerTextDrawTextSize(playerid,StTextdraw1, 629.000000, 0.000000);
    PlayerTextDrawSetSelectable(playerid,StTextdraw1, 0);

    StTextdraw2 = CreatePlayerTextDraw(playerid,500.000000, 323.000000, "Score:");
    PlayerTextDrawBackgroundColor(playerid,StTextdraw2, 255);
    PlayerTextDrawFont(playerid,StTextdraw2, 1);
    PlayerTextDrawLetterSize(playerid,StTextdraw2, 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,StTextdraw2, -1);
    PlayerTextDrawSetOutline(playerid,StTextdraw2, 0);
    PlayerTextDrawSetProportional(playerid,StTextdraw2, 1);
    PlayerTextDrawSetShadow(playerid,StTextdraw2, 1);
    PlayerTextDrawUseBox(playerid,StTextdraw2, 1);
    PlayerTextDrawBoxColor(playerid,StTextdraw2, 102);
    PlayerTextDrawTextSize(playerid,StTextdraw2, 629.000000, 0.000000);
    PlayerTextDrawSetSelectable(playerid,StTextdraw2, 0);

    StTextdraw3 = CreatePlayerTextDraw(playerid,500.000000, 337.000000, "Kills:");
    PlayerTextDrawBackgroundColor(playerid,StTextdraw3, 255);
    PlayerTextDrawFont(playerid,StTextdraw3, 1);
    PlayerTextDrawLetterSize(playerid,StTextdraw3, 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,StTextdraw3, -1);
    PlayerTextDrawSetOutline(playerid,StTextdraw3, 0);
    PlayerTextDrawSetProportional(playerid,StTextdraw3, 1);
    PlayerTextDrawSetShadow(playerid,StTextdraw3, 1);
    PlayerTextDrawUseBox(playerid,StTextdraw3, 1);
    PlayerTextDrawBoxColor(playerid,StTextdraw3, 102);
    PlayerTextDrawTextSize(playerid,StTextdraw3, 629.000000, 0.000000);
    PlayerTextDrawSetSelectable(playerid,StTextdraw3, 0);

    StTextdraw4 = CreatePlayerTextDraw(playerid,500.000000, 351.000000, "Deaths:");
    PlayerTextDrawBackgroundColor(playerid,StTextdraw4, 255);
    PlayerTextDrawFont(playerid,StTextdraw4, 1);
    PlayerTextDrawLetterSize(playerid,StTextdraw4, 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,StTextdraw4, -1);
    PlayerTextDrawSetOutline(playerid,StTextdraw4, 0);
    PlayerTextDrawSetProportional(playerid,StTextdraw4, 1);
    PlayerTextDrawSetShadow(playerid,StTextdraw4, 1);
    PlayerTextDrawUseBox(playerid,StTextdraw4, 1);
    PlayerTextDrawBoxColor(playerid,StTextdraw4, 102);
    PlayerTextDrawTextSize(playerid,StTextdraw4, 629.000000, 0.000000);
    PlayerTextDrawSetSelectable(playerid,StTextdraw4, 0);

    StTextdraw5 = CreatePlayerTextDraw(playerid,500.000000, 365.000000, "Nuclear 1:");
    PlayerTextDrawBackgroundColor(playerid,StTextdraw5, 255);
    PlayerTextDrawFont(playerid,StTextdraw5, 1);
    PlayerTextDrawLetterSize(playerid,StTextdraw5, 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,StTextdraw5, -1);
    PlayerTextDrawSetOutline(playerid,StTextdraw5, 0);
    PlayerTextDrawSetProportional(playerid,StTextdraw5, 1);
    PlayerTextDrawSetShadow(playerid,StTextdraw5, 1);
    PlayerTextDrawUseBox(playerid,StTextdraw5, 1);
    PlayerTextDrawBoxColor(playerid,StTextdraw5, 102);
    PlayerTextDrawTextSize(playerid,StTextdraw5, 629.000000, 0.000000);
    PlayerTextDrawSetSelectable(playerid,StTextdraw5, 0);

    StTextdraw6 = CreatePlayerTextDraw(playerid,500.000000, 379.000000, "Vehicle:");
    PlayerTextDrawBackgroundColor(playerid,StTextdraw6, 255);
    PlayerTextDrawFont(playerid,StTextdraw6, 1);
    PlayerTextDrawLetterSize(playerid,StTextdraw6, 0.500000, 1.000000);
    PlayerTextDrawColor(playerid,StTextdraw6, -1);
    PlayerTextDrawSetOutline(playerid,StTextdraw6, 0);
    PlayerTextDrawSetProportional(playerid,StTextdraw6, 1);
    PlayerTextDrawSetShadow(playerid,StTextdraw6, 1);
    PlayerTextDrawUseBox(playerid,StTextdraw6, 1);
    PlayerTextDrawBoxColor(playerid,StTextdraw6, 102);
    PlayerTextDrawTextSize(playerid,StTextdraw6, 629.000000, 0.000000);
    PlayerTextDrawSetSelectable(playerid,StTextdraw6, 0);
//====================================================================//
under OnPlayerUpdate
new string[128];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,MAX_PLAYER_NAME);

    format(string,40,"%s", pname);
    PlayerTextDrawSetString(playerid,StTextdraw0[playerid],string); //error line 1994
   
    format(string,40,"Score: %d",PlayerInfo[playerid][pScore]);
    PlayerTextDrawSetString(playerid,StTextdraw2[playerid],string);

    format(string,40,"Kills: %d",PlayerInfo[playerid][pKills]);
    PlayerTextDrawSetString(playerid,StTextdraw3[playerid],string);

    format(string,40,"Deaths: %d",PlayerInfo[playerid][pDeaths]);
    PlayerTextDrawSetString(playerid,StTextdraw4[playerid],string);

    format(string,40,"Vehicle:");
    PlayerTextDrawSetString(playerid,StTextdraw6[playerid],string);
//============================================================//
under OnPlayerSpawn
if(StShowing[playerid] == 1)
    {
            StShowing[playerid] = 0;
            PlayerTextDrawShow(playerid, StTextdraw0);
            PlayerTextDrawShow(playerid, StTextdraw1);
            PlayerTextDrawShow(playerid, StTextdraw2);
            PlayerTextDrawShow(playerid, StTextdraw3);
            PlayerTextDrawShow(playerid, StTextdraw4);
            PlayerTextDrawShow(playerid, StTextdraw5);
            PlayerTextDrawShow(playerid, StTextdraw6);
    }
    else
    {
            StShowing[playerid] = 1;
            PlayerTextDrawHide(playerid, StTextdraw0);
            PlayerTextDrawHide(playerid, StTextdraw1);
            PlayerTextDrawHide(playerid, StTextdraw2);
            PlayerTextDrawHide(playerid, StTextdraw3);
            PlayerTextDrawHide(playerid, StTextdraw4);
            PlayerTextDrawHide(playerid, StTextdraw5);
            PlayerTextDrawHide(playerid, StTextdraw6);
    }
//========================================================//
OnPlayerDis
StShowing =0;
    PlayerTextDrawDestroy(playerid, StTextdraw0);
    PlayerTextDrawDestroy(playerid, StTextdraw1);
    PlayerTextDrawDestroy(playerid, StTextdraw2);
    PlayerTextDrawDestroy(playerid, StTextdraw3);
    PlayerTextDrawDestroy(playerid, StTextdraw4);
    PlayerTextDrawDestroy(playerid, StTextdraw5);
    PlayerTextDrawDestroy(playerid, StTextdraw6);
Код:
E:\The Real Deathmatch\The Real Deathmatch v0.2\pawno\include\sscanf2.inc(227) : error 017: undefined symbol "SSCANF_OnPlayerDisconnect"
E:\The Real Deathmatch\The Real Deathmatch v0.2\gamemodes\TRDv0.2.pwn(1994) : error 028: invalid subscript (not an array or too many subscripts): "StTextdraw0"
E:\The Real Deathmatch\The Real Deathmatch v0.2\gamemodes\TRDv0.2.pwn(1994) : warning 215: expression has no effect
E:\The Real Deathmatch\The Real Deathmatch v0.2\gamemodes\TRDv0.2.pwn(1994) : error 001: expected token: ";", but found "]"
E:\The Real Deathmatch\The Real Deathmatch v0.2\gamemodes\TRDv0.2.pwn(1994) : error 029: invalid expression, assumed zero
E:\The Real Deathmatch\The Real Deathmatch v0.2\gamemodes\TRDv0.2.pwn(1994) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
I did abst. nothing to sscanf2, I don't why it gave these errors, anyone?