SA-MP Forums Archive
How to change a textdraw's text with a command? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to change a textdraw's text with a command? (/showthread.php?tid=375682)



How to change a textdraw's text with a command? - davelord - 07.09.2012

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?


Re: How to change a textdraw's text with a command? - sniperwars - 07.09.2012

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.


Re: How to change a textdraw's text with a command? - ddnbb - 07.09.2012

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...


Re: How to change a textdraw's text with a command? - davelord - 07.09.2012

Which command progressor do you use?


Re: How to change a textdraw's text with a command? - clarencecuzz - 07.09.2012

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;
}



Re: How to change a textdraw's text with a command? - C00K13M0N$73R - 07.09.2012

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



Re: How to change a textdraw's text with a command? - davelord - 07.09.2012

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