TextDraw errors.
#1

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 :/
Reply
#2

Sorry for bumping, And this textdraw isnt disappearing -_-
Reply
#3

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;

Reply
#4

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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)