Score dosen't show?
#1

Код:
/*
	Basic Player Stats. Shows Score and Ping in a textdraw.
	Credits - iPLEOMAX
 		      [HK]Ryder[AN]
 		      SA:MP Team
*/
#include <a_samp>
new updatetimer[MAX_PLAYERS];
//Player Textdraws:
new PlayerText:Textdraw0[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
new PlayerText:Textdraw1[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
forward update(playerid);
public OnPlayerConnect(playerid)
{
	Textdraw0[playerid] = CreatePlayerTextDraw(playerid, 498.398, 100.799, "Score - -=-");
	PlayerTextDrawAlignment(playerid, Textdraw0[playerid], 1);
	PlayerTextDrawColor(playerid, Textdraw0[playerid], -1);
	PlayerTextDrawSetOutline(playerid, Textdraw0[playerid], 1);
	PlayerTextDrawBackgroundColor(playerid, Textdraw0[playerid], 51);
	PlayerTextDrawFont(playerid, Textdraw0[playerid], 2);
	PlayerTextDrawSetProportional(playerid, Textdraw0[playerid], 1);
	PlayerTextDrawShow(playerid, Textdraw0[playerid]);

	Textdraw1[playerid] = CreatePlayerTextDraw(playerid, 497.600, 120.212, "Ping - -=- ms");
	PlayerTextDrawAlignment(playerid, Textdraw1[playerid], 1);
	PlayerTextDrawColor(playerid, Textdraw1[playerid], -1);
	PlayerTextDrawSetOutline(playerid, Textdraw1[playerid], 1);
	PlayerTextDrawBackgroundColor(playerid, Textdraw1[playerid], 51);
	PlayerTextDrawFont(playerid, Textdraw1[playerid], 2);
	PlayerTextDrawSetProportional(playerid, Textdraw1[playerid], 1);
    PlayerTextDrawShow(playerid, Textdraw1[playerid]);

    updatetimer[playerid] = SetTimerEx("update", 1000, true, "d", playerid);
	return 1;
}
public update(playerid)
{
	new score[16], ping[16];
	format(score, sizeof(score), "Score - %d", GetPlayerScore(playerid));
	format(ping, sizeof(ping), "Ping - %d ms", GetPlayerPing(playerid));
	PlayerTextDrawSetString(playerid, Textdraw0[playerid], score);
	PlayerTextDrawSetString(playerid, Textdraw1[playerid], ping);
	return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
	PlayerTextDrawDestroy(playerid, Textdraw0[playerid]);
	Textdraw0[playerid] = PlayerText:INVALID_TEXT_DRAW;

	PlayerTextDrawDestroy(playerid, Textdraw1[playerid]);
	Textdraw1[playerid] = PlayerText:INVALID_TEXT_DRAW;

	KillTimer(updatetimer[playerid]);

	return 1;
}
But there is no textdraw on my screen. also if i set my score to 12331[whatever] but it dosen't show to in *Tab* Button dialog too..
Reply
#2

Anyone help?
Reply
#3

Is it when you enter server and /setscore,it shows but after re-log it doesnt?
Reply
#4

No it dosen't
Reply
#5

Where did you set player's score?
And also, create all of your textdraws inside OnGameModeInit
Код:
for(new i=0;i<MAX_PLAYERS;i++)
	{
Textdraw0[i] = CreatePlayerTextDraw(i, 498.398, 100.799, "Score - -=-");
	PlayerTextDrawAlignment(i, Textdraw0[i], 1);
	PlayerTextDrawColor(i, Textdraw0[i], -1);
	PlayerTextDrawSetOutline(i, Textdraw0[i], 1);
	PlayerTextDrawBackgroundColor(i, Textdraw0[i], 51);
	PlayerTextDrawFont(i, Textdraw0[i], 2);
	PlayerTextDrawSetProportional(i, Textdraw0[i], 1);
	PlayerTextDrawShow(i, Textdraw0[i]);

	Textdraw1[i] = CreatePlayerTextDraw(i, 497.600, 120.212, "Ping - -=- ms");
	PlayerTextDrawAlignment(i, Textdraw1[i], 1);
	PlayerTextDrawColor(i, Textdraw1[i], -1);
	PlayerTextDrawSetOutline(i, Textdraw1[i], 1);
	PlayerTextDrawBackgroundColor(i, Textdraw1[i], 51);
	PlayerTextDrawFont(i, Textdraw1[i], 2);
	PlayerTextDrawSetProportional(i, Textdraw1[i], 1);
    PlayerTextDrawShow(i, Textdraw1[i]);
}
And on player connect just change textdraw's string, and start a timer:
Код:
new score[16], ping[16];
	format(score, sizeof(score), "Score - %d", GetPlayerScore(playerid));
	format(ping, sizeof(ping), "Ping - %d ms", GetPlayerPing(playerid));
	PlayerTextDrawSetString(playerid, Textdraw0[playerid], score);
	PlayerTextDrawSetString(playerid, Textdraw1[playerid], ping);
        updatetimer[playerid] = SetTimerEx("update", 1000, true, "d", playerid);
EDIT: I've just found that player textdraws need to be put under on player connect. But still, you can create normal textdraws, and load score with them.
Reply
#6

when i was copied and pasted your codes to my pawno i got few errors. so it will be better for me if you make this full script for me.
pawn Код:
#include <a_samp>
new updatetimer[MAX_PLAYERS];
//Player Textdraws:
new PlayerText:Textdraw0[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
new PlayerText:Textdraw1[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
forward update(playerid);
public OnPlayerConnect(playerid)
{
    Textdraw0[playerid] = CreatePlayerTextDraw(playerid, 498.398, 100.799, "Score - -=-");
    PlayerTextDrawAlignment(playerid, Textdraw0[playerid], 1);
    PlayerTextDrawColor(playerid, Textdraw0[playerid], -1);
    PlayerTextDrawSetOutline(playerid, Textdraw0[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, Textdraw0[playerid], 51);
    PlayerTextDrawFont(playerid, Textdraw0[playerid], 2);
    PlayerTextDrawSetProportional(playerid, Textdraw0[playerid], 1);
    PlayerTextDrawShow(playerid, Textdraw0[playerid]);

    Textdraw1[playerid] = CreatePlayerTextDraw(playerid, 497.600, 120.212, "Ping - -=- ms");
    PlayerTextDrawAlignment(playerid, Textdraw1[playerid], 1);
    PlayerTextDrawColor(playerid, Textdraw1[playerid], -1);
    PlayerTextDrawSetOutline(playerid, Textdraw1[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, Textdraw1[playerid], 51);
    PlayerTextDrawFont(playerid, Textdraw1[playerid], 2);
    PlayerTextDrawSetProportional(playerid, Textdraw1[playerid], 1);
    PlayerTextDrawShow(playerid, Textdraw1[playerid]);

    updatetimer[playerid] = SetTimerEx("update", 1000, true, "d", playerid);
    return 1;
}
public update(playerid)
{
    new score[16], ping[16];
    format(score, sizeof(score), "Score - %d", GetPlayerScore(playerid));
    format(ping, sizeof(ping), "Ping - %d ms", GetPlayerPing(playerid));
    PlayerTextDrawSetString(playerid, Textdraw0[playerid], score);
    PlayerTextDrawSetString(playerid, Textdraw1[playerid], ping);
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    PlayerTextDrawDestroy(playerid, Textdraw0[playerid]);
    Textdraw0[playerid] = PlayerText:INVALID_TEXT_DRAW;

    PlayerTextDrawDestroy(playerid, Textdraw1[playerid]);
    Textdraw1[playerid] = PlayerText:INVALID_TEXT_DRAW;

    KillTimer(updatetimer[playerid]);

    return 1;
}
Edit this script and give it. but must sure: remove the OnPlayerFilterscript... because i wanna use it in my gamemode not as filterscript.
Reply
#7

Код:
/*
	Basic Player Stats. Shows Score and Ping in a textdraw.
	Credits - iPLEOMAX
 		      [HK]Ryder[AN]
 		      SA:MP Team
*/
#include <a_samp>
#include <foreach>
new updatetimer[MAX_PLAYERS];
//Player Textdraws:
new Text:Textdraw0[MAX_PLAYERS];
new Text:Textdraw1[MAX_PLAYERS];
forward update(playerid);
public OnGameModeInit()
{
	foreach(Player,i)
	{
	    Textdraw0[i] = TextDrawCreate(498.398, 100.799,"Score");
		TextDrawAlignment(Textdraw0[i], 1);
		TextDrawColor(Textdraw0[i], -1);
		TextDrawSetOutline(Textdraw0[i], 1);
		TextDrawBackgroundColor(Textdraw0[i], 51);
		TextDrawFont(Textdraw0[i], 2);
		TextDrawSetProportional(Textdraw0[i], 1);

		Textdraw1[i] = TextDrawCreate(497.600, 120.212, "Ping - -=- ms");
		TextDrawAlignment(Textdraw1[i], 1);
		TextDrawColor(Textdraw1[i], -1);
		TextDrawSetOutline(Textdraw1[i], 1);
		TextDrawBackgroundColor(Textdraw1[i], 51);
		TextDrawFont(Textdraw1[i], 2);
		TextDrawSetProportional(Textdraw1[i], 1);
	}
	return 1;
}
public OnPlayerConnect(playerid)
{
	// changing strings for the first time of player's textdraw
    new score[16], ping[16];
	format(score, sizeof(score), "Score - %d", GetPlayerScore(playerid));
	format(ping, sizeof(ping), "Ping - %d ms", GetPlayerPing(playerid));
	TextDrawSetString(Textdraw0[playerid], score);
	TextDrawSetString(Textdraw1[playerid], ping);
	TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
	TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
    updatetimer[playerid] = SetTimerEx("update", 1000, true, "d", playerid);
	return 1;
}
public update(playerid)
{
	new score[16], ping[16];
	format(score, sizeof(score), "Score - %d", GetPlayerScore(playerid));
	format(ping, sizeof(ping), "Ping - %d ms", GetPlayerPing(playerid));
	TextDrawSetString(Textdraw0[playerid], score);
	TextDrawSetString(Textdraw1[playerid], ping);
	return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
	TextDrawDestroy(Textdraw0[playerid]);

	TextDrawDestroy(Textdraw1[playerid]);

	KillTimer(updatetimer[playerid]);

	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)