RCON Cmd
#1

Hey guys, I previously cut and pasted my admin script to my GM, and well everything works fine except my setlevel command, which can only be used if the player logs in as Rcon Admin. When it was a FS, it worked but now as I placed it in my GM, everything works fine except this command.....

I use ZCMD, so as the Admin FS. Here is the /rcon setlevel cmd

Код:
public OnRconCommand(cmd[])
{
        new params[130];
	sscanf(cmd, "s[128]s[128]", cmd, params);

	if(!strcmp(cmd, "setlevel", true))
	{
		new lookupid, level;
		if(sscanf(params, "ui", lookupid, level))
		{
			print(""#COL_RED"Usage: /rcon setlevel (player: id/name) (level: 0-2)");
		}
		else if(!IsPlayerConnected(lookupid))
		{
			print(""#COL_RED"That player isn't connected to the server.");
		}
		else if(!IsValidAdminLevel(level))
		{
			print(""#COL_RED"You have entered an invalid admin level.");
		}
		else
		{
			new string[144];
			aUserInfo[lookupid][user_info_admin_level] = level;

			if(IsPlayerOnDuty(lookupid))
			{
				SetPlayerSkin(lookupid, pBeforeOnDutyInfo[lookupid][0]);
				SetPlayerHealth(lookupid, 100.0);
				SetPlayerColor(lookupid, pBeforeOnDutyInfo[lookupid][1]);

				psOnDuty[lookupid] = false;
			}

			format(string, sizeof(string), "{%06x}You have set %s(%d) admin level to %d.", GetPlayerAdminLevelColor(lookupid) >>> 8, AddPertinence(ReturnPlayerName(lookupid)), lookupid, level);
			print(string);

			format(string, sizeof(string), "Your admin level has been set to %d.", level);
			SendClientMessage(lookupid, GetPlayerAdminLevelColor(lookupid), string);

			new log[144];
			format(log, sizeof(log), "%s(%d) admin level has been set to %d.", AddPertinence(ReturnPlayerName(lookupid)), lookupid, level);
			RegisterLog("scriptfiles/Admin Log/rconlog", log);
		}
	}
	return 1;
}
Any ideas how to make this command work again?
Reply
#2

From samp wiki: https://sampwiki.blast.hk/wiki/OnRconCommand

Important
Note

You will need to include this callback in a loaded filterscript for it to work in the gamemode!
Reply
#3

Why dont you just use “IsPlayerAdmin(playerid)”
Reply
#4

Quote:
Originally Posted by RowdyrideR
Посмотреть сообщение
Why dont you just use “IsPlayerAdmin(playerid)”
Yea, I'll try that now.
Reply
#5

Conver to ZCMD.

PHP код:
CMD:setlevel(playeridparams[])
{
    new 
string[144lookupidlevel;
    if(
sscanf(params"ui"lookupidlevel)) return print(""#COL_RED"Usage: /rcon setlevel (player: id/name) (level: 0-2)");
    
if(!IsValidAdminLevel(level)) return print(""#COL_RED"You have entered an invalid admin level.");
    
if(!IsPlayerConnected(lookupid)) return print(""#COL_RED"That player isn't connected to the server.");
    
aUserInfo[lookupid][user_info_admin_level] = level;
    if(
IsPlayerOnDuty(lookupid))
    {
        
SetPlayerSkin(lookupidpBeforeOnDutyInfo[lookupid][0]);
        
SetPlayerHealth(lookupid100.0);
        
SetPlayerColor(lookupidpBeforeOnDutyInfo[lookupid][1]);

        
psOnDuty[lookupid] = false;
    }
    
format(stringsizeof(string), "{%06x}You have set %s(%d) admin level to %d."GetPlayerAdminLevelColor(lookupid) >>> 8AddPertinence(ReturnPlayerName(lookupid)), lookupidlevel);
    print(string);

    
format(stringsizeof(string), "Your admin level has been set to %d."level);
    
SendClientMessage(lookupidGetPlayerAdminLevelColor(lookupid), string);

    new 
log[144];
    
format(logsizeof(log), "%s(%d) admin level has been set to %d."AddPertinence(ReturnPlayerName(lookupid)), lookupidlevel);
    
RegisterLog("scriptfiles/Admin Log/rconlog"log);

Now you can decide to take it on rcon or admin level:

PHP код:
IsPlayerAdmin(playerid
or

PHP код:
if(aUserInfo[lookupid][user_info_admin_level] == ) return //scm no admin 
Reply
#6

I tried converting it, this way. I tried Jesper's there were lots of errors. Well this code below compiles, but just like before, it doesn't show.... I tried without logging in as RCON, and logged in as RCON. Same thing.... XD no response...

Код:
CMD:setlevel(playerid, params[])
{
     if(IsPlayerAdmin(playerid))
     {
     new lookupid, level;
     if(sscanf(params, "ui", lookupid, level))
     {
         print(""#COL_RED"Usage: /rcon setlevel (player: id/name) (level: 0-2)");
     }
     else if(!IsPlayerConnected(lookupid))
     {
         print(""#COL_RED"That player isn't connected to the server.");
     }
     else if(!IsValidAdminLevel(level))
     {
         print(""#COL_RED"You have entered an invalid admin level.");
     }
     else
     {
		new string[144];
		aUserInfo[lookupid][user_info_admin_level] = level;

        if(IsPlayerOnDuty(lookupid))
        {
            SetPlayerSkin(lookupid, pBeforeOnDutyInfo[lookupid][0]);
            SetPlayerHealth(lookupid, 100.0);
            SetPlayerColor(lookupid, pBeforeOnDutyInfo[lookupid][1]);

            psOnDuty[lookupid] = false;
        }

        format(string, sizeof(string), "{%06x}You have set %s(%d) admin level to %d.", GetPlayerAdminLevelColor(lookupid) >>> 8, AddPertinence(ReturnPlayerName(lookupid)), lookupid, level);
        print(string);

        format(string, sizeof(string), "Your admin level has been set to %d.", level);
        SendClientMessage(lookupid, GetPlayerAdminLevelColor(lookupid), string);

        new log[144];
        format(log, sizeof(log), "%s(%d) admin level has been set to %d.", AddPertinence(ReturnPlayerName(lookupid)), lookupid, level);
        RegisterLog("scriptfiles/LSDMAdmin Log/rconlog", log);
      }
     }
     return 1;
}
EDIT: I tried Jesper's code again and placed:
Код:
new lookupid, level;
new string[144];
It compiles, but in-game, command is unknown.....
Reply
#7

Why dont u make it like

If(!isvalidadmin && !isplayeradmin) return print...
If(sscanf.......) return print...
If(!isplayerconnected) return print...
Then add the code directly under those lines.

Its more readable and organized...
Reply
#8

@Ryder, Invalid command man. No idea why. I did what you asked. Here's the code:

Код:
CMD:setlevel(playerid, params[])
{
    new lookupid, level;
    if(!IsValidAdminLevel(level) && !IsPlayerAdmin(playerid)) return print(""#COL_RED"You have entered an invalid admin level.");
    if(sscanf(params, "ui", lookupid, level)) return print(""#COL_RED"Usage: /rcon setlevel (player: id/name) (level: 0-2)");
    if(!IsPlayerConnected(lookupid)) return print(""#COL_RED"That player isn't connected to the server.");
    else
    {
		new string[144];
		aUserInfo[lookupid][user_info_admin_level] = level;

        if(IsPlayerOnDuty(lookupid))
        {
            SetPlayerSkin(lookupid, pBeforeOnDutyInfo[lookupid][0]);
            SetPlayerHealth(lookupid, 100.0);
            SetPlayerColor(lookupid, pBeforeOnDutyInfo[lookupid][1]);

            psOnDuty[lookupid] = false;
        }

        format(string, sizeof(string), "{%06x}You have set %s(%d) admin level to %d.", GetPlayerAdminLevelColor(lookupid) >>> 8, AddPertinence(ReturnPlayerName(lookupid)), lookupid, level);
        print(string);

        format(string, sizeof(string), "Your admin level has been set to %d.", level);
        SendClientMessage(lookupid, GetPlayerAdminLevelColor(lookupid), string);

        new log[144];
        format(log, sizeof(log), "%s(%d) admin level has been set to %d.", AddPertinence(ReturnPlayerName(lookupid)), lookupid, level);
        RegisterLog("scriptfiles/LSDMAdmin Log/rconlog", log);
    }
    return 1;
}
Reply
#9

remove the "else" and its brackets....
Reply
#10

Put some printf statements in there so you actually have some idea of how far the command was executed, and what was received from the client/callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)