Use this with zcmd? -
ZamaXor - 21.10.2010
How can i use this with zcmd so when someone type a command it will show admin what he typed. Need i use any callback or something ? ZCMD callback?
pawn Код:
new string[256];
format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
{
SendClientMessage(i, ANY_COLOR, string);
}
}
}
Re: Use this in with zcmd? -
Badger(new) - 21.10.2010
Put it at the top of
OnPlayerCommandText like this:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){
new string[256];
format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
{
SendClientMessage(i, ANY_COLOR, string);
}
}
}
Re: Use this in with zcmd? -
Scenario - 21.10.2010
Quote:
Originally Posted by Badger(new)
Put it at the top of OnPlayerCommandText like this:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){ new string[256]; format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) ) { SendClientMessage(i, ANY_COLOR, string); } } }
|
No, he is using ZCMD - that would be incorrect.
Use this:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
new string[256];
format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
{
SendClientMessage(i, ANY_COLOR, string);
}
}
}
return 1;
}
Re: Use this in with zcmd? -
ZamaXor - 21.10.2010
Quote:
Originally Posted by Badger(new)
Put it at the top of OnPlayerCommandText like this:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){ new string[256]; format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) ) { SendClientMessage(i, ANY_COLOR, string); } } }
|
What about this?
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
new string[256];
format(string, sizeof(string), "**** %s (%d) typed: %s", pNameL(playerid),playerid,cmdtext);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
{
SendClientMessage(i, ANY_COLOR, string);
}
}
}
if(!success)
{
return SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
}
return 1;
}
Re: Use this in with zcmd? -
Scenario - 21.10.2010
Yeah, that should work correctly, but I would do this:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(success)
{
new string[256];
format(string, sizeof(string), "**** %s (%d) typed: %s", pNameL(playerid),playerid,cmdtext);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
{
SendClientMessage(i, ANY_COLOR, string);
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
}
return 1;
}
It's a little bit more code, but it will only send a message to the admins if the command exists in the GM. If it doesn't, it'll just send the player an error message.
Re: Use this in with zcmd? -
ZamaXor - 21.10.2010
Quote:
Originally Posted by RealCop228
Yeah, that should work correctly, but I would do this:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success) { if(success) { new string[256]; format(string, sizeof(string), "**** %s (%d) typed: %s", pNameL(playerid),playerid,cmdtext); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) ) { SendClientMessage(i, ANY_COLOR, string); } } } } else { SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands."); } return 1; }
It's a little bit more code, but it will only send a message to the admins if the command exists in the GM. If it doesn't, it'll just send the player an error message.
|
I just want all to see the unknow cmd like "Type /cmds to display available commands."
Thank you.
Re: Use this in with zcmd? -
LarzI - 21.10.2010
Nice cell sizes guys..
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success)
return SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
return 1;
}
Re: Use this in with zcmd? -
Scenario - 21.10.2010
Quote:
Originally Posted by LarzI
Nice cell sizes guys..
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success) { if(!success) return SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands."); return 1; }
|
I wasn't optimizing the code, just giving 'em what he wanted. If it were my code though, the size would of been changed.
Re: Use this in with zcmd? -
LarzI - 21.10.2010
I don't believe he wants a unefficient cell size.. :'p
Re: Use this in with zcmd? -
kurta999 - 21.10.2010
Don't use 256 cell strings in command, text, etc.
Maximum chat string is 128...