SA-MP Forums Archive
TextDraw errors. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: TextDraw errors. (/showthread.php?tid=654223)



TextDraw errors. - BlackLineCnR - 23.05.2018

Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if (!success)
    {
    }
    else
    {
    new Text:Unknow;
    Unknow = TextDrawCreate(318, 384, "Unknown Command");
    TextDrawFont(Unknow , 1);
    TextDrawLetterSize(Unknow , 0.6, 4.2);
    TextDrawColor(Unknow , 0xFFFFFFFF);
    TextDrawSetOutline(Unknow , 0);
    TextDrawSetProportional(Unknow , 1);
    TextDrawSetShadow(Unknow , 1);
	TextDrawShowForPlayer(playerid, Unknow);
	}
    return 1;
}
I added this textdraw, So whenever a player enters wrong command it will be shown but nothing is happening :/


Re: TextDraw errors. - BlackLineCnR - 23.05.2018

Sorry for bumping, And this textdraw isnt disappearing -_-


Re: TextDraw errors. - FailerZ - 23.05.2018

I really suggest you to use https://sampwiki.blast.hk/wiki/GameTextForPlayer for this case.

But if you really want to use textdraws you can create a timer https://sampwiki.blast.hk/wiki/SetTimerEx to hide it after time

Also you are creating the textdraw everytime, why not just create it under OnGameModeInit so you can then just show/hide it

Btw you have reversed the logic with that if statement, put the code under if(!success)

Example:
PHP Code:
public OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    if (!
success)
    {
        
GameTextForPlayer(playerid"Unknown Command"30001);
    }
    return 
1;




Re: TextDraw errors. - AlexMSK - 23.05.2018

Simply creating on it's right function and using a timer to destroy it and make sure you read this > https://sampwiki.blast.hk/wiki/Textdraw


E.g code
PHP Code:
new Text:Unknow;
forward unkcmd(playerid);
public 
unkcmd(playerid)
{
    
TextDrawHideForPlayer(playeridUnknow);
    return 
1;
}
public 
OnPlayerCommandPerformed(playeridcmdtext[], success)
{
    if (!
success)
    {
        
TextDrawShowForPlayer(playeridUnknow);
        
SetTimerEx("unkcmd"5000false"i"playerid);
    }
    return 
1;
}
public 
OnGameModeInit()
{
    
Unknow TextDrawCreate(318384"Unknown Command");
    
TextDrawFont(Unknow 1);
    
TextDrawLetterSize(Unknow 0.64.2);
    
TextDrawColor(Unknow 0xFFFFFFFF);
    
TextDrawSetOutline(Unknow 0);
    
TextDrawSetProportional(Unknow 1);
    
TextDrawSetShadow(Unknow 1);
    return 
1;