Changing TextDraw?
#1

I wanted to create a textdraw that randomly selects a string and then sends the message/text draw to all player. My problem is that an unrelated textdraw that I have is the one that gets deleted. I know that the problem is that there is now "news" textdraw to destory so it gets confused but what would be a fix?

Код:
public NewsChange()
{
	new rand = random(3);
	new NewsString[128];
	switch(rand)
	{
		case 0: format(NewsString,128,"1");
		case 1: format(NewsString,128,"2");
		case 2: format(NewsString,128,"3");
		case 3: format(NewsString,128,"4");
	}
	TextDrawDestroy(News);
	News=TextDrawCreate(350,430,NewsString);
	TextDrawFont(News,1);
	TextDrawLetterSize(News,0.4,1.0);
	TextDrawShowForAll(News);
    return 1;
}
I tried changing it to this, but this does not destroy the previous text draw (the one with an actual message);

Код:
public NewsChange()
{
	new rand = random(3);
	new NewsString[128];
	switch(rand)
	{
		case 0: format(NewsString,128,"Super Jump Has Been Remade! Check It Out At ~r~//sj~w~!");
		case 1: format(NewsString,128,"Orignal Dukes Of Hazard At ~r~//duke~w~!");
		case 2: format(NewsString,128,"~r~Wanted: ~w~Apply For Admin!");
		case 3: format(NewsString,128,"Want A Hydra? Get One At //army!");
	}
	News=TextDrawCreate(400,430," ");
	TextDrawShowForAll(News);
	TextDrawDestroy(News);
	News=TextDrawCreate(350,430,NewsString);
	TextDrawFont(News,1);
	TextDrawLetterSize(News,0.4,1.0);
	TextDrawShowForAll(News);
    return 1;
}
Any help would be appreciated!
Reply
#2

try using TextDrawSetString
https://sampwiki.blast.hk/wiki/TextDrawSetString
Reply
#3

Also, make sure you're only deleting a textdraw if it actually exists by using booleans to determine if you've created them or not

pawn Код:
Text:MyTextdraw;
bool:MyTextdrawCreated;
//When creating textdraw
MyTextdraw=TextDrawCreate(...);
MyTextdrawCreated=true;
//When deleting textdraw
if(MyTextdrawCreated)
{
    TextDrawDestroy(MyTextdraw);
    MyTextdrawCreated=false;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)