[HELP] Admin Megaphone CMD
#1

Hello, i want to make a admin megaphone command.

Like:

/ma or /megaphoneadmin [TEXT]

And the players read like that:

[Admin Megaphone:] Bla Bla Bla...

In yellow.

Thanks
Reply
#2

This should work:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/ma", true, 3)
    {
        if(!strlen(cmdtext)) return 1; /* No text was set in the command*/
        new str[150], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(str, sizef(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s", cmdtext);
        SendClientMessageToAll(0xFFFFFF, str);
    }
    return 1;
}

CMD:ma(playerid, params[])
{
    new text[150];
    if(sscanf(params, "s[150]", text)) return 1; /* No text*/

    new str[150], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(str, sizef(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s", text);
    SendClientMessageToAll(0xFFFFFF, str);
    return 1;
}
EDIT: just noticed GetPlayerName & pName is not used in the string.. can delete it
Reply
#3

PHP код:
C:\Users\Eonik\Desktop\GOOD LIFE RP\GL-RP\gamemodes\GL-RP.pwn(53709) : error 017undefined symbol "sizef"
C:\Users\Eonik\Desktop\GOOD LIFE RP\GL-RP\gamemodes\GL-RP.pwn(72351) : error 001expected token")"but found "{"
C:\Users\Eonik\Desktop\GOOD LIFE RP\GL-RP\gamemodes\GL-RP.pwn(72355) : error 017undefined symbol "sizef"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
3 Errors

Line 53709
PHP код:
  format(strsizef(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s"text); 
Line 72351
PHP код:
    
Line 72355
PHP код:
format(strsizef(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s"cmdtext); 
Reply
#4

PHP код:
CMD:ma(playeridparams[])
{
    new 
text[150];
    if(
sscanf(params"s[150]"text)) return 1;
    new 
str[150];
    
format(strsizeof(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s"text);
    
SendClientMessageToAll(0xFFFFFFstr);
    return 
1;

Replace and try.
Reply
#5

Код:
C:\Users\Eonik\Desktop\GOOD LIFE RP\GL-RP\gamemodes\GL-RP.pwn(72351) : error 001: expected token: ")", but found "{"
C:\Users\Eonik\Desktop\GOOD LIFE RP\GL-RP\gamemodes\GL-RP.pwn(72355) : error 017: undefined symbol "sizef"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Line 72351
Код:
    {
Line 72355
Код:
format(str, sizef(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s", cmdtext);
2 Errors now.
Reply
#6

Quote:
Originally Posted by Eonik
Посмотреть сообщение
Код:
C:\Users\Eonik\Desktop\GOOD LIFE RP\GL-RP\gamemodes\GL-RP.pwn(72351) : error 001: expected token: ")", but found "{"
C:\Users\Eonik\Desktop\GOOD LIFE RP\GL-RP\gamemodes\GL-RP.pwn(72355) : error 017: undefined symbol "sizef"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Line 72351
Код:
    {
Line 72355
Код:
format(str, sizef(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s", cmdtext);
2 Errors now.
Oh, did you erase the 'public OnPlayerCommandText' code? You don't need it if your using the ZCMD command.

Erase this code
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/ma", true, 3)
    {
        if(!strlen(cmdtext)) return 1; /* No text was set in the command*/
        new str[150], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(str, sizef(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s", cmdtext);
        SendClientMessageToAll(0xFFFFFF, str);
    }
    return 1;
}
This one should of worked if you have ZCMD include and sscanf installed.
Quote:
Originally Posted by SkullGamer
Посмотреть сообщение
PHP код:
CMD:ma(playeridparams[])
{
    new 
text[150];
    if(
sscanf(params"s[150]"text)) return 1;
    new 
str[150];
    
format(strsizeof(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s"text);
    
SendClientMessageToAll(0xFFFFFFstr);
    return 
1;

Replace and try.
Reply
#7

sizeof not sizef
Reply
#8

It's working! Thank you guys! Rep+

EDIT:

I found one problem. Normal players can use admin megaphone, and i want a local megaphone, not a megaphone to send message to all players.

Thanks
Reply
#9

PHP код:
CMD:ma(playeridparams[])
{
    new 
text[150];
    new 
str[150];
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You are not admin!");// Admins rcon
    
if(sscanf(params"s[150]"text)) return 1;
    
format(strsizeof(str), "{FFFF00}[Admin Megaphone:] {FFFFFF}%s"text);
    
SendClientMessageToAll(0xFFFFFFstr);
    return 
1;

Replace and try again xD.
Reply
#10

Thx But can you make it for level one [and higer] admins?

Sorry for asking so much

PS: i tried to change this

Quote:

if(!IsPlayerAdmin(playerid))

to this

Quote:

if(PlayerInfo[playerid][pAdmin] >= 1

But i get a error

EDIT: And i dont want megaphone send a message to everyone, i want like the Police megaphone, just a local megaphone.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)