Problem with admin chat :|
#1

I made this code:

pawn Код:
if(strcmp(cmd, "/a", true) == 0)
    {
        if(adminlevel[playerid] >= 1)
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new texto[128];
            texto = bigstrtok(cmdtext, idx);
            if(!strlen(texto))
            {
                SendClientMessage(playerid, ORANGE, "USO: /a [texto]");
                return 1;
            }
            if(logged[playerid] == 1)
            {
                foreach(Player, i)
                {
                    if(adminlevel[i] >= 1)
                    {
                        new achat[128];
                        format(achat, 128, "Rango: %d [ID: %d] %s: %s", adminlevel[i], i, sendername, texto);
                        SendClientMessage(i, COLOR_ORANGE, achat);
                        return 1;
                    }
                    else if(adminlevel[i] == 0) return 0;
                }
            }
            else SendClientMessage(playerid, COLOR_RED, "Tenes que estar logeado para usar este comando!");
        }
        else SendClientMessage(playerid, RED, "No estas autorizado a utilizar este comando."); return 1;
    }
The problem is that only works for ID 0, and I made a loop OMG
Thanks
Reply
#2

Well i just read first line and i see you use CHAT as command
WRONG!
Use on player text and if it begin with # (for example)get text after # and send client message to admins...
Reply
#3

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Well i just read first line and i see you use CHAT as command
WRONG!
Use on player text and if it begin with # (for example)get text after # and send client message to admins...
It's not wrong using a command, /a [text]

Anyways, I solved it, I just had to remove return 1;

Thanks!
Reply
#4

A useful tip for any future commands:

Instead of creating loads of unnecessary structures, such as 'if(adminlevel[playerid] >= 1)', simply do:

if(adminlevel[playerid] < 1) return SendClientMessage(playerid, RED, "No estas autorizado a utilizar este comando.");

By doing this you will keep your structures organised and can easily see what code is where (to prevent your problem from happening again).

-Conroy
Reply
#5

Quote:
Originally Posted by Conroy
Посмотреть сообщение
A useful tip for any future commands:

Instead of creating loads of unnecessary structures, such as 'if(adminlevel[playerid] >= 1)', simply do:

if(adminlevel[playerid] < 1) return SendClientMessage(playerid, RED, "No estas autorizado a utilizar este comando.");

By doing this you will keep your structures organised and can easily see what code is where (to prevent your problem from happening again).

-Conroy
Oh, yea, it could be.. but I am used like that XD

Thanks for the tip
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)