Problem with removing text label
#1

Hello guys,

I'm scripting i have been working on a casino script since a few days and i have a problem with removing a 3d textlabel. It removes for the player who peformed the command, But it doesn't remove for other players inside the casino.
http://i.imgur.com/r7Zl9iS.jpg

Code:
Код:
YCMD:hostroulette(playerid, params[]) {
	new betmin,betmax;
	new string[128];
	new Text3D:roulette = Create3DTextLabel("CASINO", X11_ORANGE, 30.0, 40.0, 50.0, 40.0, 0);
	if(!sscanf(playerid,params,"ii",betmin,betmax)) {
	 	if(GetPVarInt(playerid,"hosting") == 1)
    	        {
    	               DeletePlayer3DTextLabel(playerid, roulette);
        	       SendClientMessage(playerid, X11_TOMATO_2,"[CASINO] You stopped hosting roulette.");
	               SetPVarInt(playerid, "hosting", 0);
        	       SetPVarInt(playerid, "MinimumBet", 0);
        	       SetPVarInt(playerid, "MaximumBet", 0);
    	         } else {
			SetPVarInt(playerid, "MinimumBet", betmin);
			SetPVarInt(playerid, "MaximumBet", betmax);
			SetPVarInt(playerid, "hosting", 1);
			Attach3DTextLabelToPlayer(roulette, playerid, 0.0, 0.0, 0.4);
			format(string, sizeof(string), "Roulette Dealer\n $%d - $%d", betmin, betmax);
			Update3DTextLabelText(roulette, X11_ORANGE, string);
		}
	} else {
	    SendClientMessage(playerid, X11_TOMATO_2,"[CASINO] /hostroulette [minimumbet] [maximumbet]");
	}
	if(IsPlayerInRangeOfPoint(playerid, 30.0, 2235.9666, 1613.1771, 1006.1797)) {
    } else {
 		SendClientMessage(playerid, X11_TOMATO_2, "You are not in a casino or not close enough at the roulette tables!");
 	}
 	return 1;
}
Reply
#2

Player label or Global label?
Your case is GLOBAL: Delete3DTextLabel(roulette);
Reply
#3

Once the label is created it can't be destroyed because you use a local variable. In other words, the label exists in the world but its id is no longer stored anywhere. You must use a static variable instead. Probably a MAX_PLAYER array, as well.
Reply
#4

@F1N4L Thanks for your help <3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Once the label is created it can't be destroyed because you use a local variable. In other words, the label exists in the world but its id is no longer stored anywhere. You must use a static variable instead. Probably a MAX_PLAYER array, as well.
How ?
Reply
#5

Can someone help?
Reply
#6

BUMP
Reply
#7

PHP код:
new
    
Text3Dg_myLabel[MAX_PLAYERS]; // Global array (goes on top of your script before the includes. I meant after but wrote before, oops) 
    
// Creating / attaching
g_myLabel[playerid] = Create3DTextLabel(...);
Attach3DTextLabelToPlayer(playeridg_myLabel[playerid], ...);
// Destroying
Delete3DTextLabel(g_myLabel[playerid]); 
Reply
#8

Quote:
Originally Posted by Sjn
Посмотреть сообщение
PHP код:
new
    
Text3Dg_myLabel[MAX_PLAYERS]; // Global array (goes on top of your script before the includes)   (I have this after includes)
    
// Creating / attaching
g_myLabel[playerid] = Create3DTextLabel(...);
Attach3DTextLabelToPlayer(playeridg_myLabel[playerid], ...);
// Destroying
Delete3DTextLabel(g_myLabel[playerid]); 
Thanks this will help me to understand it
Reply
#9

The label is still above the player's head
Reply
#10

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)