Help with 3d textlabel
#1

I can't get this labels to work...

Код:
CMD:adminduty(playerid, params[])
{
	if(!PInfo[playerid][Level])
	return SendClientMessage(playerid, STEALTH_BLUE, "You need to be level 1 to go on admin duty.");
	CMDMessageToAdmins(playerid, "ADMINDUTY");
	new string[55], pName[MAX_PLAYER_NAME];
	new Text3D:AdminLabel;
	GetPlayerName(playerid, pName, sizeof(pName));
	if(!PInfo[playerid][pAdminDuty])
	{
		PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 1;
		GetPlayerArmour(playerid, OldArmour[playerid]);
		OldSkin[playerid] = GetPlayerSkin(playerid);
		GetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
  		for(new i; i < 13; ++i)
		{
			GetPlayerWeaponData(playerid, i, OldWeapon[playerid][i], OldAmmo[playerid][i]);
		}
		SetPlayerSkin(playerid, 217);
		ResetPlayerWeapons(playerid);
		GivePlayerWeapon(playerid, 38, 99999);
		format(string, sizeof(string), "Administrator %s is now on Admin Duty.", pName);
		AdminLabel = Create3DTextLabel("ADMIN ON DUTY\nDO NOT ATTACK",0x33DD1100,0.0, 0.0, 0.0, 40.0, 0, 0);
		Attach3DTextLabelToPlayer(AdminLabel,playerid, 0.0, 0.0, 0.7);
		if(PInfo[playerid][ASP] == 1)
		OldHealth[playerid] = 100.0;
		else GetPlayerHealth(playerid, OldHealth[playerid]);
	}
	else if(PInfo[playerid][pAdminDuty])
	{
		PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 0;
		format(string, sizeof(string), "Administrator %s is now off Admin Duty.", pName);
		SetPlayerSkin(playerid,OldSkin[playerid]);
		SetPlayerHealth(playerid,OldHealth[playerid]);
		SetPlayerArmour(playerid, OldArmour[playerid]);
		SetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
		ResetPlayerWeapons(playerid);
		for(new i; i < 13; ++i)
		{
			GivePlayerWeapon(playerid, OldWeapon[playerid][i], OldAmmo[playerid][i]);
		}
		Delete3DTextLabel(AdminLabel);
	}
	SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
	return 1;
}
Reply
#2

Quote:
Originally Posted by Nabster
Посмотреть сообщение
I can't get this labels to work...
The Code should work

So...are there any errors or warnings?

Maybe use the crashdetect Plugin to see if your Code get an error somewhere.

Greekz
Reply
#3

Probably define AdminLabel this way :
Код:
AdminLabel[MAX_PLAYERS]; 
AdminLabel[playerid] = Create3DTextLabel("ADMIN ON DUTY\nDO NOT ATTACK",0x33DD1100,0.0, 0.0, 0.0, 40.0, 0, 0);
Delete3DTextLabel(AdminLabel[playerid]);
Edit : use print("line ( 1 , 2 ... n )") in multiple lines to see when the code ends.

Edit 2: after reading it well, I saw the flaw and its that you don't return after going on duty offduty
what you code does is :
if ( off duty )
set duty on ( you should just return 1 here )
if ( on duty )
set duty off. ( same thing )
Код:
CMD:adminduty(playerid, params[])
{
	if(!PInfo[playerid][Level])
	return SendClientMessage(playerid, STEALTH_BLUE, "You need to be level 1 to go on admin duty.");
	CMDMessageToAdmins(playerid, "ADMINDUTY");
	new string[55], pName[MAX_PLAYER_NAME];
	new Text3D:AdminLabel;
	GetPlayerName(playerid, pName, sizeof(pName));
	if(!PInfo[playerid][pAdminDuty])
	{
		PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 1;
		GetPlayerArmour(playerid, OldArmour[playerid]);
		OldSkin[playerid] = GetPlayerSkin(playerid);
		GetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
  		for(new i; i < 13; ++i)
		{
			GetPlayerWeaponData(playerid, i, OldWeapon[playerid][i], OldAmmo[playerid][i]);
		}
		SetPlayerSkin(playerid, 217);
		ResetPlayerWeapons(playerid);
		GivePlayerWeapon(playerid, 38, 99999);
		format(string, sizeof(string), "Administrator %s is now on Admin Duty.", pName);
		AdminLabel = Create3DTextLabel("ADMIN ON DUTY\nDO NOT ATTACK",0x33DD1100,0.0, 0.0, 0.0, 40.0, 0, 0);
		Attach3DTextLabelToPlayer(AdminLabel,playerid, 0.0, 0.0, 0.7);
                SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
		if(PInfo[playerid][ASP] == 1)
		OldHealth[playerid] = 100.0;
		else GetPlayerHealth(playerid, OldHealth[playerid]);
                return 1;
	}
	else if(PInfo[playerid][pAdminDuty])
	{
		PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 0;
		format(string, sizeof(string), "Administrator %s is now off Admin Duty.", pName);
		SetPlayerSkin(playerid,OldSkin[playerid]);
		SetPlayerHealth(playerid,OldHealth[playerid]);
		SetPlayerArmour(playerid, OldArmour[playerid]);
		SetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
		ResetPlayerWeapons(playerid);
		for(new i; i < 13; ++i)
		{
			GivePlayerWeapon(playerid, OldWeapon[playerid][i], OldAmmo[playerid][i]);
		}
		Delete3DTextLabel(AdminLabel);
                SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
                return 1;
	}
	return 1;
}
Reply
#4

Quote:
Originally Posted by Golimad
Посмотреть сообщение
Probably define AdminLabel this way
Oh, right there is a mistake.

PHP код:
new Text3D:AdminLabel[MAX_PLAYERS]; //Must be declared global
//Then in the Command
AdminLabel[playerid] = Create3DTextLabel(...); 
But this didnt explained, why it was not attached
Reply
#5

I just explained above why It doesn't get attached.
Actually it does get attached but it gets destroyed right after it.
Reply
#6

Quote:
Originally Posted by Golimad
Посмотреть сообщение
I just explained above why It doesn't get attached.
Actually it does get attached but it gets destroyed right after it.
No, thats false!

PHP код:
new x=1;
if(
x) print("hi"),x=0;
else if(!
x) print("nope"),x=1;
print(
"end"); 
Only hi & end gets called, because of the ELSE if!

The mistake he made is the color: 0x33DD1100

When the alpha is 00...its transparent.

So he need to do sth like this: 0x33DD11FF

Greekz
Reply
#7

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Only hi & end gets called, because of the ELSE if!:
Was just about to point this one out.
The other if check does not get checked as it is an ELSE if.

Anyway, I wonder if Alpha was the problem here.
Reply
#8

I will test it out with my friend and let you know..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)