SA-MP Forums Archive
error tag administrator - 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: error tag administrator (/showthread.php?tid=609065)



error tag administrator - gogo45 - 08.06.2016

why I made the rank adminnator tag mess when I made was not an error, I test into games I setlevel I became moderator adminsnator and others can get messy his tag




I put in the area OnPlayerSpawn
Quote:

if(User[playerid][accountAdmin] >= 0)
{
playermembers[playerid] = CreateDynamic3DTextLabel("", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
}

if(User[playerid][accountAdmin] >= 1)
{
moderator[playerid] = CreateDynamic3DTextLabel("{87A3AE}Moderator", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
}

if(User[playerid][accountAdmin] >= 2)
{
administrator[playerid] = CreateDynamic3DTextLabel("{87A3AE}Administrator", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
}

if(User[playerid][accountAdmin] >= 3)
{
leadadministrator[playerid] = CreateDynamic3DTextLabel("{87A3AE}Lead Administrator", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
}

if(User[playerid][accountAdmin] >= 4)
{
headadministrator[playerid] = CreateDynamic3DTextLabel("{87A3AE}Head Administrator", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
}

if(User[playerid][accountAdmin] >= 5)
{
serverowner[playerid] = CreateDynamic3DTextLabel("{87A3AE}Server Developer", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
}




Re: error tag administrator - Vince - 08.06.2016

If-statements are handled sequentially, top to bottom. Code will just keep executing until it hits a return, or the end of the function.

It is advisable to use a switch in this condition, which could potentially reduce this entire piece of code to 10 lines or less.


Re: error tag administrator - Stinged - 08.06.2016

Код:
if (User[playerid][accountAdmin] >= 1)
{
	PlayerLabel[playerid] = CreateDynamic3DTextLabel("", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
	switch (User[playerid][accountAdmin])
	{
		case 1: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Moderator");
		case 2: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Administrator");
		case 3: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Lead Administrator");
		case 4: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Head Administrator");
		case 5: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Server Developer");
	}
}
SetPlayerHealth(playerid, 100.0);
SetPlayerArmour(playerid, 100.0);
You don't need to create multiple arrays for multiple labels, just use one and change its text depending on the admin's level.


Re: error tag administrator - gogo45 - 08.06.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Код:
if (User[playerid][accountAdmin] >= 1)
{
	PlayerLabel[playerid] = CreateDynamic3DTextLabel("", -1, 0.0, 0.0, -0.9, 20, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
	switch (User[playerid][accountAdmin])
	{
		case 1: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Moderator");
		case 2: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Administrator");
		case 3: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Lead Administrator");
		case 4: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Head Administrator");
		case 5: UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF, "Server Developer");
	}
}
SetPlayerHealth(playerid, 100.0);
SetPlayerArmour(playerid, 100.0);
You don't need to create multiple arrays for multiple labels, just use one and change its text depending on the admin's level.
@Stinged if this is not so an error like that cluttered his tag


Re: error tag administrator - gogo45 - 08.06.2016

so what if the old


Re: error tag administrator - gogo45 - 08.06.2016

Answer


Re: error tag administrator - Dayrion - 08.06.2016

As you can see, you copied/pasted your code without adding intendation. Fixe it and try again.


Re: error tag administrator - gogo45 - 08.06.2016

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
As you can see, you copied/pasted your code without adding intendation. Fixe it and try again.
what should be written on the code down the


Re: error tag administrator - gogo45 - 08.06.2016

Answer??


Re: error tag administrator - Dayrion - 08.06.2016

Try to understand by yourself before asking help.
PHP код:
    if (User[playerid][accountAdmin] >= 1)
    {
        
PlayerLabel[playerid] = CreateDynamic3DTextLabel("", -10.00.0, -0.920playeridINVALID_VEHICLE_ID0, -1, -1, -110.0);
        switch (
User[playerid][accountAdmin])
        {
            case 
1UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF"Moderator");
            case 
2UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF"Administrator");
            case 
3UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF"Lead Administrator");
            case 
4UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF"Head Administrator");
            case 
5UpdateDynamic3DTextLabelText(PlayerLabel[playerid], 0x87A3AEFF"Server Developer");
        }
    }
    
SetPlayerHealth(playerid100.0);
    
SetPlayerArmour(playerid100.0);