help with 3dlabels
#1

label not showing and yes i tested it on other player

Код:
CMD:adminduty(playerid,params[])
{
	new string[128],pName[MAX_PLAYER_NAME];
	new Text3D:label[MAX_PLAYERS];
	if(PInfo[playerid][Level] < 1)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to go on admin duty.");
    CMDMessageToAdmins(playerid,"ADMINDUTY");
    if(PInfo[playerid][pAdminDuty] == 0)
	{
            PInfo[playerid][God] = 1;
            PInfo[playerid][GodCar] = 1;
            PInfo[playerid][pAdminDuty] = 1;
            SetPlayerHealth(playerid,100000);
    	    SetPlayerSkin(playerid,217);
    	    ResetPlayerWeapons(playerid);
    	    GivePlayerWeapon(playerid,38,99999);
			GetPlayerName(playerid,pName,sizeof pName);
			format(string,sizeof(string),"Administrator %s is now on Admin Duty.",pName);
			SendClientMessageToAll(COLOR_MENUHIGHLIGHT,string);
			label[playerid] = Create3DTextLabel("!!ADMIN ON DUTY\n DO NOT ATTACK!!!",COLOR_GREEN,30.0, 40.0, 50.0, 40.0, 0);
			Attach3DTextLabelToPlayer(label[playerid],playerid,0.0,0.0,0.7);
	}
	else
	{
            PInfo[playerid][God] = 0;
            PInfo[playerid][GodCar] = 0;
			PInfo[playerid][pAdminDuty] = 0;
       	    GetPlayerName(playerid,pName,sizeof pName);
			format(string,sizeof(string),"Administrator %s is now off Admin Duty.",pName);
			SendClientMessageToAll(COLOR_MENUHIGHLIGHT,string);
        	SetPlayerHealth(playerid,0.0);
        	Delete3DTextLabel(label[playerid]);
    }
    return 1;
}
Reply
#2

pawn Код:
new Text3D:label[MAX_PLAYERS];

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];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(!PInfo[playerid][pAdminDuty])
    {
        PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 1;
        SetPlayerHealth(playerid, 0x7F800000);
        SetPlayerSkin(playerid, 217);
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 38, 99999);
        format(string, sizeof(string), "Administrator %s is now on Admin Duty.", pName);
        label[playerid] = Create3DTextLabel("!!ADMIN ON DUTY\nDO NOT ATTACK!!!", COLOR_GREEN, 30.0, 40.0, 50.0, 40.0, 0);
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
    }
    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);
        SetPlayerHealth(playerid, 0.0); //Really? Why 0 health?
        Delete3DTextLabel(label[playerid]);
    }
    SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
    return 1;
}
The 'new Text3D:label[MAX_PLAYERS]' line needs to go at the top of your script. This is a global variable, so you have a value saved when you attempt to delete it.

Also, you were using an 'else' statement, when you should have been using an 'else if' statement.

Basically:
pawn Код:
new variable = 0;
if(variable == 0)
{
    variable = 1;
}
else
{
    variable = 0;
}
Variable starts off as 0, so the first 'if' statement gets called. Variable is now equal to '1'. Once we reach the 'else' statement, the variable is not equal to 0 anymore, so this else statement gets called. Variable is now equal to 0 again, so we're back where we started.

By using an 'else if' statement, this pretty much decides which one should be called at the time the first 'if' statement is called.

References:
https://sampwiki.blast.hk/wiki/Control_Structures
Reply
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
new Text3D:label[MAX_PLAYERS];

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];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(!PInfo[playerid][pAdminDuty])
    {
        PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 1;
        SetPlayerHealth(playerid, 0x7F800000);
        SetPlayerSkin(playerid, 217);
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 38, 99999);
        format(string, sizeof(string), "Administrator %s is now on Admin Duty.", pName);
        label[playerid] = Create3DTextLabel("!!ADMIN ON DUTY\nDO NOT ATTACK!!!", COLOR_GREEN, 30.0, 40.0, 50.0, 40.0, 0);
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
    }
    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);
        SetPlayerHealth(playerid, 0.0); //Really? Why 0 health?
        Delete3DTextLabel(label[playerid]);
    }
    SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
    return 1;
}
The 'new Text3D:label[MAX_PLAYERS]' line needs to go at the top of your script. This is a global variable, so you have a value saved when you attempt to delete it.

Also, you were using an 'else' statement, when you should have been using an 'else if' statement.

Basically:
pawn Код:
new variable = 0;
if(variable == 0)
{
    variable = 1;
}
else
{
    variable = 0;
}
Variable starts off as 0, so the first 'if' statement gets called. Variable is now equal to '1'. Once we reach the 'else' statement, the variable is not equal to 0 anymore, so this else statement gets called. Variable is now equal to 0 again, so we're back where we started.

By using an 'else if' statement, this pretty much decides which one should be called at the time the first 'if' statement is called.

References:
https://sampwiki.blast.hk/wiki/Control_Structures
thanks for your help,now i get it and about that 0.0 health,i don't want admins to abuse it
is there anything wrong with 0.0?
Reply
#4

Well, it will kill them for starters. Why don't you just save their previous health?

pawn Код:
new Text3D:label[MAX_PLAYERS];
new Float:OldHealth[MAX_PLAYERS];

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];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(!PInfo[playerid][pAdminDuty])
    {
        PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 1;
        GetPlayerHealth(playerid, OldHealth[playerid]);
        SetPlayerHealth(playerid, 0x7F800000);
        SetPlayerSkin(playerid, 217);
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 38, 99999);
        format(string, sizeof(string), "Administrator %s is now on Admin Duty.", pName);
        label[playerid] = Create3DTextLabel("!!ADMIN ON DUTY\nDO NOT ATTACK!!!", COLOR_GREEN, 30.0, 40.0, 50.0, 40.0, 0);
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
    }
    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);
        SetPlayerHealth(playerid, OldHealth[playerid]); //Really? Why 0 health?
        Delete3DTextLabel(label[playerid]);
    }
    SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
    return 1;
}
Reply
#5

yes but still i need to save everything like skin,old class,team,health,armour,guns anyways i will make this
Reply
#6

well sorry for double post but its still not working

i can't see 3dtextonhead,i test it with my friend
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)