30.04.2012, 15:17
If you want to make console commands you need to use OnRconCommand and sscanf and strcmp.
You'll need sscanf.
Also IMPORTANT:
Just tested it and it works great.
pawn Код:
public OnRconCommand(cmd[])
{
new cmdtext[16], params[128];
sscanf(cmd, "s[16]S( )[128]", cmdtext, params);
if(!strcmp(cmdtext, "setname", true))
{
new id, newname[MAX_PLAYER_NAME];
if(sscanf(params, "us[24]", id, newname))
{
print("USAGE: setname <id/name> <newname>");
}
else
{
if(id == INVALID_PLAYER_ID) print("ERROR: Player not connected.");
else SetPlayerName(id, newname);
}
return 1;
}
return 0;
}
Also IMPORTANT:
pawn Код:
// Put this in a filterscript. OnRconCommand won't be called in your GM unless it is used in a FS
public OnRconCommand(cmd[]) return 1;