cmd:admins
#1

Hello sampers!

I have one question!

Why if there is one admin online command works normaly but if there is two or more it says "UNKNOWN COMMAND" -- and yea this is from old good PPC trucking gamemode

Код:
// This command lists all online admins
COMMAND:admins(playerid, params[])
{
	// Setup local variables
	new AdminList[500], Name[24];

	// Send the command to all admins so they can see it
	SendAdminText(playerid, "/admins", params);

	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
		// Scan through all players
		for (new i; i < MAX_PLAYERS; i++)
		{
			// Check if this player is connected
			if (IsPlayerConnected(i))
			{
				// Get the name of the player
				GetPlayerName(i, Name, sizeof(Name));

				// Check if this player is an RCON admin
				if (IsPlayerAdmin(i))
				{
					// Add all admin players to the list
					format(AdminList, 500, "%s%s: %s (id: %i), admin-level: %i (RCON admin)\n", AdminList, AdminLevelName[APlayerData[i][PlayerLevel]], Name, i, APlayerData[i][PlayerLevel]); // Add the name of the admin-player to the list
					// Re-start the for loop (skipping the remaining code for this iteration)
					continue;
				}

				//Check if that player is an admin (using the PlayerLevel)
				if (APlayerData[i][PlayerLevel] > 0)
				{
					// Add all admin players to the list
					format(AdminList, 500, "%s%s: %s (id: %i), admin-level: %i\n", AdminList, AdminLevelName[APlayerData[i][PlayerLevel]], Name, i, APlayerData[i][PlayerLevel]); // Add the name of the admin-player to the list
				}
			}
		}

		// Check if there were admin-names added to the list
		if (strlen(AdminList) > 0)
		    ShowPlayerDialog(playerid, DialogNoResponse, DIALOG_STYLE_LIST, "Online admins:", AdminList, "OK", "Cancel");
		else
			SendClientMessage(playerid, 0xFF0000FF, "No admin online"); // No admins are online
	}
	else
	    return SendClientMessage(playerid, 0xFF0000FF, "REPORT THIS TO ADMIN"); // No admins are online;

	// Let the server know that this was a valid command
	return 1;
}
Reply
#2

You get UNKNOWN COMMAND if you do not return 1 or if the server got a run-time error.

Please check you server log and see if you got a run-time error.If so then post the error here.
Reply
#3

Don't create the command with the same syntax, otherwise the script wont be able to distinguish which one to execute.

The command looks fine with no errors, so unless you have another command with the same function name 'admins' & 'admins' then change one of them.
Reply
#4

It's a run time error and probably run time error 4 because of this:
pawn Код:
AdminLevelName[APlayerData[i][PlayerLevel]]
We can be sure though - just load crashdetect plugin: https://github.com/Zeex/samp-plugin-...etect/releases
Do this aswell (so we can get the line): https://github.com/Zeex/samp-plugin-...ith-debug-info

After done the above, run the server and execute the command when two or more admins are online. If you get the unknown command message, post your server log.
Reply
#5

use thys


Quote:

if (strcmp(cmd, "/admins", true) == 0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COLOR_GREEN, "__________ Admini On __________");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] == 1337)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{FF0000}Co-Ownar {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
if(PlayerInfo[i][pAdmin] == 1340)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{00FF80}Scripter {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
if(PlayerInfo[i][pAdmin] == 1339)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{00FF80}Mapper {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
if(PlayerInfo[i][pAdmin] == 133
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{FF0000}Owner {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
if(PlayerInfo[i][pAdmin] == 1)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{0080FF}Admin 1 {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
if(PlayerInfo[i][pAdmin] == 2)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{0080FF}Admin 2 {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
if(PlayerInfo[i][pAdmin] == 3)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{0080FF}Admin 3 {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
if(PlayerInfo[i][pAdmin] == 4)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "{0080FF}Admin 4 {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]", sendername,i);
SendClientMessage(playerid, 0x33CCFFAA, string);
}
}
}
}
return 1;
}

Reply
#6

He doesn't want a new command, he wants the one he has fixed.
Reply
#7

That code won't work !!
I wonder from where you copied it from.

It won't work because it is using variables which belong to the script from which you copied.

EDIT:Abagail was faster than me
Reply
#8

Quote:
Originally Posted by StR_MaRy
Посмотреть сообщение
use thys
Lol! Why are you checking the Administrator's level?! Just a slow way and strcmp! Omg...

Quote:

{FF0000}Co-Ownar {80FF80}| {FFFFFF}Nume: {FF8000}%s {FFFFFF}| ID: {80FFFF}[%d]

Wow...just wow...
Reply
#9

pawn Код:
COMMAND:admins(playerid, params[])
{
    SendAdminText(playerid, "/admins", params);
    if(!APlayerData[playerid][LoggedIn]) return SendClientMessage(playerid, 0xFF0000FF, "REPORT THIS TO ADMIN");
    new count = 0, AdminList[750];
    for(new i = 0, j = GetPlayerPoolSize(); i != j; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(!APlayerData[i][PlayerLevel]) continue;
        new fstr[75], Name[MAX_PLAYER_NAME];
        GetPlayerName(i, Name, sizeof(Name));
        format(fstr, sizeof(fstr), "%s: %s (id: %i), admin-level: %i", AdminLevelName[APlayerData[i][PlayerLevel]], Name, i, APlayerData[i][PlayerLevel]);
        strcat(fstr, (IsPlayerAdmin(i)) ? ("(RCON admin)\n") : ("\n"));
        strcat(AdminList, fstr);
        count++;
        if(count >= 10) break;
    }
    if(!count) return SendClientMessage(playerid, 0xFF0000FF, "No admin online");
    ShowPlayerDialog(playerid, DialogNoResponse, DIALOG_STYLE_LIST, "Online admins:", AdminList, "OK", "Cancel");
    return 1;
}
Make sure your 'new AdminLevelName' elements do not exceed your maximum admin level.

Example: If your maximum admin level is 10, AdminLevelName should be 11. (Unless you want to take 1 from the variable in the code - eg. AdminLevelName[APlayerData[i][PlayerLevel] - 1])
Reply
#10

new AdminLevelName[6][24] =
{
{"Player"}, // Admin-level 0
{"Moderator"}, // Admin-level 1
{"Helper-admin"}, // Admin-level 2
{"Admin"}, // Admin-level 3
{"Head-admin"}, // Admin-level 4
{"Owner-admin"} // Admin-level 5
};


What then? Thats ok right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)