Need help with Attach3DTextLabelToPlayer
#9

First, if you type adutyon twice with that code, you will have 2 similar labels on your head.
Second, those 3d text labels will get bugged, and maybe show to non admin players.
So I recommend you to create all labels on OnGameModeInit and Destroy them on OnGameModeExit (Same if you are using the filterscripts, just place the code on OnFilterScriptInit and OnFilterScriptExit)
Everytime a player connects, attach the label to him, and everytime a player disconnects, Update the label to " " (Space), so the next player to join with the same ID as a previous admin, won't get a label on his head saying "Fuck Off (Admin Off Duty)"...
Here is the code:
pawn Код:
new Text3D:aduty[MAX_PLAYERS];

public OnGameModeInit()     // or public OnFilterScriptInit()
{
     for(new i = 0; i < 100; i++) aduty[i] = Create3DTextLabel(" ", 30.0, 40.0, 50.0, 40.0, 0);
     return 1;
}
public OnGameModeExit()     // or public OnFilterScriptExit()
{
     for(new i = 0; i < 100; i++) Delete3DTextLabel(aduty[i]);
     return 1;
}
public OnPlayerConnect(playerid)
{
     Attach3DTextLabelToPlayer(aduty[playerid], playerid, 0.0, 0.0, 0.3);
     return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
     Update3DTextLabelText(aduty[playerid], COLOR_YELLOW, " ");
     return 1;
}
CMD:adutyon(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
         new string[128];
         Update3DTextLabelText(aduty[playerid], COLOR_YELLOW, "Admin On Duty");
         SetPlayerColor(playerid, 0x00FBFFAA);
         SetPlayerHealth(playerid, 99999);
         SetPlayerArmour(playerid, 99999);
         GivePlayerWeapon(playerid, 38, 60000);
         format(string, sizeof(string), "The admin %s is on Admin Duty now, If you need support or help just /report to admin (Don't spam or abuse it)", GetPlayerNameEx(playerid));
         SendClientMessageToAll(COLOR_CYAN, string);
         SendClientMessage(playerid, COLOR_WHITE, "Admin Duty on rules: Max report time to accept or deny is 30 seconds, You must help to players if they request, If you saw a bug, report it to scripter");
    }
    else SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    return 1;
}

CMD:adutyoff(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
         new string[128];
         Update3DTextLabelText(aduty[playerid], COLOR_TWRED, "Fuck Off (Admin Off Duty)");
         SetPlayerColor(playerid, COLOR_TWWHITE);
         SetPlayerHealth(playerid, 100);
         SetPlayerArmour(playerid, 100);
         format(string, sizeof(string), "The admin %s is off Admin Duty now, If you need support or help just go fuck yourself and dont bother him!", GetPlayerNameEx(playerid));
         SendClientMessageToAll(COLOR_TWRED, string);
    }
    else SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    return 1;
}
Edit: You don't need to add/change anything here This was all, easy and not too complicated.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)