SA-MP Forums Archive
New chat commands - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: New chat commands (/showthread.php?tid=168521)



New chat commands - jonnyboy - 16.08.2010

- I re posted on this section becuse i posted the another one in the wrong section :S -


Hey, Im doing a chat commands and it worked when i made my commands:

Код:
#include <a_samp>
#include "../include/chat.inc"

#define MESSAGE_COLOR 		  0xEEEEEEFF
#define ECHO_COLOR 		  	  0xEEEEEEFF
#define ACTION_COLOR     	  0xEE66EEFF

//------------------------------------------------

public OnFilterScriptInit()
{
	print("\n--New Chat Commands from scratch -By JonnyBoy-.\n");
	return 1;
}

//------------------------------------------------

public OnPlayerText(playerid, text[])
{
	 if(strlen(text) > 128) return 0;

	 new to_others[MAX_CHATBUBBLE_LENGTH+1];
	 new to_me[MAX_CHATBUBBLE_LENGTH+1];

	 format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
	 format(to_me,MAX_CHATBUBBLE_LENGTH,">> %s",text);

     SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
     SendClientMessage(playerid,ECHO_COLOR,to_me);

     return 0; // can't do normal chat with this loaded
}

//------------------------------------------------

public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new Message[256];
	new	idx;
	new actiontext[MAX_CHATBUBBLE_LENGTH+1];

	cmd = strtok(cmdtext, idx);

	// Action command
	if(strcmp("/me", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"* %s",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,20.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	if(strcmp("/sa", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"[Server Admin] %s",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,10.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	if(strcmp("/ad", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"[Admin] %s",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,5.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	if(strcmp("/n", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"[Newbie] %s",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,3.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	if(strcmp("/h", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"[Helper] %s",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,3.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	if(strcmp("/race", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"[Race] Race at %s and win 2000$! /ra for [Race] Chat!",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,2.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	if(strcmp("/ra", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"[Race] %s",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,2.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	if(strcmp("/s", cmd, true) == 0)
	{
	    Message = strrest(cmdtext,idx);
	    format(actiontext,MAX_CHATBUBBLE_LENGTH,"[STOP] %s",Message);
       	SetPlayerChatBubble(playerid,actiontext,ACTION_COLOR,4.0,10000);
    	SendClientMessage(playerid,ACTION_COLOR,actiontext);
		return 1;
	}
	return 0; // not handled by this script
}

//------------------------------------------------
when im doing another chat command "Example /helpme" i get some wierd errors

and btw, how can i know what colors:

Код:
ACTION_COLOR,4.0,10000);
have?


Re: New chat commands - billiout - 16.08.2010

first show the errors, second the action_color id defined here #define ACTION_COLOR < 0xEE66EEFF> this is hex color. for more info about colors look here https://sampwiki.blast.hk/wiki/Hex_colors


Re: New chat commands - jonnyboy - 16.08.2010

html colors? Thanks!! now this will be easy

and i will show u the errors when it shows up, ok? (it comes randomly)