error tag administrator
#1

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);
}

Reply
#2

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.
Reply
#3

Код:
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.
Reply
#4

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
Reply
#5

so what if the old
Reply
#6

Answer
Reply
#7

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

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
Reply
#9

Answer??
Reply
#10

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); 
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)