/kick and admin chat
#1

so here is my admin kick

pawn Код:
dcmd_kick(playerid, params[])
{
    new pid;
    if(sscanf(params, "us", pid, params[2])) return SendClientMessage(playerid, Yellow, "Command Usage: /kick <playerid> <reason>");
    if(level[playerid] >= 1)
    {
        if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, Red, "Player is not connected");
        new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
        GetPlayerName(pid, paramname, sizeof(paramname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "%s has been kicked by %s for: %s", paramname, adminname, params[2]);
        SendClientMessageToAll(AdminColor, string);
        SendClientMessage(pid, AdminColor, "You have been kicked by %s for: %s", adminname, params[2]);
        Kick(pid);
    } else return 0;
    return 1;
}
and this is line the error is
pawn Код:
SendClientMessage(pid, AdminColor, "You have been kicked by %s for: %s", adminname, params[2]);
pawn Код:
E:\GTA San Andreas\Server\gamemodes\DMTest.pwn(333) : warning 202: number of arguments does not match definition
E:\GTA San Andreas\Server\gamemodes\DMTest.pwn(333) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Warnings.
I think I did a mistake with admin name and the params..


and also how can I change example the admin chat from # to /a or something else? Currently the admin chat is under OnPlayerText, should I just make it out of dcmd and put it under onplayercommandtext?
Reply
#2

You cannot use "SendClientMessage" like you are now. You need to format the string, including the params. Something like this should suffice for what you need now:

pawn Код:
new string[128];
format(string, sizeof(string), "You have been kicked by %s for: %s", adminname, params[2]);
SendClientMessage(pid, AdminColor, string);
Show the code for your admin chat and I'll make a DCMD command for you.
Reply
#3

Thanks the kick worked

This is the admin chat

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(muted[playerid] == 1)
    {
    SendClientMessage(playerid, Red, "You are muted and cannot talk");
    return 0;
    }
    if(text[0] == '#')
    {
        if(level[playerid] >= 1)
        {
        new string[180], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "Admin Lvl %s: %s",name,text[1]);
        MessageToAdmins(AdminColor,string);
        return 0;
        } else {
        return 0;
        }
    }
    return 1;
}
Reply
#4

Okay, this should do what you need for an admin chat...

pawn Код:
dcmd_admin(playerid, params[])
{
    if(level[playerid] < 1) // Checking to see if they're admin level is less than one.
        return false; // If so, we stop the command.
    if(strlen(params) > 95) // We should check to see if they have a message to large for the SA-MP chat
        return SendClientMessage(playerid, 0xFFFFFFAA, "ERROR: Your message is too long!"); // It is, lets send them an error message.

    new name[MAX_PLAYER_NAME], string[128]; // Define some new variables
    GetPlayerName(playerid, name, sizeof(name)); // Get their name
    format(string, sizeof(string), "Admin Lvl %s: %s", name, params); // format the message
    MessageToAdmins(AdminColor, string); // send to the admins
    return 1;
}
Reply
#5

Worked!! Thank you so much RealCop !!
Reply
#6

Can I do this with onplayertext?

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(muted[playerid] == 1)
    {
    SendClientMessage(playerid, Red, "You are muted and cannot talk");
    return 1;
    }
    return 0;
}
Reply
#7

Quote:
Originally Posted by xir
Посмотреть сообщение
Can I do this with onplayertext?

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(muted[playerid] == 1)
    {
    SendClientMessage(playerid, Red, "You are muted and cannot talk");
    return 1;
    }
    return 0;
}
Yes.
Reply
#8

Quote:
Originally Posted by xir
Посмотреть сообщение
Can I do this with onplayertext?

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(muted[playerid] == 1)
    {
    SendClientMessage(playerid, Red, "You are muted and cannot talk");
    return 1;
    }
    return 0;
}
I take it you have a /mute command which mutes the players and makes them unable to chat with the other players. You will be sending the "You are muted and cannot talk" message, but it will still send their message to the other players because you have "return 1;" underneath it. You need to "return 0" and if this isn't a role-play server, the last "return 0;" should be "return 1;".
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)