/asay color change
#1

Hello, here I want help with /asay color. I want different colors for different admin level /asay's . There are 6 admin levels in my script, I want their /asay to be changed according to the colors I put.

My /asay command :
PHP код:
CMD:asay(playeridparams[])
{
 new 
tmp[256], playername[25], string[256], string2[256], moneys=0moneys1=0;
 if (
adlvl[playerid] < 1) return 0;
 if (
sscanf(params"s[128]"tmp)) return SendClientMessage2(playeridCOLOR_WHITE"Usage: /asay [message]");
 
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
 
format(stringsizeof(string), "* Admin: %s (%s)"tmpplayername);
 
format(string2sizeof(string2), "* Admin: %s"tmp);
 for(new 
i=0PLAYERSi++)
 {
  if(
== playerid)
  {
      if(
adlvl[i] >= && adminuc[i] == 0)
      {
          
moneys++;
      }
      if(
adlvl[i] >= && adminuc[i] != 0)
      {
          
moneys1++;
      }
   }
 }
 if(
moneys != 0)
 {
    if(
adlvl[playerid] ==|| adlvl[playerid]==2)
    {
      
SendMessageToAdmins(COLOR_ADMIN_1string);
      
SendMessageToNormal(COLOR_ADMIN_1string2);
    }
       if(
adlvl[playerid] ==3)
    {
      
SendMessageToAdmins(COLOR_ADMIN_2string);
      
SendMessageToNormal(COLOR_ADMIN_2string2);
    }
       if(
adlvl[playerid] >=4)
    {
      
SendMessageToAdmins(COLOR_ADMIN_3string);
      
SendMessageToNormal(COLOR_ADMIN_3string2);
    }
 }
 if(
moneys1 != 0)
 {
    if(
adlvl[playerid] ==|| adlvl[playerid]==2)
    {
      
SendMessageToAdmins(COLOR_ADMIN_1string2);
      
SendMessageToNormal(COLOR_ADMIN_1string2);
    }
       if(
adlvl[playerid] ==3)
    {
      
SendMessageToAdmins(COLOR_ADMIN_2string2);
      
SendMessageToNormal(COLOR_ADMIN_2string2);
    }
       if(
adlvl[playerid] >=4)
    {
      
SendMessageToAdmins(COLOR_ADMIN_3string2);
      
SendMessageToNormal(COLOR_ADMIN_3string2);
    }
 }
 return 
1;

Reply
#2

Ok, so you've done it, what's the problem ?


Also, I don't understand why you use that loop through players, you're looking for the ID of the player, comparing it with the playerid, which is the ID of the player.

P.S. Suggest you to take a look and read foreach and/or y_iterate if you don't use it already.
Reply
#3

Can u give me some dynamic system of changing /asay colors for each ( admin levels 6 ) ?
Reply
#4

Try not to copy beckzy's script, and learn coding yourself, that would be alot better.
Learn the basics first.
Reply
#5

I know of an easy way to do this, or so I have planned in my head.

But, before I rewrite the script, can you please explain what "moneys" and "moneys1" is used for? Lol.

I can't wrap my head around it.
Reply
#6

This is created with explanations for each line for you to get an understanding.

Like I stated above, I'm not sure what your "moneys" and "moneys2" is used for.

I can integrate it into this existing code for you, but, you will need to explain the purpose of those.

Let me know if you need any further help or don't understand something.

Код:
new A_CHAT_COLORS[60] = { //6 SLOTS IN ARRAY - 10 CHAR EACH FOR HEX CODE (6*10=60arraySize)

	"{FFFFFF}", //LEVEL 1
	"{FFFFFF}", //LEVEL 2
	"{FFFFFF}", //LEVEL 3
	"{FFFFFF}", //LEVEL 4
	"{FFFFFF}", //LEVEL 5
	"{FFFFFF}"  //LEVEL 6

};

CMD:asay( playerid, params[]) {

	new
		grabbedMessage[128], //Message obtained through chatbox
		adminMessage[256], //Message used to pass to admins
		normalMessage[256], //Message used to pass to normal players
		playerName[MAX_PLAYER_NAME] //Holds player name string
	;

	if ( adlvl[playerid] < 1 ) //Checks administration level
		return SendClientMessage( playerid, -1, "You do not have permission to use this call." ); //If player is not an admin, returns this message

	if ( sscanf( params, "s[128]", grabbedMessage ) ) //Makes sure you filled out all parameters
		return SendClientMessage( playerid, -1, "Usage: /asay [message]" ); //Returns this usage

	format( adminMessage, sizeof( adminMessage ), "* Admin: %s (%s)", grabbedMessage, GetPlayerName( playerid, playerName, MAX_PLAYER_NAME ) ); //Formats adminMessage with player name
	format( normalMessage, sizeof( normalMessage ), "* Admin: %s", grabbedMessage ); //Formats normalMessage

	foreach(Player,i) {

		SendMessageToAdmins( A_CHAT_COLORS[adlvl[playerid] - 1], adminMessage ); //Sends adminMessage to administration
		SendMessageToNormal( A_CHAT_COLORS[adlvl[playerid] - 1], normalMessage ); //Sends normalMessage to normal players

	}

	return 1;

}
Reply
#7

Well... I already fixed this. Still thanks for the help Daymen.
Reply
#8

Quote:
Originally Posted by RomaNScripteR
Посмотреть сообщение
Well... I already fixed this. Still thanks for the help Daymen.
Even if you fixed it, I'd recommend my code. It's a lot more efficient and easier to understand.

Of course you don't have to, but, yours is very difficult to understand and edit in the future.
Reply
#9

lol u stealer that is my script the /asay color only need 2 lines of coding nub
Reply
#10

silverms can u stop saying this again and again that this is your script ?
You posted this script on samp forums once when I downloaded it lol come on....
Its me, Hamza Sherazi

And Damen, I tried using your code of /asay, its saying 1 error, Undefined Symbol foreach
I don't know exactly how can I define this shit....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)