How to create /asay [text]
#1

Hello, how can I create the command /asay [text] for this variable: if(PlayerInfo[playerid][AdminLevel] >= 1) (All lvls, form 1 to 5). Thanks
Reply
#2

Using ZCMD, sscanf :

pawn Код:
CMD:asay(playerid, params[])
{
    new String[100];
    if(PlayerInfo[playerid][AdminLevel] < 1)
        return SendClientMessage(playerid, -1, "You need to be an Adminstrator to use this command!");
    else if(sscanf(params, "s[100]", String))
        return SendClientMessage(playerid, -1, "Usage: /asay <text>");
    else
    {
        GameTextForAll(String, 4000, 3);
    }
    return 1;
}
This will create a gametext for the players saying what you typed.

Next time ask on https://sampforum.blast.hk/showthread.php?tid=413556 please.
Reply
#3

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
Using ZCMD, sscanf :

pawn Код:
CMD:asay(playerid, params[])
{
    new String[100];
    if(PlayerInfo[playerid][AdminLevel] < 1)
        return SendClientMessage(playerid, -1, "You need to be an Adminstrator to use this command!");
    else if(sscanf(params, "s[100]", String))
        return SendClientMessage(playerid, -1, "Usage: /asay <text>");
    else
    {
        GameTextForAll(String, 4000, 3);
    }
    return 1;
}
This will create a gametext for the players saying what you typed.

Next time ask on https://sampforum.blast.hk/showthread.php?tid=413556 please.
humm ok I,ll try.

PD: DUDE!!! long time since the last time I heard from you. (I was banned )
Reply
#4

pawn Код:
COMMAND:asay(playerid,params[])
{
    #pragma unused params
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        new text[128];
        if(sscanf(params, "s[128]", text))
        {
            SendClientMessage(playerid,RED,"Usage: /asay <message>");
            return 1;
        }
        new string[128];
        format(string, sizeof(string), "* Admin %s: %s", GetName(playerid), text);
        SendClientMessageToAll(RED,string);
    }
    else
    {
        SendClientMessage(playerid, RED,"You can't use this commands!");
    }
    return 1;
} // If you want it but with SendClientMessage
Reply
#5

Quote:
Originally Posted by thegreathom
Посмотреть сообщение
pawn Код:
COMMAND:asay(playerid,params[])
{
    #pragma unused params
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        new text[128];
        if(sscanf(params, "s[128]", text))
        {
            SendClientMessage(playerid,RED,"Usage: /asay <message>");
            return 1;
        }
        new string[128];
        format(string, sizeof(string), "* Admin %s: %s", GetName(playerid), text);
        SendClientMessageToAll(RED,string);
    }
    else
    {
        SendClientMessage(playerid, RED,"You can't use this commands!");
    }
    return 1;
} // If you want it but with SendClientMessage
look:
Код:
pwn(1542) : error 017: undefined symbol "GetName"
Reply
#6

Quote:
Originally Posted by Lauder
Посмотреть сообщение
look:
Код:
pwn(1542) : error 017: undefined symbol "GetName"
pawn Код:
CMD:asay(playerid, params[])
{
    new String[100];
    if(PlayerInfo[playerid][AdminLevel] < 1)
        return SendClientMessage(playerid, -1, "You need to be an Adminstrator to use this command!");
    else if(sscanf(params, "s[100]", String))
        return SendClientMessage(playerid, -1, "Usage: /asay <text>");
    else
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(String, 100, "Adminstrator %s : %s", pName, String);
        SendClientMessageToAll(-1, String);
    }
    return 1;
}
Should work
Reply
#7

Why not just
pawn Код:
CMD:asay(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] < 1) return 0;
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /asay <text>");
    new
        text[ 128 ]
    ;
    format(text, 128, "ADMIN: %s", params);
    SendClientMessageToAll(-1, text);
    return 1;
}
?
Reply
#8

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
pawn Код:
CMD:asay(playerid, params[])
{
    new String[100];
    if(PlayerInfo[playerid][AdminLevel] < 1)
        return SendClientMessage(playerid, -1, "You need to be an Adminstrator to use this command!");
    else if(sscanf(params, "s[100]", String))
        return SendClientMessage(playerid, -1, "Usage: /asay <text>");
    else
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(String, 100, "Adminstrator %s : %s", pName, String);
        SendClientMessageToAll(-1, String);
    }
    return 1;
}
Should work
Thank you bro! hoo and... when you finish the Admin system that you are making, I want to be the first one to have it!

PD: And i'm also making one. . |\/| |\/| |\/|... soooooo.... are you going to help me with that admin system that I asked you to install?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)