PDA

View Full Version : CMD


lsreskjn
22/09/2013, 04:55 PM
Hello, is there a simple way to see what players types? what commands? I am only using rcon admin so IsPlayerAdmin, i am looking for something very simple and i need to type it under my commands in my mod something like IfIsPlayerAdmin ...then...SendClientMessageToAdmin....Player xxx has used /xxx command...


I have printf("Player %s used command %s",Jmeno(playerid), cmdtext); to see in log what they typed :D

Areax
22/09/2013, 04:59 PM
public OnPlayerCommandReceived(playerid, cmdtext[])
{
new string[150];
new name;
format(string, sizeof(string), "%s[ID:%d] Has Typed: %s", GetName(name), playerid, cmdtext);
SendAdminMessage(-1, string);
return 1;
}

stock GetName(playerid)
{
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}

stock SendAdminMessage(color, const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i) != 0)
SendClientMessage(i, color, string);
}
return 1;
}

Champ
22/09/2013, 04:59 PM
You can use this stock


stock SendClientMessageToAdmins(msg[]) for(new i; i < MAX_PLAYERS; i++) if(GetPlayerAdminLevel(i)) SendClientMessage(i, COLOR_SALMON, msg);


Replacing the Adminlevel variable to your own admin variable.

how to use it
see

format(string, sizeof string, "=> Admin %s has ____ %s.", pName, gName);
SendClientMessageToAdmins(string);

EiresJason
22/09/2013, 05:00 PM
Put this where the printf is.

for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerAdmin(i)) //or replace with your admin variable such as if(PlayerInfo[i][pAdmin] >= 1)
{
new string[128];
format(string,sizeof(string),"Player %s has used the command %s",Jmeno(playerid),cmdtext);
SendClientMessage(i,-1,string);
}
}

lsreskjn
22/09/2013, 05:04 PM
Too many errors :D I am only using RCON admin! i thought there something mutch more simpler :(

lsreskjn
22/09/2013, 05:06 PM
new string[124];

showing an error

Areax
22/09/2013, 05:06 PM
public OnPlayerCommandReceived(playerid, cmdtext[])
{
new string[150];
new name;
format(string, sizeof(string), "%s[ID:%d] Has Typed: %s", GetName(name), playerid, cmdtext);
SendAdminMessage(-1, string);
return 1;
}

stock GetName(playerid)
{
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}

stock SendAdminMessage(color, const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(i) != 0)
SendClientMessage(i, color, string);
}
return 1;
}

What ERRORS you get ?

lsreskjn
22/09/2013, 05:18 PM
(1694) : warning 235: public function lacks forward declaration (symbol "OnPlayerCommandReceived")

line:

public OnPlayerCommandReceived(playerid, cmdtext[])

Areax
22/09/2013, 05:23 PM
Do you have ZCMD included ?

I mean this:

#include <zcmd>

lsreskjn
22/09/2013, 05:24 PM
yes :D

Areax
22/09/2013, 05:27 PM
Then you should not have any problems.

lsreskjn
22/09/2013, 05:32 PM
Thanks, it is working very well, it is showing the command what they typed but the commands it self doesn't work now

Areax
22/09/2013, 05:37 PM
Do you have your commands like this ?

CMD:yourcommand(playerid, params[])

lsreskjn
22/09/2013, 05:39 PM
no, all my commands are basic...like this

if(strcmp("/armour", cmdtext) == 0)
{
if(IsPlayerVipMember(playerid))
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, 0x800080FF, "[ Server ] Armour has been set to maximum.");
}
else SendClientMessage(playerid, 0x800080FF, "[ Server ] Nevlastníš VIP");
printf("Player %s used command %s",Jmeno(playerid), cmdtext);
return 1;
}

Areax
22/09/2013, 05:40 PM
Then this could be a reason.. Change all your commands to ZCMD style.

lsreskjn
22/09/2013, 05:42 PM
i dont know how to use zmdc so it's not going to happe

EiresJason
22/09/2013, 05:44 PM
Example of the command /armour in ZCMD:

CMD:armour(playerid,params[])
{
if(IsPlayerVipMember(playerid))
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, 0x800080FF, "[ Server ] Armour has been set to maximum.");

for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerAdmin(i)) //or replace with your admin variable such as if(PlayerInfo[i][pAdmin] >= 1)
{
new string[128];
format(string,sizeof(string),"Player %s has used the command /armour!",Jmeno(playerid));
SendClientMessage(i,-1,string);
}
}
}
else SendClientMessage(playerid, 0x800080FF, "[ Server ] Nevlastníš VIP");
printf("Player %s used command %s",Jmeno(playerid), cmdtext);
return 1;
}

Areax
22/09/2013, 05:44 PM
ZCMD is easier then strcmp..