How to change a textdraw's text with a command?
#1

Hi. This is my textdraw:

Код:
Textdraw2 = TextDrawCreate(542.000000, 391.000000, "000000");
	TextDrawAlignment(Textdraw2, 2);
	TextDrawBackgroundColor(Textdraw2, 255);
	TextDrawFont(Textdraw2, 3);
	TextDrawLetterSize(Textdraw2, 0.399994, 1.399999);
	TextDrawColor(Textdraw2, -1);
	TextDrawSetOutline(Textdraw2, 0);
	TextDrawSetProportional(Textdraw2, 1);
	TextDrawSetShadow(Textdraw2, 1);
I want to be able to change it by typing a command, for example, when I type /setdraw [input], the textdraw changes to my input, how should I be able to do this?
Reply
#2

pawn Код:
COMMAND:setdraw(playerid, params[])
{
    new string[128];
    new text;
    if(sscanf(params, "s[128]", text)) SendClientMessage(playerid, 0xFF0000FF, "[USAGE]: /setdraw [input]");
    else
    {
        TextDrawSetString(Textdraw2, string);
        SendClientMessageToAll(0xFF0000FF, string);
    }
    return 1;
}
The command compiles fine but not tested it.
Reply
#3

Quote:
Originally Posted by sniperwars
Посмотреть сообщение
pawn Код:
COMMAND:setdraw(playerid, params[])
{
    new string[128];
    new text;
    if(sscanf(params, "s[128]", text)) SendClientMessage(playerid, 0xFF0000FF, "[USAGE]: /setdraw [input]");
    else
    {
        TextDrawSetString(Textdraw2, string);
        SendClientMessageToAll(0xFF0000FF, string);
    }
    return 1;
}
The command compiles fine but not tested it.
Ehh, why use 128, when 30 is more than enough...
Reply
#4

Which command progressor do you use?
Reply
#5

That command is wrong. Where are you getting string from, it's an empty string?
You should be using text.
pawn Код:
COMMAND:setdraw(playerid, params[])
{
    new string[45];
    if(sscanf(params, "s[45]", string)) return SendClientMessage(playerid, 0xFF0000FF, "[USAGE]: /setdraw [input]");
    TextDrawSetString(Textdraw2, string);
    SendClientMessageToAll(0xFF0000FF, string);
    return 1;
}
Reply
#6

pawn Код:
COMMAND:setdraw(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid,-1,"/setdraw [text]");
    TextDrawSetString(Textdraw2,params);
    SendClientMessageToAll(0xFF0000FF,params);
    return 1;
}
Reply
#7

Trying any command gives me this:

C:\Users\Mijn pc\Desktop\Scripting\gamemodes\login.pwn(162) : error 029: invalid expression, assumed zero
C:\Users\Mijn pc\Desktop\Scripting\gamemodes\login.pwn(162) : error 017: undefined symbol "cmd_mycommand"
C:\Users\Mijn pc\Desktop\Scripting\gamemodes\login.pwn(162) : error 029: invalid expression, assumed zero
C:\Users\Mijn pc\Desktop\Scripting\gamemodes\login.pwn(162) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)