17.03.2015, 01:48
I have been experiencing an issue with sscanf, I thought it works like it would do on in-game commands (etc... /test)
I am not sure if i have done it correctly since i haven't used sscanf onRconCommand call back yet.
Can someone tell me if i have done something wrong or something?
NOTE: I am not that lazy to fix the problem, I can fix the problem by myself but due to lack of knowledge of sscanf OnRconCommand, i will need your help on this one.
Here is the source code.
I am not sure if i have done it correctly since i haven't used sscanf onRconCommand call back yet.
Can someone tell me if i have done something wrong or something?
NOTE: I am not that lazy to fix the problem, I can fix the problem by myself but due to lack of knowledge of sscanf OnRconCommand, i will need your help on this one.
Here is the source code.
pawn Код:
public OnRconCommand(cmd[])
{
new string[128], parameters[128], parameters2[128], parameters3[128], parameter2;
// custom command customhelp
if(!strcmp(cmd, "customhelp", true))
{
print("JaKe's custom RCON commands @ 2015");
print("/b, /admins, /a, /admin, /c, /v, /w, /fakea, /fakec");
}
// command /b
if(!strcmp(cmd, "b", true))
{
if(sscanf(cmd[2], "is[128]", parameter2, parameters)) return print("USAGE: /rcon b [playerid] [message]");
if(parameter2 == INVALID_PLAYER_ID) return print("NOTE: Player not connected.");
format(string, sizeof(string), "(( [X] RCON Admin: %s ))", parameters);
print(string);
new
Float: f_Radius = 20.0, Float: f_playerPos[3];
GetPlayerPos(parameter2, f_playerPos[0], f_playerPos[1], f_playerPos[2]);
foreach(Player, i)
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(parameter2))
{
if(IsPlayerInRangeOfPoint(i, f_Radius / 16, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
SendClientMessageEx(i, COLOR_FADE1, string);
}
else if(IsPlayerInRangeOfPoint(i, f_Radius / 8, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
SendClientMessageEx(i, COLOR_FADE2, string);
}
else if(IsPlayerInRangeOfPoint(i, f_Radius / 4, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
SendClientMessageEx(i, COLOR_FADE3, string);
}
else if(IsPlayerInRangeOfPoint(i, f_Radius / 2, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
SendClientMessageEx(i, COLOR_FADE4, string);
}
else if(IsPlayerInRangeOfPoint(i, f_Radius, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
SendClientMessageEx(i, COLOR_FADE5, string);
}
}
}
}
// command /admins
if(!strcmp(cmd, "admins", true))
{
foreach(new i : Player)
{
if(PlayerInfo[i][pAdmin] >= 1)
{
format(string, sizeof string, "[PlayerID: %d] [AdminLevel: %d] - %s", i, PlayerInfo[i][pAdmin], GetPlayerNameEx(i));
print(string);
}
}
}
// command /mods
if(!strcmp(cmd, "mods", true))
{
foreach(new i : Player)
{
if(PlayerInfo[i][pHelper] >= 1)
{
format(string, sizeof string, "[PlayerID: %d] [ModLevel: %d] - %s", i, PlayerInfo[i][pHelper], GetPlayerNameEx(i));
print(string);
}
}
}
// command /admin
if(!strcmp(cmd, "a", true))
{
if(sscanf(cmd[2], "s[128]", parameters)) return print("USAGE: /rcon a(dmin) [adminchat]");
format(string, sizeof string, "* RCON Console: %s", parameters);
print(string);
SendAdminMessage(COLOR_YELLOW, string);
Log("logs/adminchat.log", string);
}
if(!strcmp(cmd, "admin", true))
{
if(sscanf(cmd[6], "s[128]", parameters)) return print("USAGE: /rcon a(dmin) [adminchat]");
format(string, sizeof string, "* RCON Console: %s", parameters);
print(string);
SendAdminMessage(COLOR_YELLOW, string);
Log("logs/adminchat.log", string);
}
// command /c
if(!strcmp(cmd, "c", true))
{
if(sscanf(cmd[2], "s[128]", parameters)) return print("USAGE: /rcon c [advisor chat]");
format(string, sizeof string, "** RCON Console: %s", parameters);
print(string);
SendAdvisorMessage(COLOR_COMBINEDCHAT, string);
Log("logs/cchat.log", string);
}
// command /v
if(!strcmp(cmd, "v", true))
{
if(sscanf(cmd[2], "s[128]", parameters)) return print("USAGE: /rcon v [vip chat]");
format(string, sizeof string, "** RCON Console: %s", parameters);
print(string);
SendVIPMessage(COLOR_VIP, string);
Log("logs/vipchat.log", string);
}
// command /w
if(!strcmp(cmd, "w", true))
{
if(sscanf(cmd[2], "us[128]", parameter2, parameters)) return print("USAGE: /rcon w [playerid] [message]");
format(string, sizeof string, "RCON whispered to %s(ID%d): %s", GetPlayerNameEx(parameter2), parameter2, parameters);
print(string);
format(string, sizeof string, "RCON messages you: %s", parameters);
SendClientMessage(parameter2, COLOR_WHITE, string);
}
// fake admin
if(!strcmp(cmd, "fakea", true))
{
if(sscanf(cmd[6], "p<,>s[128]s[128]s[128]", parameters, parameters2, parameters3)) return print("USAGE: /rcon fakea [rank] [name] [adminchat]");
format(string, sizeof string, "* %s %s: %s", parameters, parameters2, parameters3);
print(string);
SendAdminMessage(COLOR_YELLOW, string);
Log("logs/adminchat.log", string);
}
// fake c
if(!strcmp(cmd, "fakec", true))
{
if(sscanf(cmd[6], "p<,>s[128]s[128]s[128]", parameters, parameters2, parameters3)) return print("USAGE: /rcon fakec [rank] [name] [advisorchat]");
format(string, sizeof string, "* %s %s: %s", parameters, parameters2, parameters3);
print(string);
SendAdvisorMessage(COLOR_COMBINEDCHAT, string);
Log("logs/cchat.log", string);
}
return 1;
}