[NeedHelp]
#1

First , I dont know why my previous topic was deleted ! So if by mistake I broke a rule please pm me ..
Here's the question :

stock SendAdminMessage(text[])
{
for (new pid; pid<MAX_PLAYERS; pid++)
{
If(IsPlayerAdmin(pid)
{
SendClientMessage(pid,SOME_COLOR,GetPlayerName(pid )+":"+text);
return 1;
}
}
}
//after including zcmd
CMD:a(playerid,params[])
{
SendAdminMessage(params);
return 1;
}


//this code compiles fine but nothing shows up when i do /a some text here
//also dos not show an UNKNOWN COMMAND error
//what to do ?
Reply
#2

pawn Код:
stock SendAdminMessage(const text[])
{
    for(new pid = 0; pid < MAX_PLAYERS; pid++)
    {
        if(IsPlayerAdmin(pid))
        {
            SendClientMessage(pid, -1, text);
        }
    }
    return 1;
}

//after including zcmd
CMD:a(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not an admin.");
    SendAdminMessage(params);
    return 1;
}
Basically, by putting 'return 1' INSIDE the loop, it is ending it and will not continue past the first matching player. Also, this shouldn't be compiling successfully, there are missing brackets and possibly undefined variables in this code. Try the code I've given and see how it works for you.

EDIT: Also read the below poster's, as I was going to mention logging into RCON, but his post was submitted before I could edit it.
Reply
#3

first of all.
You make sure you're RCON Logged in?
Second use sscanf, or use the isnull made up function to check if the string inputted is null.
Then if it is not, Make it sendable like this

pawn Код:
if(isnull(params)) return //SendClientMessage
new string[128];
format(string, 128, "CHAT: %s", params);
SendAdminMessage(params);
Reply
#4

Thanks a lot ...I just realized i should not forget to initialize pointers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)