Admin Prefixes Help
#1

So i need help about AdminPrefixes. Can anyone help me?
Reply
#2

Can you be more specific with what you need help with?
Reply
#3

Yea. So i make /makeadmin command but i want when i type that to give prefix [Admin]MyName.
Reply
#4

PHP код:
new pName[24], str[MAX_PLAYER_NAME 7];
GetPlayerName(idpNamesizeof(pName));
format(strsizeof(str), "[Admin]%s"pName);
SetPlayerName(idstr); 
Reply
#5

Quote:
Originally Posted by JaKe Elite
Посмотреть сообщение
PHP код:
new pName[24], str[MAX_PLAYER_NAME 7];
GetPlayerName(idpNamesizeof(pName));
format(strsizeof(str), "[Admin]%s"pName);
SetPlayerName(idstr); 
wouldn't that mess up the file saving/reading system?
Reply
#6

Quote:
Originally Posted by JaKe Elite
Посмотреть сообщение
PHP код:
new pName[24], str[MAX_PLAYER_NAME 7];
GetPlayerName(idpNamesizeof(pName));
format(strsizeof(str), "[Admin]%s"pName);
SetPlayerName(idstr); 
lol? This could've been done a lot better just under OnPlayerText
Reply
#7

Quote:
Originally Posted by Ritzy
Посмотреть сообщение
lol? This could've been done a lot better just under OnPlayerText
That's not the point, changing the player's name will fuck the reading/saving up,
anyway i made this
PHP код:
new adminchat[MAX_PLAYERS];
CMD:admchat(playerid,params[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,".: Unauthorized cmd! :.");
    if(
adminchat[playerid])
   {
        
adminchat[playerid]=false;
        
SendClientMessage(playerid,-1,".: Admin chat off! :.");
        }
    else
    {
        
adminchat[playerid]=true;
        
SendClientMessage(playerid,-1,".: Admin chat on! :.");
        }
    return 
1;
}
public 
OnPlayerDisconnect(playerid,reason)
{
    
adminchat[playerid]=false;
    return 
1;
}
public 
OnPlayerText(playerid,text[])
{
    if(
adminchat[playerid])
    {
    new 
name[26],string[126];
    
GetPlayerName(playerid,name,sizeof(name));
    
format(string,sizeof(string),"[Admin]%s: {FFFFFF}%s",name,text);
    
SendClientMessageToAll(GetPlayerColor(playerid),string);
    return 
0;
    }
return 
1;

or here's a cmd i found in some old script and shifted it.
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/admchat"cmdtexttrue10) == 0)
    {
        if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"Unauthoerized cmd");
        
GetPlayerName(playeridnamesizeof(name));
        new 
length strlen(cmdtext);
        while ((
idx length) && (cmdtext[idx] <= ' '))
        {
            
idx++;
            }
        new 
offset idx;
        new 
result[200];
        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
        {
            
result[idx offset] = cmdtext[idx];
            
idx++;
            }
        
result[idx offset] = EOS;
        if(!
strlen(result))
        {
            
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /admchat [admin chat]");
            return 
1;
            }
        
format(stringsizeof(string), "[Admin]%s:{FFFFFF} %s ",nameresult);
          
SendClientMessageToAll(GetPlayerColor(playerid),string);
        return 
1;
        }
return 
0;

Reply
#8

Can i make it with "if" which is under onplayertext here's my enum:

enum PlayerInfo
{
Pass[129],
pAdmin,
pMoney,
pLevels
}

it need to be something like this:

if(PlayerInfo[playerid][pAdmin] == 1)
{
new pName[MAX_PLAYER_NAME], msg[256];
GetPlayerName(playerid, pName, 24);
format(msg, sizeof(msg), "{00CC00}[{FFFFFF}Admin{00CC00}]{FF0000}%s{00CC00}[ID: %d]: {FFFFFF}%s",pName, playerid, text);
SetPlayerColor(playerid, 0xFF0000FF);
SendClientMessageToAll(GetPlayerColor(playerid), msg);
return 0;
}

Can anyone do that but with my enum please ?
Reply
#9

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
That's not the point, changing the player's name will fuck the reading/saving up,
anyway i made this
PHP код:
new adminchat[MAX_PLAYERS];
CMD:admchat(playerid,params[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,".: Unauthorized cmd! :.");
    if(
adminchat[playerid])
   {
        
adminchat[playerid]=false;
        
SendClientMessage(playerid,-1,".: Admin chat off! :.");
        }
    else
    {
        
adminchat[playerid]=true;
        
SendClientMessage(playerid,-1,".: Admin chat on! :.");
        }
    return 
1;
}
public 
OnPlayerDisconnect(playerid,reason)
{
    
adminchat[playerid]=false;
    return 
1;
}
public 
OnPlayerText(playerid,text[])
{
    if(
adminchat[playerid])
    {
    new 
name[26],string[126];
    
GetPlayerName(playerid,name,sizeof(name));
    
format(string,sizeof(string),"[Admin]%s: {FFFFFF}%s",name,text);
    
SendClientMessageToAll(GetPlayerColor(playerid),string);
    return 
0;
    }
return 
1;

or here's a cmd i found in some old script and shifted it.
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/admchat"cmdtexttrue10) == 0)
    {
        if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"Unauthoerized cmd");
        
GetPlayerName(playeridnamesizeof(name));
        new 
length strlen(cmdtext);
        while ((
idx length) && (cmdtext[idx] <= ' '))
        {
            
idx++;
            }
        new 
offset idx;
        new 
result[200];
        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
        {
            
result[idx offset] = cmdtext[idx];
            
idx++;
            }
        
result[idx offset] = EOS;
        if(!
strlen(result))
        {
            
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /admchat [admin chat]");
            return 
1;
            }
        
format(stringsizeof(string), "[Admin]%s:{FFFFFF} %s ",nameresult);
          
SendClientMessageToAll(GetPlayerColor(playerid),string);
        return 
1;
        }
return 
0;

Where did I said you need to change the player's name?
You just got to compare if he's on duty then add a [Admin] tag before his name, send his msg and return 0 so that server doesn't do it since we're sending the msg manually.
Reply
#10

Quote:
Originally Posted by Ritzy
Посмотреть сообщение
Where did I said you need to change the player's name?
You just got to compare if he's on duty then add a [Admin] tag before his name, send his msg and return 0 so that server doesn't do it since we're sending the msg manually.
where did i say that you said to change the name? i meant that its not about this "could've been done a lot better just under OnPlayerText" what i meant was his way of setting the player's name will not work at all and will confuse the file reading system.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)