Admin Chat help
#1

pawn Код:
CMD:a(playerid, params[])
{
    new string[512], aname[MAX_PLAYER_NAME];
    if(sscanf(params, "s[512]", string)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /a <text>");
    if(pInfo[playerid][Level] < 1) return 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(playerid))
        {
            if(pInfo[playerid][Level] == 1)
            {
            GetPlayerName(playerid, aname, sizeof(aname));
            format(string, sizeof(string), "[Admin Chat][admin 1] %s: %s", aname, string);
            SendClientMessage(i, 0xFFFF00AA, string);
            }
            if(pInfo[playerid][Level] == 2)
            {
            GetPlayerName(playerid, aname, sizeof(aname));
            format(string, sizeof(string), "[Admin Chat] [admin 2] %s: %s", aname, string);
            SendClientMessage(i, 0x00FF7FAA, string);
            }
            if(pInfo[playerid][Level] == 3)
            {
            GetPlayerName(playerid, aname, sizeof(aname));
            format(string, sizeof(string), "[Admin Chat] [admin 3 %s: %s", aname, string);
            SendClientMessage(i, 0xFF9900AA, string);
            }
            if(pInfo[playerid][Level] == 4)
            {
            GetPlayerName(playerid, aname, sizeof(aname));
            format(string, sizeof(string), "[Admin Chat] [admin 4] %s: %s", aname, string);
            SendClientMessage(i, 0x33AA33AA, string);
            }
            if(pInfo[playerid][Level] == 5)
            {
            GetPlayerName(playerid, aname, sizeof(aname));
            format(string, sizeof(string), "[Admin Chat] [admin 5] %s: %s", aname, string);
            SendClientMessage(i, 0xFF0000AA, string);
            }
        }
    }
    return 1;
}
Help, i've been wondering how am i supposed to script that code in a way that only administrators are able to see it. Actually, whenever an admin uses the chat everyone is able to see it!
Reply
#2

I modified your script a bit:

pawn Код:
CMD:a(playerid, params[])
{
    new string[128], aname[MAX_PLAYER_NAME];
    if(sscanf(params, "s[128]", string)) return SendClientMessage(playerid, 0xFF0000AA, "[USAGE]: /a <text>");
    if(pInfo[playerid][Level] < 1) return 0;
   
    GetPlayerName(playerid, aname, sizeof(aname));
    format(string, sizeof(string), "[Admin Chat][admin %d] %s: %s", pInfo[playerid][Level], aname, string);
   
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(pInfo[i][Level] > 0) SendClientMessage(i, 0xFFFF00AA, string);
    }
    return 1;
}
Reply
#3

Thanks it worked. And my last issue is my spectate command, im completely stuck. When i try to compile the code i receive these following errors:

Quote:

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

Then, if i try to define a new global array called "new spectateid" i receive a list of warnings, even if i create it, a non-global array

Quote:

gamemodes\test.pwn(237) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(254) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(273) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(291) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(313) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(332) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(363) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(382) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(457) : warning 219: local variable "pname" shadows a variable at a preceding level
gamemodes\test.pwn(475) : warning 219: local variable "pname" shadows a variable at a preceding level




Here's the issue part:
pawn Код:
CMD:spectate(playerid, params[])
{
new pID, string[128], aname[MAX_PLAYER_NAME], aspectate[MAX_PLAYERS], pspectate[MAX_PLAYERS];
new Float:x[MAX_PLAYERS], Float:y[MAX_PLAYERS], Float:z[MAX_PLAYERS], vworld[MAX_PLAYERS], interior[MAX_PLAYERS];
if(pInfo[playerid][Level] < 1) return 0;
if(playerid == pID) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]You may not spectate yourself.");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]User is not connected.");
if(aspectate[playerid] == 1) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR]You are currently spectating someone.");
GetPlayerPos(playerid, x[playerid], y[playerid], z[playerid]);
interior[playerid] = GetPlayerInterior(playerid);
vworld[playerid] = GetPlayerVirtualWorld(playerid);
TogglePlayerSpectating(playerid, 1);
if(IsPlayerInAnyVehicle(pID))
    {
        if(GetPlayerInterior(pID) > 0)
        {
            SetPlayerInterior(playerid,GetPlayerInterior(pID));
        }
        if(GetPlayerVirtualWorld(pID) > 0)
        {
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(pID));
        }
        PlayerSpectateVehicle(playerid,GetPlayerVehicleID(pID));
    }
    else
    {
        if(GetPlayerInterior(pID) > 0)
        {
            SetPlayerInterior(playerid,GetPlayerInterior(pID));
        }
        if(GetPlayerVirtualWorld(pID) > 0)
        {
            SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(pID));
        }
        PlayerSpectatePlayer(playerid, pID);
    }
GetPlayerName(pID, aname, sizeof(aname));
format(string, sizeof(string), "You are now spectating %s", aname);
SendClientMessage(playerid, 0xFFC0CBAA, string);
aspectate[playerid] = 1;
pspectate[playerid] = 1;
spectatedid[playerid] = 1; // Line 149
return 1;
}
Reply
#4

Can someone help me to create roleplay server please. Just give me a idea. thanks you
Reply
#5

Quote:
Originally Posted by macparas
Посмотреть сообщение
Can someone help me to create roleplay server please. Just give me a idea. thanks you
Search around for tut's.

Anyone could help me? :/
Reply
#6

Just remove that line and see if any error comes, could you tell me what that variable is used for?
Reply
#7

Im using pname as a variable in each command, actually but not as a global one. If i remove it i will receive the long list of errors :/

Here's the whole script: http://pastebin.com/TaCuZH2v
Reply
#8

Sorry to bump, im still clueless about this :/
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)