Creating a simple textdraw
#1

I am trying to learn how to use textdraws, and I am trying to create a simple one which shows a player a list of text when he types a command.

So, for example, it could be a list of colours. He types /textdraw and one appears, with a list such as --
- Blue
- Red
- Orange
- Green

and then there is a button which he can click to get rid of it.

So far, I've got this...
PHP код:
CMD:textdraw(playerid, params[])
{
    
ShowTextdraw(playerid);
    return 
1;
}
ShowTextdraw(playerid);
{
    new
        
string[128];
    
format(string, sizeof(string), "Blue\nRed\nOrange\nGreen");
    
PlayerTextDrawSetString(playerid, PlayerData[playerid][pTextdraws][0], string);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
CreateTextDraws(playerid);
    return 
1;
}
CreateTextDraws(playerid) {    
    
PlayerData[playerid][pTextdraws][0] = CreatePlayerTextDraw(playerid, 199.000000, 174.000000, "Colours");
    
PlayerTextDrawBackgroundColor(playerid, PlayerData[playerid][pTextdraws][0], 255);
    
PlayerTextDrawFont(playerid, PlayerData[playerid][pTextdraws][0], 1);
    
PlayerTextDrawLetterSize(playerid, PlayerData[playerid][pTextdraws][0], 0.310000, 1.100000);
    
PlayerTextDrawColor(playerid, PlayerData[playerid][pTextdraws][0], -1);
    
PlayerTextDrawSetOutline(playerid, PlayerData[playerid][pTextdraws][0], 0);
    
PlayerTextDrawSetProportional(playerid, PlayerData[playerid][pTextdraws][0], 1);
    
PlayerTextDrawSetShadow(playerid, PlayerData[playerid][pTextdraws][0], 1);
    
PlayerTextDrawSetSelectable(playerid, PlayerData[playerid][pTextdraws][0], 0);
} 
But when I type the command in-game, nothing appears. I get no warnings when compiling.
Reply
#2

Код:
ShowTextdraw(playerid);
{
    new
        string[128];
    PlayerTextDrawShowForPlayer(playerid, PlayerData[playerid][pTextdraws][0]);
    format(string, sizeof(string), "Blue\nRed\nOrange\nGreen");
    PlayerTextDrawSetString(playerid, PlayerData[playerid][pTextdraws][0], string);
    return 1;
}
You were not showing the TextDraw thats why the command wasn't even showing anything.
Reply


Forum Jump:


Users browsing this thread: