Textdraw Question - 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: Textdraw Question (
/showthread.php?tid=364206)
Textdraw Question -
andrew2695 - 29.07.2012
Hello, My server has an announce command using a textdraw. So basicaly we do /text [Message] And we can use ~b~ ~n~ etc. I saw some people having an announce command but they couldn't use the ~n~ but needed $cr for example make it red. /text $crHello. In this case, the server is not crashing if ~r~ is misspelled in ~r~~. I'm asking how can I disable the usage of ~~ in my text command and make it using the "$c"?
Re: Textdraw Question -
Sniper Kitty - 30.07.2012
This may or may not work so don't blame me if it doesn't.
pawn Код:
stock CheckTD(String[]) {
for(new StringPos = 0; StringPos < strlen(String); StringPos++) {
if(String[StringPos] == '~' && String[(StringPos + 2)] == '~') {
switch(String[(StringPos + 1)]) {
case 'n', 'r', 'g', 'b': {
strdel(String, StringPos, (StringPos + 2));
StringPos--;
}
}
}
else if(String[StringPos] == '$' && String[(StringPos + 1)] == 'c') {
switch(String[(StringPos + 2)]) {
case 'r', 'g', 'b': {
String[StringPos] = '~';
String[(StringPos + 1)] = String[(StringPos + 2)];
String[(StringPos + 2)] = '~';
}
}
}
}
return String;
}
Possible Example:
Код:
printf("%s", CheckTD("~r~Welcome to~n~ $crmy server! $cg$cnNoob!"));
Possible Output:
Welcome to
my server! $cnNoob!
Re : Textdraw Question -
andrew2695 - 30.07.2012
The code you gave look fine but where should I add the CheckTD in my code?
I tried: But the td is not showing at all
pawn Код:
CMD:text(playerid,params[])
{
if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
new announce[41];
if(sscanf(params,"s[256]", announce)) return Usage(playerid, "/text [message]");
if(!InUse)
{
TextDrawSetString(AnnText, CheckTD(announce));
TextDrawShowForAll(AnnText);
SetTimer("TextTime",4000,false);
InUse = true;
}
else
{
SendClientMessage(playerid, COLOR_RED, "Text already in use!");
}
AdminMessage(playerid, "/text");
return 1;
}
}