Scripting Help. Admin Chat
#1

ok, so i'm trying to make it where all admins level 1 to 9999, able to use /a, i've changed the admin level in the script, but still has'nt worked. if anyone know how to do that, please fix this for me it only lets admins 2 - 9999 use /a only, not level 1 admins :S i needa know how to make it so they can too

if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/a", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/a)dmin [admin chat]");
return 1;
}
format(string, sizeof(string), "*%d Admin %s: %s", PlayerInfo[playerid][pAdmin], sendername, result);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
SendAdminMessage(COLOR_YELLOW, string);
}
printf("Admin %s: %s", sendername, result);
}
Reply
#2

Quote:
Originally Posted by Floyd_Pink
Посмотреть сообщение
ok, so i'm trying to make it where all admins level 1 to 9999, able to use /a, i've changed the admin level in the script, but still has'nt worked. if anyone know how to do that, please fix this for me it only lets admins 2 - 9999 use /a only, not level 1 admins :S i needa know how to make it so they can too

if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/a", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/a)dmin [admin chat]");
return 1;
}
format(string, sizeof(string), "*%d Admin %s: %s", PlayerInfo[playerid][pAdmin], sendername, result);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
SendAdminMessage(COLOR_YELLOW, string);
}
printf("Admin %s: %s", sendername, result);
}
change
pawn Код:
if (PlayerInfo[playerid][pAdmin] >= 1)
to
pawn Код:
if (PlayerInfo[playerid][pAdmin] > 0)
Reply
#3

Quote:
Originally Posted by admantis
Посмотреть сообщение
change
pawn Код:
if (PlayerInfo[playerid][pAdmin] >= 1)
to
pawn Код:
if (PlayerInfo[playerid][pAdmin] > 0)
should work like the way its right there
>= means "is the same as or higher as 1"
> 0 means "is higher than 0"
does the same.
Reply
#4

Quote:
Originally Posted by notime
Посмотреть сообщение
should work like the way its right there
>= means "is the same as or higher as 1"
> 0 means "is higher than 0"
does the same.
seriously? lol i didnt know that, sorry
Reply
#5

Quote:
Originally Posted by admantis
Посмотреть сообщение
seriously? lol i didnt know that, sorry
yeah, but its still strange it only works for 2 or above. because i understand ur post with changing it to > 0. it could be a bug of pawno(wich i doubt) or script wise. I think theres more in that command than that hes posting.

It could be a copy&paste mistake, but theres 1 closing bracket("}") missing, tho i dont think this is bugging the command.

by the way, if u use the command as a level 1 admin, does it say anything? if not: show us the
"public SendAdminMessage(color, string[])"
Reply
#6

Gosh, Why you have to make evrything so advanced?

pawn Код:
if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/a", true) == 0)
{
    new result[128], str[128], sendername[20];
    result = strtok(cmdtext, idx);
    GetPlayerName(playerid, sendername, 20);

    if(!strlen(strval(result))) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/a)dmin [admin chat]");

    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        format(string, sizeof(string), "*%d Admin %s: %s", PlayerInfo[playerid][pAdmin], sendername, strval(result));
        SendAdminMessage(COLOR_YELLOW, string);
        printf("Admin %s: %s", sendername, strval(result));
    }
    return 1;
}
Reply
#7

That code won't work
pawn Код:
result = strtok(cmdtext, idx);
strtok will return the next word separated by a space ( not the whole line )
pawn Код:
if(!strlen(strval(result)))
is incorrect, strval returns an integer

also, you have %s in the format, and you are formatting an integer.
you have defined str[128] and then used string
try this
pawn Код:
if(!strcmp(cmd, "/admin", true) || !strcmp(cmd, "/a", true))
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new result[128], str[128], sendername[MAX_PLAYER_NAME];
        strmid(result,cmdtext,idx,strlen(cmdtext),sizeof(result));
        if(!strlen(result)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/a)dmin [admin chat]");
   
        GetPlayerName(playerid,sendername,sizeof(sendername));
        format(str, sizeof(str), "*%d Admin %s: %s", PlayerInfo[playerid][pAdmin], sendername, result);
        SendAdminMessage(COLOR_YELLOW, str);
        return 1;
    }
    SendClientMessage(playerid,COLOR_GRAD2,"Unauthorized command");
    return 1;
}
In this instance, idx will already hold the reference for the start of the 'chat' portion of cmdtext
Reply
#8

well, i fixed it so that level 1 admins are able to talk in it, thanks for the help...but, now i have the problem they can't see what we say in /a unless they a 2 or higher admin :S

you know how to fix that one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)