Player Textdraw Doesn't show...
#1

Hey!

So, I made a player-textdraw that would show everytime when someone types a wrong command.

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
              new str[256];
              format(str,sizeof(str),"The Command ~y~%s ~w~does not exist, To see all commands use ~y~/cmds ",cmdtext);
              PlayerTextDrawSetString(playerid,wrongcmd[playerid],str);
              PlayerTextDrawShow(playerid,wrongcmd[playerid]);
              SetTimerEx("HideWrongTD", 4000, false, "i", playerid);
    }
    return 1;
}

forward HideWrongTD(playerid);

public HideWrongTD(playerid)
{
    PlayerTextDrawHide(playerid, wrongcmd[playerid]);
}
Somehow, The textdraw isn't showing... Whenever someone types a wrong command, nothing happens.
I tried changing this
Код:
public HideWrongTD(playerid)
{
	PlayerTextDrawHide(playerid, wrongcmd[playerid]);
}
to this
Код:
public HideWrongTD(playerid)
{
	PlayerTextDrawDestroy(playerid, wrongcmd[playerid]);
}
It shows the textdraw for the first time, but after that it doesn't show it.

This is irritating, any kind of help would be appreciated?
Reply
#2

Don't destroy it, just hide it(if it shows for first time only).
Reply
#3

I am hiding it using the following
Код:
public HideWrongTD(playerid)
{
	PlayerTextDrawHide(playerid, wrongcmd[playerid]);
}
But it isn't showing in the first place...Nothing is happening whenever someone is typing a wrong command.
Reply
#4

Do you mind showing us the textdraw?
Reply
#5

The problem is in here,
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
              new str[75];
              format(str,sizeof(str),"The Command ~y~%s ~w~does not exist, To see all commands use ~y~/cmds ",cmdtext);
              PlayerTextDrawSetString(playerid,wrongcmd[playerid],str);
              PlayerTextDrawShow(playerid,wrongcmd[playerid]);
              SetTimerEx("HideWrongTD", 6000, false, "i", playerid);
    }
    return 1;
}
If I use new str[70]; and keep it within 70, it perfectly shows the textdraw however some text doesn't show. If i increase it over 70, it doesn't show the entire textdraw.
Reply
#6

Never put spaces at the end of a Textdraw Text! That prevents any TextDraw/GameText from showing.

The size of the string should be at least 90 btw. That will show a command of the length 20 maximum, when longer the text will get cut.
Reply
#7

Quote:
Originally Posted by NaS
Посмотреть сообщение
Never put spaces at the end of a Textdraw Text! That prevents any TextDraw/GameText from showing.

The size of the string should be at least 90 btw. That will show a command of the length 20 maximum, when longer the text will get cut.
Thanks a lot, it fixed it.

Does anyone know whether there is a way in which like if a player types /blahslkdjasdkasd or any other big wrong command, it only shows some characters of it and change it to like /blahsikl.... and with dots at the end?

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
    {
              new str[75];
              format(str,sizeof(str),"The Command ~y~%s ~w~does not exist, To see all commands use ~y~/cmds",cmdtext);
              PlayerTextDrawSetString(playerid,wrongcmd[playerid],str);
              PlayerTextDrawShow(playerid,wrongcmd[playerid]);
              SetTimerEx("HideWrongTD", 6000, false, "i", playerid);
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by SsHady
Посмотреть сообщение
Thanks a lot, it fixed it.

Does anyone know whether there is a way in which like if a player types /blahslkdjasdkasd or any other big wrong command, it only shows some characters of it and change it to like /blahsikl.... and with dots at the end?

[pawn]
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success)
{
new str[75];
format(str,sizeof(str),"The Command ~y~%s ~w~does not exist, To see all commands use ~y~/cmds",cmdtext);
PlayerTextDrawSetString(playerid,wrongcmd[playerid],str);
PlayerTextDrawShow(playerid,wrongcmd[playerid]);
SetTimerEx("HideWrongTD", 6000, false, "i", playerid);
}
return 1;
}/pawn]
Use strmid if the text is longer than X characters. strmid copies a string, from a given start position to a given end position.

Код:
new str[90];

if(strlen(cmdtext) > 20)
{
strmid(str,  cmdtext, 0, 20);
strcat(str, "...");
}
else strcat(str, cmdtext);

format(str,sizeof(str),"The Command ~y~%s ~w~does not exist, To see all commands use ~y~/cmds", str);
Alternatively you can set the last 4 characters of cmdtext to "...\0" to cap it at 20 characters max.
Reply
#9

Thanks alot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)