Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function serverCmdSetNameColor(%cl,%id)
- {
- if(strPos("1234567",%id) == -1)
- {
- // Give the players a list of valid colors
- messageClient(%cl,'',"\c0You many only enter a number 1 to 7.");
- messageClient(%cl,'',"\c0Here are the valid colors: \c00 \c11 \c22 \c33 \c44 \c55 \c66 \c77");
- }
- else
- {
- // "\c" @ %color doesnt work but this does
- eval("%color = \"\\c" @ %id @ "\";");
- %cl.nameColor = %color;
- // Tell them that they can use clan prefix
- messageClient(%cl,'',"\c2Your normal name will appear as " @ %color @ "this color\c2 in the chat.");
- messageClient(%cl,'',"\c2To automatically set that color, use this clan prefix: \c7c{" @ %id @ "}");
- }
- }
- function serverCmdMessageSent(%cl,%msg)
- {
- // This function recreates the entire chat
- %msg = stripMLControlChars(trim(%msg));
- %cnt = getWordCount(%msg);
- %spam = %cl.isSpamming;
- %time = getSimTime();
- // Remaking chat so we need to block words
- if($Pref::Server::ETardFilter)
- {
- %filter = strReplace($Pref::Server::ETardList,",","\t");
- %count = getFieldCount(%filter);
- for(%i = 0; %i < %count; %i++)
- {
- %word = getField(%filter,%i);
- // This will check space-requiring filters
- if(strPos(" " @ %msg @ " ",%word) != -1)
- {
- messageClient(%cl,'',"\c5This is a civilized game. Please use full words.");
- return;
- }
- }
- }
- if(%msg $= %cl.lastChatText && %time - %cl.lastChatTime < 15000)
- {
- // An admin gets sent this warning message
- messageClient(%cl,'',"\c5Do not repeat yourself.");
- if(!%cl.isAdmin && !%spam)
- {
- // They get flood protected for 10 seconds
- %cl.isSpamming = 1;
- %cl.spamProtectStart = %time;
- schedule(10000,0,eval,%cl @ ".isSpamming = 0;");
- }
- }
- if(!%cl.isAdmin && !%spam)
- {
- if(%cl.spamMessageCount == 4)
- {
- // They get flood protected for 10 seconds
- %cl.isSpamming = 1;
- %cl.spamProtectStart = %time;
- schedule(10000,0,eval,%cl @ ".isSpamming = 0;");
- }
- else
- {
- // They can only send four lines every 10s
- %cl.spamMessageCount++;
- schedule(10000,0,eval,%cl @ ".spamMessageCount--;");
- }
- }
- // Tells them that they're spamming
- if(%cl.isSpamming)
- {
- spamAlert(%cl);
- return;
- }
- // Remaking chat so we need to parse links
- for(%i = 0; %i < %cnt; %i++)
- {
- %word = getWord(%msg,%i);
- %end = getSubStr(%word,7,strLen(%word));
- // Added in check for ":" which broke tags
- if(getSubStr(%word,0,7) $= "http://" && strPos(%end,":") == -1)
- %word = "<a:" @ %end @ ">" @ %end @ "</a>\c6";
- if(%i) %new = %new SPC %word;
- else %new = %word;
- }
- // Send messages to clients the proper way
- %msg = %new;
- %name = %cl.nameColor @ %cl.getPlayerName();
- %pre = %cl.clanPrefix;
- %suf = %cl.clanSuffix;
- %all = '\c7%1\c3%2\c7%3\c6: %4' @ "\c7" @ %pre @ "\c3" @ %name @ "\c7" @ %suf @ "\c6: " @ %msg;
- %cl.lastChatText = %msg;
- %cl.lastChatTime = %time;
- commandToAll('chatMessage',%cl,'','',%all,%pre,%name,%suf,%msg);
- }
- package ColoredNames
- {
- function GameConnection::onConnectRequest(%this,%a,%b,%c,%d,%e,%f,%g)
- {
- %length = strLen(%d);
- // Has to start with "c{" and end with "}"
- if(getSubStr(%d,0,2) $= "c{" && getSubStr(%d,%length - 1,1) $= "}")
- {
- // After the "c{" must be a color id 0 - 7
- if(strPos("01234567",getSubStr(%d,2,1)) != -1)
- {
- // "\c" @ %color doesnt work but this does
- eval("%color = \"\\c" @ getSubStr(%d,2,%length - 3) @ "\";");
- %this.nameColor = %color;
- %d = "";
- }
- }
- Parent::onConnectRequest(%this,%a,%b,%c,%d,%e,%f,%g);
- }
- };
- activatePackage(ColoredNames);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement