3DTextlabel issue; how to make a global one but assign for a player?
#1

^^READ THE LAST POST^^








Hello,

I am trying to do something regarding 3DTextlabels

I want to make a global 3DTextlabel, but I want it to be assigned to be a player ID, just like doing:

SObject[playerid] = CreateObject(....);

and then at someother part of the code:

if(IsValidObject(SObject[playerid]) DestroyObject(SObject[playerid]);

So these work fine with objects, however they don't work with 3d text labels. They give tag mismatch errors.

So I want to create a 3DTextlabel where a player is and assign the 3dtextlabel id to a variable and X seconds later I want to destroy the label, how can I do that? If I use player labels then it's going to be assigned for everyone. If I make global ones though then I can't use multiple labels.

Don't get me wrong, I want the labels to be visible for all players just NOT assigned for all players.

Thanks.
Reply
#2

Add "Text3D:" infront of the global variable and it will work. Although I'm not sure if it'd work, let me get a quote.


EDIT: Please refer to http://forum.sa-mp.com/showpost.php?...postcount=2524 for future usage, just incase. (:
Reply
#3

new Text3D:SOobject[MAX_PLAYERS];
I think that will work?
edit: Mionee beat me to it :P
Reply
#4

new Text3D:Myvar[MAX_PLAYERS];

Myvar = Create3DTextLabel("I'm at the coordinates:\n30.0, 40.0, 50.0", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0, 0);

error 033: array must be indexed (variable "Myvar ")
I create the label at a sub-callback (command at this case) and the definition is on top of the script
Reply
#5

Use Myvar[playerid], you added an array but didn't actually use it
Reply
#6

Quote:
Originally Posted by IKnowWhatIAmDoing
Посмотреть сообщение
new Text3D:Myvar[MAX_PLAYERS];

Myvar = Create3DTextLabel("I'm at the coordinates:\n30.0, 40.0, 50.0", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0, 0);

error 033: array must be indexed (variable "Myvar ")
I create the label at a sub-callback (command at this case) and the definition is on top of the script
You need to add [playerid] to myvar. If you defined it with MAX_PLAYERS, or some other thing.
Reply
#7

Quote:
Originally Posted by Mionee
Посмотреть сообщение
Use Myvar[playerid], you added an array but didn't actually use it
I actually tried this before weird. It gave errors. Now Its fine thanks.

I forgot to add Myvar[playerid] I was so sure It would not work I actually forgot doing that completely. xD Thanks to both of you anyway
Reply
#8

pawn Код:
foreach(new i : Player) // onplayerspawn
{
     if(SomeVar[i] == 1)
     {
         new PlayerText3D:playertextid
         playertextid = CreatePlayer3DTextLabel(i,"bla bla bla",0x008080FF,x,y,z,40.0);
         SetTimerEx("DeleteLabel", 15000, false, "dd", i, playertextid); // warning 213: tag mismatch
     }
}

forward DeleteLabel(playerid,labelid);
public DeleteLabel(playerid,labelid)
{
    DeletePlayer3DTextLabel(playerid, PlayerText3D:labelid);
}
How can I fix it? I want the label to be visible for some players only and I want it to disappear after 15 seconds. And yeah it's in a loop
Reply
#9

Bump
Reply
#10

I highly recommend you to use streamer plugin by Incognito, it has some kick ass natives which allow you easier use of 3D text labels.

I'm pretty sure this should work!(not tested)

Код:
foreach(new i : Player)
{
	if(SomeVar[i] == 1)//if it's boolean value you can just use if(SomeVar[i]){...}
	{
		new Text3D:dummy;
		dummy = CreateDynamic3DTextLabel("bla bla bla", -1, 0.0, 0.0, 0.3, 10.0, i, .playerid = playerid);
		SetTimerEx("DummyCallBack", 15000, false, "i", (_:dummy));
	}
}

forward DummyCallBack(Text3D:id);
public DummyCallBack(Text3D:id)
{
	DestroyDynamic3DTextLabel(id);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)