Author Topic: IRC like /me command  (Read 2385 times)

0 Members and 1 Guest are viewing this topic.

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
IRC like /me command
« on: August 06, 2008, 01:29:01 pm »
Script Name: IRC like /me command
Script Description: When you do /me MSG ingame, it says * NAME MSG to all players.
Original Author(s): jrgp. function Explode() by DorkyDear (thanks bro!)
Core Version: 2.2
Code:
Code: [Select]
//whenever someone does a command
procedure OnPlayerCommand(ID: Byte; Text: string);
var
halves: array of string;
begin
//what the person's command was, seperated by /me's
halves := Explode(Text, '/me');
//more than two items causes problems
if getarraylength(halves) > 2 then
exit;
//write it out!
WriteConsole(0, IDToName(ID)+halves[1], $FFffcccc);
end;
There are other worlds than these

Offline UnknownSniper

  • Camper
  • ***
  • Posts: 428
  • Southern by the Grace of God
Re: IRC like /me command
« Reply #1 on: August 06, 2008, 01:33:40 pm »
Very nice script, good job.

~Sorry, I'm not a very talkative person.~
I had a job and a piece of land
My sweet wife was my best friend
But I traded that for Cocaine and a whore
-Jamey Johnson


Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: IRC like /me command
« Reply #2 on: August 06, 2008, 04:07:48 pm »
lol nice
no slapping people around a bit with large tunas?

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: IRC like /me command
« Reply #3 on: August 06, 2008, 04:11:27 pm »
lol nice
no slapping people around a bit with large tunas?
haha, I'll have to add that too! What other irc like commands should this script have?
There are other worlds than these

Offline mar77a

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1295
  • mad
    • random stuffs
Re: IRC like /me command
« Reply #4 on: August 06, 2008, 04:15:31 pm »
The idea is good compared to the way it's coded. I mean, do you even need to explode()? Can't you just substr with Copy?
« Last Edit: August 06, 2008, 04:17:34 pm by mar77a »

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: IRC like /me command
« Reply #5 on: August 06, 2008, 04:27:21 pm »
Yeah looking at the source it seems this should be a lot simpler.
Can't you just substr with Copy?
I don't think there is a substr in the scripting core.
Instead I would do if GetPiece(Text,' ',0) = '/me' to check the first bit, and I dunno about the rest.
« Last Edit: August 06, 2008, 04:31:49 pm by iDante »

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: IRC like /me command
« Reply #6 on: August 06, 2008, 04:30:24 pm »
Yeah looking at the source it seems this should be a lot simpler.
Can't you just substr with Copy?
I don't think there is a substr in the scripting core.
Instead I would do if GetPiece(Text,' ',0) = '/me' to check the first bit, and I dunno about the rest.
if lowercase(copy(Text, 1, 4)) = '/me ' then ...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: IRC like /me command
« Reply #7 on: August 06, 2008, 04:32:58 pm »
if (LowerCase(Copy(Text, 1, 4)) = '/me ') then WriteConsole(0, GetPlayerStat(Id, 'Name') + ' ' + Copy(Text, 5, Length(Text)), $FFFFFFFF);

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: IRC like /me command
« Reply #8 on: August 07, 2008, 06:05:43 am »
Yeah, it would be a lot better to code it that way. Thanks for the suggestion. One thing though, the only thing that pisses me off to no end about Soldat Server Scripting is there are functions that exist in the scripting core but are not documented and cannot be found with google. I wish EnEsCe would post a list of functions that pretty much come with Pascal itself.
There are other worlds than these

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: IRC like /me command
« Reply #9 on: August 07, 2008, 09:07:28 am »
He did a while ago to somebody...
Code: [Select]
function inttostr(i: Int64): string;
function inttostr(i: Integer): string;
function strtoint(s: string): Longint;
function strtointdef(s: string; def: Longint): Longint;
function copy(s: string; ifrom, icount: Longint): string
function pos(substr, s: string): Longint;
procedure delete(var s: string; ifrom, icount: Longint);
procedure insert(s: string; var s2: string; ipos: Longint);
function getarraylength: integer;
Function StrGet(var S : String; I : Integer) : Char;
procedure StrSet(c : Char; I : Integer; var s : String);
Function WStrGet(var S : WideString; I : Integer) : WideChar;
procedure WStrSet(c : WideChar; I : Integer; var s : WideString);
Function StrGet2(S : String; I : Integer) : Char;
Function AnsiUppercase(s : string) : string;
Function AnsiLowercase(s : string) : string;
Function Uppercase(s : string) : string;
Function Lowercase(s : string) : string;
Function Trim(s : string) : string;
function Length(s : string) : Integer;
procedure SetLength;
function Low: Int64;
function High: Int64;
procedure Dec;
procedure Inc;
Function Sin(e : Extended) : Extended;
Function Cos(e : Extended) : Extended;
Function Sqrt(e : Extended) : Extended;
Function Round(e : Extended) : Longint;
Function Trunc(e : Extended) : Longint;
Function Int(e : Extended) : Extended;
Function Pi : Extended;
Function Abs(e : Extended) : Extended;
function StrToFloat(s: string): Extended;
Function FloatToStr(e : Extended) : String;
Function Padl(s : string;I : longInt) : string;
Function Padr(s : string;I : longInt) : string;
Function Padz(s : string;I : longInt) : string;
Function Replicate(c : char;I : longInt) : string;
Function StringOfChar(c : char;I : longInt) : string;
function Unassigned: Variant;
function VarIsEmpty(const V: Variant): Boolean;
function Null: Variant;
function VarIsNull(const V: Variant): Boolean;
function VarType(const V: Variant): TVarType;
procedure RaiseLastException;
procedure RaiseException(Ex: TIFException; Param: string);
function ExceptionType: TIFException;
function ExceptionParam: string;
function ExceptionProc: Cardinal;
function ExceptionPos: Cardinal;
function ExceptionToString(er: TIFException; Param: string): string;
function StrToInt64(s: string): int64;
function Int64ToStr(i: Int64): string;
function SizeOf: Longint;
function IDispatchInvoke(Self: IDispatch; PropertySet: Boolean; const Name: String; Par: array of variant): variant;

function GetTickCount():Cardinal

I added GetTickCount to the list sense it wasn't there; everything else EnEsCe listed.

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: IRC like /me command
« Reply #10 on: August 07, 2008, 06:10:16 pm »
Another one:

function CheckWeaponAllowed(WeaponNum: byte): boolean;
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline Mittsu

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 617
Re: IRC like /me command
« Reply #11 on: August 08, 2008, 07:11:57 pm »
nice script, but

"
  • [Error] me -> (OnPlayerCommand): Out Of Range"


it keeps appearing on my server.
Realistic-Soldat.net
<+elerok> soldat is dead
<+AThousandD> shit happens