Textdraw in makeadmin command.(Just first time working with textdraws)
#1

So I want to show a textdraw with Promoted to player who is promoted.. How I can do it?
And show his lvl of admin too.

Thanks.
pawn Код:
YCMD:makeadmin(playerid,params[],help)
{
    if(PlayerInfo[playerid][pAdmin] >= 1337) //the one who typed it
    {
        new string[128],name[MAX_PLAYER_NAME],pID,Level;
        GetPlayerName(playerid,name,MAX_PLAYER_NAME);
        if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GRAY,"/makeadmin <player> <level>");
        if(IsPlayerConnected(pID))
        {
            if(PlayerInfo[pID][pAdmin] != Level) //why not let RCON admins have admin...?
            {
                PlayerInfo[pID][pAdmin] = Level;
                format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
                SendClientMessageToAll(COLOR_RED,string);
                TDEditor_PTD[pID][0] = CreatePlayerTextDraw(pID, 20.600341, 111.833343, "Promoted");
                PlayerTextDrawLetterSize(pID, TDEditor_PTD[pID][0], 0.382196, 2.183332);
                PlayerTextDrawTextSize(pID, TDEditor_PTD[pID][0], 124.000000, 0.000000);
                PlayerTextDrawAlignment(pID, TDEditor_PTD[pID][0], 1);
                PlayerTextDrawColor(pID, TDEditor_PTD[pID][0], -1);
                PlayerTextDrawUseBox(pID, TDEditor_PTD[pID][0], 1);
                PlayerTextDrawBoxColor(pID, TDEditor_PTD[pID][0], 255);
                PlayerTextDrawSetShadow(pID, TDEditor_PTD[pID][0], 2);
                PlayerTextDrawSetOutline(pID, TDEditor_PTD[pID][0], 0);
                PlayerTextDrawBackgroundColor(pID, TDEditor_PTD[pID][0], 255);
                PlayerTextDrawFont(pID, TDEditor_PTD[pID][0], 2);
                PlayerTextDrawSetProportional(pID, TDEditor_PTD[pID][0], 1);
                PlayerTextDrawSetShadow(pID, TDEditor_PTD[pID][0], 2);
            }
            else return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
        }
        else return SendClientMessage(playerid, COLOR_RED, "Invalid Player Specified.");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You don't have access to this command.");
    return 1;
}
Reply
#2

First thing, i advise you to quit the usage of if() { //blabla } else return blabla like
PHP код:
if(IsPlayerConnected(id))
{
    
//code
}
else return 
SendClientMessage(playerid, -1"Not connected"); 
You can do, more readable and get rid of lot of brackets "{ }"
PHP код:
if(!IsPlayerConnect(id)) return SendClientMessage(playerid, -1"Not connected");
//code 
First thing i'd do is convert the code for you to the more readable one
pawn Код:
CMD:makeadmin(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_RED, "You don't have access to this command.");
    new string[128],name[MAX_PLAYER_NAME],pID,Level;
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GRAY,"/makeadmin <player> <level>");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Invalid Player Specified.");
    if(PlayerInfo[pID][pAdmin] == Level) return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
    PlayerInfo[pID][pAdmin] = Level;
    format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
    SendClientMessageToAll(COLOR_RED,string);
    TDEditor_PTD[pID][0] = CreatePlayerTextDraw(pID, 20.600341, 111.833343, "Promoted");
    PlayerTextDrawLetterSize(pID, TDEditor_PTD[pID][0], 0.382196, 2.183332);
    PlayerTextDrawTextSize(pID, TDEditor_PTD[pID][0], 124.000000, 0.000000);
    PlayerTextDrawAlignment(pID, TDEditor_PTD[pID][0], 1);
    PlayerTextDrawColor(pID, TDEditor_PTD[pID][0], -1);
    PlayerTextDrawUseBox(pID, TDEditor_PTD[pID][0], 1);
    PlayerTextDrawBoxColor(pID, TDEditor_PTD[pID][0], 255);
    PlayerTextDrawSetShadow(pID, TDEditor_PTD[pID][0], 2);
    PlayerTextDrawSetOutline(pID, TDEditor_PTD[pID][0], 0);
    PlayerTextDrawBackgroundColor(pID, TDEditor_PTD[pID][0], 255);
    PlayerTextDrawFont(pID, TDEditor_PTD[pID][0], 2);
    PlayerTextDrawSetProportional(pID, TDEditor_PTD[pID][0], 1);
    PlayerTextDrawSetShadow(pID, TDEditor_PTD[pID][0], 2);
    return 1;
}
And now to your issue, you want the textdraw to saw "Promoted to lvl x" ?
format a string..
PHP код:
new string[50]; format(string50"Promoted to %d"Level);
TDEditor_PTD[pID][0] = CreatePlayerTextDraw(pID20.600341111.833343string); 
Oh and, i see you missing PlayerTextDrawShow
PHP код:
PlayerTextDrawShow(pIDTDEditor_PTD[pID][0]); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)