SA-MP Forums Archive
/admins cmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /admins cmd (/showthread.php?tid=664934)



/admins cmd - severance - 16.03.2019

Hello,

I'm trying to achieve a format message of something like:
Quote:

Managements: %s %s %s %s

Instead of
Quote:

Managements:
%s %s

Like the whole names in only one line without making a new one.
That's what i did for a while and does not work of course, it duplicates the same name.

Код:
		if(Player[i][Level] == 6)
		{
			//SendClientMessage(playerid, -1, "{3377FF}Managements: ");
			rank6++;
			/*
			strcat(string, "Managements:");
			format(string, sizeof string, "%s %s", string, PNames[i]);  
			*/

			if (rank6 == 1){
				format(text, sizeof text, "{3377FF}Managements: {FFFFFF}%s", PNames[i]); 
				SendClientMessage(playerid, -1, text);
			}
			else if(rank6 == 2){
				format(text, sizeof text, "{3377FF}Managements: {FFFFFF}%s {FFFFFF}%s", PNames[i], PNames[i]); 
				SendClientMessage(playerid, -1, text);
			}
			else if(rank6 == 3){
				format(text, sizeof text, "{3377FF}Managements: {FFFFFF}%s {FFFFFF}%s {FFFFFF}%s", PNames[i], PNames[i], PNames[i]); 
				SendClientMessage(playerid, -1, text);
			}
			else if(rank6 == 4){
				format(text, sizeof text, "{3377FF}Managements: {FFFFFF}%s {FFFFFF}%s {FFFFFF}%s {FFFFFF}%s", PNames[i], PNames[i], PNames[i], PNames[i]); 
				SendClientMessage(playerid, -1, text);
			}
			else if(rank6 == 5){
				format(text, sizeof text, "{3377FF}Managements: {FFFFFF}%s {FFFFFF}%s {FFFFFF}%s {FFFFFF}%s {FFFFFF}%s", PNames[i], PNames[i], PNames[i], PNames[i], PNames[i]); 
				SendClientMessage(playerid, -1, text);
			}
			else{
				SendClientMessage(playerid, -1, "Managements:");
				format(text, sizeof text, "%s{FFFFFF}%s", text, PNames[i]); 
				SendClientMessage(playerid, -1, text);
			}
		}



Re: /admins cmd - antixgaming - 16.03.2019

It duplicates the names because you have the same name. You have to store more names.


Re: /admins cmd - severance - 16.03.2019

Quote:
Originally Posted by antixgaming
Посмотреть сообщение
It duplicates the names because you have the same name.
Yeah thats OBVIOUS.
I have been experimenting with string concatenation as well, but seems like im just lost.


Re: /admins cmd - antixgaming - 16.03.2019

You need to have a variable (must be string; can be array) that is going to store names from different people. Then you can write down the names. Because using this method, you are using same id. Show us code above your first statement.


Re: /admins cmd - severance - 16.03.2019

Oh, and then the next question how do you store different player nicks? You use another GetName ?

Thats the whole concept.

Код:
	new 
		Admins,
		text[150]
	;
	
	foreach(new i : Player) if(Player[i][Level] > 0) 
	{
		if(Player[i][Level] == 1){...}

		if(Player[i][Level] == 2){...}

		if(Player[i][Level] == 3){...}

		if(Player[i][Level] == 4){...}

		if(Player[i][Level] == 5){...}

		if(Player[i][Level] == 6){...}

		Admins++;
	}
	
	if (Player[playerid][Level] == 0){
		if (Admins == 0){
			format(text, sizeof(text), "{CACACA}There are no admins online.");
			SendClientMessage(playerid, -1, text);
		}else{
			format(text, sizeof(text), "{CACACA}There are {3377FF}%d {CACACA}admins online.", Admins);
			SendClientMessage(playerid, -1, text);
		}
	}



Re: /admins cmd - antixgaming - 16.03.2019

So you are printing all the names of active admins? Is that right?


Re: /admins cmd - severance - 16.03.2019

Yeah, absolutely.

If there is an admin online. it adds the admin's name on one line ex.
Quote:

Admins: name1

If there are more than 2 admins:
Quote:

Admins: name1, name2

and go on.


Re: /admins cmd - antixgaming - 16.03.2019

So every time player logs in as an admin, you should get his name and add it to some global variable that containes all names. And when you perform command, you should print it out. After the admin logs off, he's name should be removed. You can use arrays, but I recommend linked lists (only if you know what they are).