Admin chat -
Santox14 - 04.11.2011
Hey im usind zcmd and sscanf and want to make a /a command that only admins can use, and everyone in the server can see it how can i make it?
Im scripting my Admin cmds like this:
pawn Код:
CMD:slap(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new
pID;
if(sscanf(params, "u", pID))
{
return 0;
} else {
if(!IsPlayerConnected(pID))
{
SendMessage(playerid, 0xFF000FFF, "s", "That player is not connected or not signed in!");
} else {
SendMessage(pID, 0xFF000FFF, "sss", "Administrator ", GetName(playerid), " has killed you.");
SendMessageToAll(0xFF000FFF, "ss", GetName(pID), " has been Admin killed by Administrator", GetName(playerid));
SetPlayerHealth(playerid,0);
}
return 1;
}
}
return 0;
}
Re: Admin chat -
SmiT - 04.11.2011
Here is an example, without even using sscanf:
pawn Код:
CMD:a(playerid, params[])
{
if ( !IsPlayerAdmin ( playerid ) ) return 0; /* return 0 if player is not admin */
if ( isnull ( params ) ) return SendClientMessage( playerid, -1, "Syntax /a <text>" ); /* if parameters are null return the syntax message */
new
_string[ 128 ]; /* declare a new array */
format ( _string, sizeof ( _string ), "Admin %s: %s", GetName( playerid ), params ); /* format our message, store it in the array _string */
SendClientMessageToAll( -1, _string ); /* send the message to all players */
return true; /* true = 1 */
}
Re: Admin chat -
Zonoya - 04.11.2011
removed
Re: Admin chat -
SmiT - 04.11.2011
Quote:
Originally Posted by Santox14
only admins can use, and everyone in the server can see
|
Zonoya please read.
Re: Admin chat -
Zonoya - 04.11.2011
oh sorry kinda sleepy
Re: Admin chat -
Kingunit - 04.11.2011
You need to create a own SendMessageToAdmins. Just make a loop and check if the person is a Administrator with your own variables.
AW: Admin chat -
Santox14 - 04.11.2011
i made this :
pawn Код:
stock SendMessage(playerid, color, type[], {Float,_}:...)
{
new
string[128];
for(new i = 0; i < numargs() - 2; i++)
{
switch(type[i])
{
case 's':
{
new
result[128];
for(new a = 0; getarg(i + 3, a) != 0; a++)
{
result[a] = getarg(i + 3, a);
}
if(!strlen(string))
{
format(string, sizeof(string), "%s", result);
} else format(string, sizeof(string), "%s%s", string, result);
}
case 'i':
{
new
result = getarg(i + 3);
if(!strlen(string))
{
format(string, sizeof(string), "%i", result);
} else format(string, sizeof(string), "%s%i", string, result);
}
case 'f':
{
new
Float:result = Float:getarg(i + 3);
if(!strlen(string))
{
format(string, sizeof(string), "%f", result);
} else format(string, sizeof(string), "%s%f", string, result);
}
}
}
SendClientMessage(playerid, color, string);
return 1;
}
stock SendMessageToAll(color, type[], {Float,_}:...)
{
new
string[128];
for(new i = 0; i < numargs() - 2; i++)
{
switch(type[i])
{
case 's':
{
new
result[128];
for(new a = 0; getarg(i + 3, a) != 0; a++)
{
result[a] = getarg(i + 3, a);
}
if(!strlen(string))
{
format(string, sizeof(string), "%s", result);
} else format(string, sizeof(string), "%s%s", string, result);
}
case 'i':
{
new
result = getarg(i + 3);
if(!strlen(string))
{
format(string, sizeof(string), "%i", result);
} else format(string, sizeof(string), "%s%i", string, result);
}
case 'f':
{
new
Float:result = Float:getarg(i + 3);
if(!strlen(string))
{
format(string, sizeof(string), "%f", result);
} else format(string, sizeof(string), "%s%f", string, result);
}
}
}
SendClientMessageToAll(color, string);
return 1;
}
I just want that the admin can say something to all players not a admin chat i did wrong sorry
xD
EDIT: Thanks it works !
Re: Admin chat -
Zonoya - 04.11.2011
lol king read the response SmiT Gave me its for the hole server xD
Re: Admin chat -
Kingunit - 04.11.2011
The one that SmiT gave isn't a Admin chat. Like you can see it sends it to everyone: "SendClientMessageToAll"
pawn Код:
stock SendMessageToAdmins(color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][Adminlevel] > 0) // Own var
{
SendClientMessage(i, color, string);
}
}
return 1;
}
pawn Код:
//-----[Adminchat]-----
CMD:a(playerid, params[])
{
if ( !IsPlayerAdmin ( playerid ) ) return SendClientMessage(playerid, 0xFFFFFFFF, "* You are not Administrator."
new pName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, pName, sizeof(pName));
if(isnull(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "/a [TEXT]" );
format(string, sizeof(string), "{ Administrator %s: %s }", pName, params);
SendMessageToAdmins(0xFFFFFFFF,string);
return 1;
}
AW: Admin chat -
Santox14 - 04.11.2011
Thanks!