Textdraw
#1

I want that you can see your score in the textdraw, and it will update if you get a higher score.
Reply
#2

pawn Код:
public OnGameModeInit()
{
  SetTimer("Update", 5000, true);
  return 1;
}
forward Update();
public Update()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(!IsPlayerConnected(i)) continue;
    TextDrawSetString(/*Your textdraw here*/, GetPlayerScore(i));
  }
}
Reply
#3

That is a bad way to do it. You should hook SetPlayerScore.
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
That is a bad way to do it. You should hook SetPlayerScore.
was only a guide for him
Reply
#5

Quote:
Originally Posted by (*|Flake|*)
Посмотреть сообщение
pawn Код:
public OnGameModeInit()
{
  SetTimer("Update", 5000, true);
  return 1;
}
forward Update();
public Update()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(!IsPlayerConnected(i)) continue;
    TextDrawSetString(/*Your textdraw here*/, GetPlayerScore(i));
  }
}
Код:
C:\Users\Magdy\Desktop\Server 3.0e\filterscripts\d.pwn(286) : error 035: argument type mismatch (argument 2)
Line 286:
pawn Код:
TextDrawSetString(Score, GetPlayerScore(i));
Reply
#6

Quote:
Originally Posted by MechaTech
Посмотреть сообщение
Код:
C:\Users\Magdy\Desktop\Server 3.0e\filterscripts\d.pwn(286) : error 035: argument type mismatch (argument 2)
Line 286:
pawn Код:
TextDrawSetString(Score, GetPlayerScore(i));
pawn Код:
TextDrawSetString(/*Your textdraw here*/, GetPlayerScore(i));
you need to add your textdraw there, like the cords for it and everything...
Reply
#7

Hook the function:

pawn Код:
stock h_SetPlayerScore(playerid, score)
{
    SetPlayerScore(playerid, score);

    // Textdraw code here
    new tdstring[24];
    format(tdstring, sizeof(tdstring), "Score: ~Y~%i", score);
    PlayerTextDrawSetString(playerid, TD_pScore[playerid], tdstring);
    return 1;
}

#if defined _ALS_SetPlayerScore
    #undef SetPlayerScore
#else
    #define _ALS_SetPlayerScore
#endif
#define SetPlayerScore h_SetPlayerScore
Put that code UNDER the includes, but BEFORE any callbacks or functions.

You need to CREATE THE PLAYER-TEXTDRAW.

https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw
Reply
#8

Quote:
Originally Posted by MP2
Посмотреть сообщение
Hook the function:

pawn Код:
stock h_SetPlayerScore(playerid, score)
{
    SetPlayerScore(playerid, score);

    // Textdraw code here
    new tdstring[24];
    format(tdstring, sizeof(tdstring), "Score: ~Y~%i", score);
    PlayerTextDrawSetString(playerid, TD_pScore[playerid], tdstring);
    return 1;
}

#if defined _ALS_SetPlayerScore
    #undef SetPlayerScore
#else
    #define _ALS_SetPlayerScore
#endif
#define SetPlayerScore h_SetPlayerScore
Put that code UNDER the includes, but BEFORE any callbacks or functions.

You need to CREATE THE PLAYER-TEXTDRAW.

https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw
I tried that and it gives no errors, but if i check on the server i dont see the score textdraw

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xF30000AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_LIGHTBLUE 0x00D0F6AA
#define COLOR_WHITE 0xF6F6F6AA
#define COLOR_PURPLE 0xA600F6AA
#define COLOR_TUT 0xF6C861AA
#define COLOR_ROYAL 0x00C1F6AA
#define COLOR_CWHITE 0xE0FFFFAA

#define PRIVATE 0
#define CORPORAL 1
#define SERGENTEANT 2
#define CAPTAIN 3
#define BRIGADIER 4
#define GENERAL 5

new Text:Private;
new Text:Corporal;
new Text:Sergenteant;
new Text:Captain;
new Text:Brigadier;
new Text:General;
new Text:Score;

new PlayerLogged[MAX_PLAYERS];
new Rank[MAX_PLAYERS];

stock h_SetPlayerScore(playerid, score)
{
    SetPlayerScore(playerid, score);

    Score = TextDrawCreate(496.000000, 128.000000, "Score: ");
    TextDrawBackgroundColor(Score, 255);
    TextDrawFont(Score, 1);
    TextDrawLetterSize(Score, 0.440000, 1.500000);
    TextDrawColor(Score, 16711935);
    TextDrawSetOutline(Score, 1);
    TextDrawSetProportional(Score, 1);
    new tdstring[24];
    format(tdstring, sizeof(tdstring), "Score: ~Y~%i", score);
    PlayerTextDrawSetString(playerid, TD_pScore[playerid], tdstring);
    return 1;
}

#if defined _ALS_SetPlayerScore
    #undef SetPlayerScore
#else
    #define _ALS_SetPlayerScore
#endif
#define SetPlayerScore h_SetPlayerScore
Reply
#9

You need to create it under OnPlayerConnect and destroy it under OnPlayerDisconnect. Use PLAYER textdraws.
Reply
#10

Quote:
Originally Posted by MP2
Посмотреть сообщение
You need to create it under OnPlayerConnect and destroy it under OnPlayerDisconnect. Use PLAYER textdraws.
Thanks it worked.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)