Help! :D
#1

Hello guys how i want to make when player use commands /ask send client message for admins only i can see it only like lets do /ask for player want help from admins ok and only the admins get it
Reply
#2

anyhelp !!
Reply
#3

Using zcmd and sscanf2 heres a quik one i wrote that should work (unless i missed something) only for rcon as i don't know what admin script you use.
pawn Код:
COMMAND:ask(playerid,params[])
{
    new str[128];
    if(sscanf(params,"s[128]",str))return SendClientMessage(playerid,0xff0000ffFF,"Error: Usage /ask [message]");
    {
        for(new i; i < MAX_PLAYERS;i++)
        {
            if(!IsPlayerConnected(i) || !IsPlayerAdmin(i))continue;
            else
            {
                format(str,sizeof(str),"(%d)%s asks: %s?",playerid,playername(playerid),str);
                SendClientMessage(i,0x00ff00AA,str);
            }
        }
    }
    return 1;
}
stock playername(playerid)//preferably put this way down at the bottom of the script although it doesn't realy matter.
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    return pname;
}
Reply
#4

you don't need to use sscanf for commands with only one parameter.
Reply
#5

I know its just what i'm used to i should have used params only with strlen check.
Like this
pawn Код:
COMMAND:ask(playerid,params[])
{
    if(!strlen(params))return SendClientMessage(playerid,0xff0000ffFF,"Error: Usage /ask [message]");
    {
        for(new i; i < MAX_PLAYERS;i++)
        {
            if(!IsPlayerConnected(i) || !IsPlayerAdmin(i))continue;
            else
            {
                format(params,128,"(%d)%s asks: %s?",playerid,playername(playerid),params);
                SendClientMessage(i,0x00ff00AA,str);
            }
        }
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by iggy1
Посмотреть сообщение
I know its just what i'm used to i should have used params only with strlen check.
Like this
pawn Код:
COMMAND:ask(playerid,params[])
{
    if(!strlen(params))return SendClientMessage(playerid,0xff0000ffFF,"Error: Usage /ask [message]");
    {
        for(new i; i < MAX_PLAYERS;i++)
        {
            if(!IsPlayerConnected(i) || !IsPlayerAdmin(i))continue;
            else
            {
                format(params,128,"(%d)%s asks: %s?",playerid,playername(playerid),params);
                SendClientMessage(i,0x00ff00AA,str);
            }
        }
    }
    return 1;
}
Wrong.
Or... It would work, but isnull is more efficient than strlen.

This forum requires that you wait 120 seconds between posts. Please try again in 80 seconds.
Reply
#7

this way is nice but i need to send for all admins not me only
Reply
#8

Quote:
Originally Posted by LarzI
Wrong.
Isnull is a seperate function which i don't use. Its not wrong at all. If it was inefficient beyond beleif i'd understand but that won't real make a difference on performance at all, its one command.
Reply
#9

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Isnull is a seperate function which i don't use. Its not wrong at all. If it was inefficient beyond beleif i'd understand but that won't real make a difference on performance at all, its one command.
It's not wrong, but there's no point in using strlen when isnull exists, I'm assuming params is at least 169 characters long which means isnull is about 169 times faster than strlen.

OT:
How do you check if someone is an admin? PlayerInfo[playerid][Admin]?

Edit:
Oh, I didn't see my post so I thought it wasn't created

Then change IsPlayerAdmin(i) for PlayerInfo[playerid][admin]
Reply
#10

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Isnull is a seperate function which i don't use. Its not wrong at all. If it was inefficient beyond beleif i'd understand but that won't real make a difference on performance at all, its one command.
Read my full post, mister.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)