Textdraw similar to Speed-O-Meter Overlay problem :(
#1

So yea i got an hour system that counts minutes,secs,and Hours and my score goes for 1Hour = 1Point
and now i did a textdraw so the ppl can see how much minutes,secs etc they got...
but when it refreshes it just does overlay again...
and when i add a destroytextdraw
the textdraw does never appear.not even once...
so please help....
iposted this prob already but nobody did help me :/
i did wait like 2 days now...
Reply
#2

OnFilterScriptInit: create a textdraw for all players using a loop

OnPlayerConnect/Login: TextDrawShowForPlayer

OnPlayerDisconnect: TextDrawHideForPlayer

and to change the text in it (in the timer): TextDrawSetString
Reply
#3

Thanks and wat do i put as string?
Reply
#4

Quote:
Originally Posted by saiberfun
Thanks and wat do i put as string?
The hours/minutes/second the player is playing on the server, for example:

~w~Hours: ~g~%d~n~~w~Minutes: ~g~%d~n~~w~Seconds: ~g~%d

Will show for example:

Hours: 6
Minutes: 32
Seconds: 27
Reply
#5

pawn Код:
public Draw()
{
new str[128];
for(new i; i<MAX_PLAYERS; i++)
{
if(draw[i] == 0)
{
format(str, sizeof str, "Hours:%d Mins:%d Secs:%d",AccountInfo[i][Hours],AccountInfo[i][Mins],AccountInfo[i][Secs]);
Textdraw0 = TextDrawCreate(303.000000,432.000000,str);
TextDrawAlignment(Textdraw0,0);
TextDrawBackgroundColor(Textdraw0,0x000000ff);
TextDrawFont(Textdraw0,3);
TextDrawLetterSize(Textdraw0,0.699999,1.200000);
TextDrawColor(Textdraw0,0xffffffff);
TextDrawSetOutline(Textdraw0,1);
TextDrawSetProportional(Textdraw0,1);
TextDrawSetShadow(Textdraw0,1);
TextDrawShowForPlayer(i,Textdraw0);
draw[i] = 1;
}
if(draw[i] == 1)
{
TextDrawSetString(Textdraw0,str);
}
}
return 1;
}
I've set it like that now...
but it does crash my server
the timer is set to 1sec aka 1000ms
Reply
#6

Quote:
Originally Posted by saiberfun
pawn Код:
public Draw()
{
new str[128];
for(new i; i<MAX_PLAYERS; i++)
{
if(draw[i] == 0)
{
format(str, sizeof str, "Hours:%d Mins:%d Secs:%d",AccountInfo[i][Hours],AccountInfo[i][Mins],AccountInfo[i][Secs]);
Textdraw0 = TextDrawCreate(303.000000,432.000000,str);
TextDrawAlignment(Textdraw0,0);
TextDrawBackgroundColor(Textdraw0,0x000000ff);
TextDrawFont(Textdraw0,3);
TextDrawLetterSize(Textdraw0,0.699999,1.200000);
TextDrawColor(Textdraw0,0xffffffff);
TextDrawSetOutline(Textdraw0,1);
TextDrawSetProportional(Textdraw0,1);
TextDrawSetShadow(Textdraw0,1);
TextDrawShowForPlayer(i,Textdraw0);
draw[i] = 1;
}
if(draw[i] == 1)
{
TextDrawSetString(Textdraw0,str);
}
}
return 1;
}
I've set it like that now...
but it does crash my server
the timer is set to 1sec aka 1000ms
Youre creating a textdraw for all players every 1 sec! Sorry, but thats bullshit! I told you how to do it..
Reply
#7

i dont get it.....
How should i do that?
sry if im annoying ya...
Reply
#8

Quote:
Originally Posted by lesley
OnFilterScriptInit: create a textdraw for all players using a loop

OnPlayerConnect/Login: TextDrawShowForPlayer

OnPlayerDisconnect: TextDrawHideForPlayer

and to change the text in it (in the timer): TextDrawSetString
Reply
#9

FilterScript and learn it :P

Код:
#include <a_samp>
enum PlayerInfoEnum {
	Text:PlayingTime,
	bool:TextOn,
 	Time
};
new PlayerInfo[200][PlayerInfoEnum];

public OnFilterScriptInit()
{
  SetTimer("Draw",1000,1);
	for(new i=0; i < GetMaxPlayers(); i++) {
    CreatePlayerDraw(i);
    if(IsPlayerConnected(i)) {
			TextDrawShowForPlayer(i,PlayerInfo[i][PlayingTime]);
		}
	}
	return 1;
}

public OnFilterScriptExit()
{
	for(new i=0; i < GetMaxPlayers(); i++) {
		DestroyPlayerDraw(i);
	}
	return 1;
}

public OnPlayerConnect(playerid)
{
  CreatePlayerDraw(playerid);
	PlayerInfo[playerid][Time]=0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  DestroyPlayerDraw(playerid);
  PlayerInfo[playerid][Time]=0;
	return 1;
}
forward Draw();
public Draw()
{
new str[128];
for(new i=0; i<GetMaxPlayers(); i++)
{
  PlayerInfo[i][Time]++;
	format(str, sizeof str, "Hours:%d Mins:%d Secs:%d",PlayerInfo[i][Time]/3600,PlayerInfo[i][Time]/60-(((PlayerInfo[i][Time]/3600)*3600)/60),PlayerInfo[i][Time]-((PlayerInfo[i][Time]/60)*60));
	TextDrawSetString(PlayerInfo[i][PlayingTime],str);
	SetPlayerScore(i,PlayerInfo[i][Time]/3600);
}
return 1;
}

stock CreatePlayerDraw(playerid){
	if(!PlayerInfo[playerid][TextOn]) {
		PlayerInfo[playerid][TextOn]=true;
		PlayerInfo[playerid][PlayingTime] = TextDrawCreate(303.0,432.0,"_");
		TextDrawAlignment(PlayerInfo[playerid][PlayingTime],0);
		TextDrawBackgroundColor(PlayerInfo[playerid][PlayingTime],0x000000ff);
		TextDrawFont(PlayerInfo[playerid][PlayingTime],3);
		TextDrawLetterSize(PlayerInfo[playerid][PlayingTime],0.7,1.2);
		TextDrawColor(PlayerInfo[playerid][PlayingTime],0xffffffff);
		TextDrawSetOutline(PlayerInfo[playerid][PlayingTime],1);
		TextDrawSetProportional(PlayerInfo[playerid][PlayingTime],1);
		TextDrawSetShadow(PlayerInfo[playerid][PlayingTime],1);
		TextDrawShowForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
 	}
	return 1;
}

stock DestroyPlayerDraw(playerid){
	if(PlayerInfo[playerid][TextOn]) {
	  TextDrawHideForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
	  PlayerInfo[playerid][TextOn]=false;
	  TextDrawDestroy(PlayerInfo[playerid][PlayingTime]);
	}
	return 1;
}
Reply
#10

Quote:
Originally Posted by Jefff
FilterScript and learn it :P

Код:
#include <a_samp>
enum PlayerInfoEnum {
	Text:PlayingTime,
	bool:TextOn,
 	Time
};
new PlayerInfo[200][PlayerInfoEnum];

public OnFilterScriptInit()
{
  SetTimer("Draw",1000,1);
	for(new i=0; i < GetMaxPlayers(); i++) {
    CreatePlayerDraw(i);
    if(IsPlayerConnected(i)) {
			TextDrawShowForPlayer(i,PlayerInfo[i][PlayingTime]);
		}
	}
	return 1;
}

public OnFilterScriptExit()
{
	for(new i=0; i < GetMaxPlayers(); i++) {
		DestroyPlayerDraw(i);
	}
	return 1;
}

public OnPlayerConnect(playerid)
{
  CreatePlayerDraw(playerid);
	PlayerInfo[playerid][Time]=0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  DestroyPlayerDraw(playerid);
  PlayerInfo[playerid][Time]=0;
	return 1;
}
forward Draw();
public Draw()
{
new str[128];
for(new i=0; i<GetMaxPlayers(); i++)
{
  PlayerInfo[i][Time]++;
	format(str, sizeof str, "Hours:%d Mins:%d Secs:%d",PlayerInfo[i][Time]/3600,PlayerInfo[i][Time]/60-(((PlayerInfo[i][Time]/3600)*3600)/60),PlayerInfo[i][Time]-((PlayerInfo[i][Time]/60)*60));
	TextDrawSetString(PlayerInfo[i][PlayingTime],str);
	SetPlayerScore(i,PlayerInfo[i][Time]/3600);
}
return 1;
}

stock CreatePlayerDraw(playerid){
	if(!PlayerInfo[playerid][TextOn]) {
		PlayerInfo[playerid][TextOn]=true;
		PlayerInfo[playerid][PlayingTime] = TextDrawCreate(303.0,432.0,"_");
		TextDrawAlignment(PlayerInfo[playerid][PlayingTime],0);
		TextDrawBackgroundColor(PlayerInfo[playerid][PlayingTime],0x000000ff);
		TextDrawFont(PlayerInfo[playerid][PlayingTime],3);
		TextDrawLetterSize(PlayerInfo[playerid][PlayingTime],0.7,1.2);
		TextDrawColor(PlayerInfo[playerid][PlayingTime],0xffffffff);
		TextDrawSetOutline(PlayerInfo[playerid][PlayingTime],1);
		TextDrawSetProportional(PlayerInfo[playerid][PlayingTime],1);
		TextDrawSetShadow(PlayerInfo[playerid][PlayingTime],1);
		TextDrawShowForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
 	}
	return 1;
}

stock DestroyPlayerDraw(playerid){
	if(PlayerInfo[playerid][TextOn]) {
	  TextDrawHideForPlayer(playerid,PlayerInfo[playerid][PlayingTime]);
	  PlayerInfo[playerid][TextOn]=false;
	  TextDrawDestroy(PlayerInfo[playerid][PlayingTime]);
	}
	return 1;
}
1. learn how to indent your code
2. still wrong! it creates useless textdraws!
3. Do it like i told in one of my posts in this thread!
Reply


Forum Jump:


Users browsing this thread: