Admin Message
#1

Hello
i need a help with a new script...
i need help with a admin message system... the cmd's : /admin [message]
if players do /admin Hi so the message will be go to admin in a small box.. and the admins can do /ram playerid/player
name [message]... please help me with create this cmd's...
Reply
#2

like /a ?
if yes there u are , use ZCMD

pawn Код:
CMD:a(playerid, params[])
{
    new string[512];
    new pName[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] >= 1) //i dont know your admin variables xD
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) == 1)
            GetPlayerName(playerid, Name, sizeof(Name));
            format(string, sizeof(string), "[ADMINCHAT]:%s ( %s )", pName, params);
            SendClientMessage(i, COLOR_WHITE,string);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "[ERROR]:You need to be an [ADMIN] to use this Commands!");
    }
    return 1;
}
if works Rep+ me
Reply
#3

  • Get dcmd and sscanf if you dont have from here.
    SSCANF : Here
    DCMD :
    pawn Код:
    #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  • Add this at top of your script.
    pawn Код:
    #include <sscanf2>
    #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  • Under OnPlayerCommandText Add
    pawn Код:
    public OnPlayerCommandText(playerid, cmdtext[])
    {
        dcmd(admin,5,cmdtext);//admin command
        dcmd(ram,3,cmdtext);//ram command
        return 0;
    }
  • Admin Command
    pawn Код:
    dcmd_admin(playerid,params[])
    {
        new msg[120];
        if(sscanf(params,"s[120]",msg)) return SendClientMessage(playerid,-1,"Correct Usage : /admin [message]");
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        format(msg,sizeof(msg),"%s(ID:%d) : %s",name,playerid,msg);
        for(new i=0;i<MAX_PLAYERS;++i)
        {
            if(IsPlayerConnected(i))
            {
                if(IsPlayerAdmin(i) || pInfo[i][Admin]>=1)
                    SendClientMessage(i,-1,msg);
            }
        }
        return 1;
    }
  • RAM command
    pawn Код:
    dcmd_ram(playerid,params[])
    {
        new msg[200],targetid;
        if(pInfo[playerid][Admin]< 1 && !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
        if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
        SendClientMessage(targetid,-1,msg);
        return 1;
    }
Remember to REPLACE pInfo[playerid][Admin] with your Admin Variable
Reply
#4

1 error
F:\Copy of test.pwn(13) : warning 203: symbol is never used: "dcmd_ram"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Reply
#5

Quote:
Originally Posted by Tuntun
Посмотреть сообщение
1 error
F:\Copy of test.pwn(13) : warning 203: symbol is never used: "dcmd_ram"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(admin,5,cmdtext);//admin command
    dcmd(ram,3,cmdtext);//ram command
    return 0;
}
Reply
#6

Like this?:
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}
dcmd_ram(playerid,params[])
{
new msg[200],targetid;
if(pInfo[playerid][Admin]< 1 || !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
SendClientMessage(targetid,-1,msg);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}
Reply
#7

pawn Код:
#include <a_samp>
#include <sscanf2>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(admin,5,cmdtext);//admin command
    dcmd(ram,3,cmdtext);//ram command
    return 0;
}

dcmd_admin(playerid,params[])
{
    new msg[120];
    if(sscanf(params,"s[120]",msg)) return SendClientMessage(playerid,-1,"Correct Usage : /admin [message]");
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(msg,sizeof(msg),"%s(ID:%d) : %s",name,playerid,msg);
    for(new i=0;i<MAX_PLAYERS;++i)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerAdmin(i) || pInfo[i][Admin]>=1)
                SendClientMessage(i,-1,msg);
        }
    }
    return 1;
}
dcmd_ram(playerid,params[])
{
    new msg[200],targetid;
    if(pInfo[playerid][Admin]< 1 && !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
    if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
    SendClientMessage(targetid,-1,msg);
    return 1;
}
Reply
#8

F:\Copy of test.pwn(23) : error 017: undefined symbol "pInfo"
F:\Copy of test.pwn(23) : warning 215: expression has no effect
F:\Copy of test.pwn(23) : error 001: expected token: ";", but found "]"
F:\Copy of test.pwn(23) : error 029: invalid expression, assumed zero
F:\Copy of test.pwn(23) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#9

Change line 23 to:
pawn Код:
if(IsPlayerAdmin(i))
Reply
#10

#include <a_samp>
#include <sscanf2>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}

dcmd_admin(playerid,params[])
{
new msg[120];
if(sscanf(params,"s[120]",msg)) return SendClientMessage(playerid,-1,"Correct Usage : /admin [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"%s(ID:%d) : %s",name,playerid,msg);
for(new i=0;i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i))
SendClientMessage(i,-1,msg);
}
}
return 1;
}
dcmd_ram(playerid,params[])
{
new msg[200],targetid;
if(pInfo[playerid][Admin]< 1 && !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
SendClientMessage(targetid,-1,msg);
return 1;
}
And the Errors:

F:\Copy of test.pwn(31) : error 017: undefined symbol "pInfo"
F:\Copy of test.pwn(31) : warning 215: expression has no effect
F:\Copy of test.pwn(31) : error 001: expected token: ";", but found "]"
F:\Copy of test.pwn(31) : error 029: invalid expression, assumed zero
F:\Copy of test.pwn(31) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)