Author Topic: Move to Spectator if name...  (Read 3958 times)

0 Members and 1 Guest are viewing this topic.

Offline sepetphalanx

  • Major(1)
  • Posts: 1
Move to Spectator if name...
« on: March 29, 2007, 06:04:14 pm »
Script Name: What's in a name?
Script Description: This will instantly move anyone that joins with a specific word in their name to the spectators and then send then broadcast a message
Original Author: Sepet Phalanx
Core Version: 2.5.4

Code: [Select]
procedure OnJoinTeam(IP, Nickname: string;Team: byte);
var
  swearWord: array[1..32] of string;
  i: integer;
begin
  { put your swear words here }
  swearWord[1] := 'word1';
  swearWord[2] := 'word2';
  swearWord[3] := 'word3';
  { make sure --v-- that number matches your number of swear words }
  for i := 1 to 3 do if(ContainsString(LowerCase(Nickname), LowerCase(swearWord[i]))) then begin
    { Move player to spectators... }
    Command('/SETTEAM5 ' + inttostr(NametoID(Nickname)));
    { Message... }
    SayToPlayer(NametoID(Nickname),Nickname + ', please change your name!');
  end;
end;
If you copy and paste that then my poor excuse for an ascii arrow should line up with the '3' in the line below it.
« Last Edit: March 30, 2007, 09:49:17 am by sepetphalanx »

Offline HEX

  • Major
  • *
  • Posts: 77
  • =tNt=
    • SoldatX Brazilian Community
Re: Move to Spectator if name...
« Reply #1 on: May 05, 2007, 01:01:00 pm »
Does it accept wildcards?
Code: [Select]
swearWord[1] := 'word1*';
swearWord[2] := '*word1';



Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: Move to Spectator if name...
« Reply #2 on: May 05, 2007, 02:08:48 pm »
Use this for wildcards:

Code: [Select]
...
for i := 1 to 3 do if(MaskCheck(LowerCase(Nickname), LowerCase(swearWord[i]))) then begin
...
« Last Edit: May 05, 2007, 02:11:47 pm by xmRipper »
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline zooc

  • Major(1)
  • Posts: 12
Re: Move to Spectator if name...
« Reply #3 on: May 05, 2007, 02:32:09 pm »
HEX, you don't have to use star (*) as it's said in Script Description: will move anyone (...) with a specific word in their name
so it'll work just fine

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: Move to Spectator if name...
« Reply #4 on: May 05, 2007, 02:46:22 pm »
HEX, you don't have to use star (*) as it's said in Script Description: will move anyone (...) with a specific word in their name
so it'll work just fine

but you cant use like 'word*word'

sorry for little bad english
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline zooc

  • Major(1)
  • Posts: 12
Re: Move to Spectator if name...
« Reply #5 on: May 05, 2007, 03:11:37 pm »
you're right there, your answer was better :)

i only answered for exact HEX question, hehe

Offline HEX

  • Major
  • *
  • Posts: 77
  • =tNt=
    • SoldatX Brazilian Community
Re: Move to Spectator if name...
« Reply #6 on: May 05, 2007, 04:17:21 pm »
This code is out-of-date. A friend of mine will fix it... I'm gonna ask him to post here as soon as he finish it.
« Last Edit: May 05, 2007, 04:20:03 pm by HEX »



Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Move to Spectator if name...
« Reply #7 on: May 05, 2007, 05:07:01 pm »
Code: [Select]
procedure swearWord_OnJoinTeam(ID, Team: byte);
var
swearWord: array[1..32] of string;
i, NumberOfWords: integer;
Nickname: string;
begin
if Team <> 5 then
begin
// put your swear words here
swearWord[1] := '[Spec]';

// make sure NumberOfWords has the correct value
NumberOfWords := 1;

Nickname := IDToName(ID);

for i := 1 to 3 do
begin
if(ContainsString(LowerCase(Nickname), LowerCase(swearWord[i]))) then
begin
// Move player to spectators...
Command('/SETTEAM5 ' + inttostr(ID));
// Message...
SayToPlayer(ID, Nickname + ', please change your name!');
end;
end;
end;
end;

i change the OnJoinTeam procedure name so i can put this in a separated file swearword.pas and add it in the include.txt, before networkcore.pas
then all i do is modify networkcore.pas this way

Code: [Select]
procedure OnJoinTeam(ID, Team: byte);
begin
swearWord_OnJoinTeam(ID, Team);
end;
urraka

Offline HEX

  • Major
  • *
  • Posts: 77
  • =tNt=
    • SoldatX Brazilian Community
Re: Move to Spectator if name...
« Reply #8 on: May 05, 2007, 05:10:06 pm »
Thanks!! :)



Offline NeoniK

  • Major(1)
  • Posts: 7
Re: Move to Spectator if name...
« Reply #9 on: June 09, 2007, 10:27:42 am »
I have script PerroAZUL, how make it to use some commands to able or disable script to join spectator ?

Offline HEX

  • Major
  • *
  • Posts: 77
  • =tNt=
    • SoldatX Brazilian Community
Re: Move to Spectator if name...
« Reply #10 on: June 09, 2007, 04:30:34 pm »
Try this:

Code: [Select]
var
swearWord_script: boolean;

procedure swearWord_OnJoinTeam(ID, Team: byte);
var
swearWord: array[1..32] of string;
i, NumberOfWords: integer;
Nickname: string;
begin
if (Team <> 5) And (swearWord_script = true) then
begin
// put your swear words here
swearWord[1] := '[Spec]';

// make sure NumberOfWords has the correct value
NumberOfWords := 1;

Nickname := IDToName(ID);

for i := 1 to 3 do
begin
if(ContainsString(LowerCase(Nickname), LowerCase(swearWord[i]))) then
begin
// Move player to spectators...
Command('/SETTEAM5 ' + inttostr(ID));
end;
end;
end;
end;

procedure swearWord_ActivateServer();
begin
swearWord_script := false;
end;

function swearWord_OnCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/specon' then
begin
swearWord_script := true;
WriteLn('Enabled!');
end
else if Text = '/specoff' then
begin
swearWord_script := false;
WriteLn('Unabled');
end;
Result := false;
end;

Turning on /specon
Turning off /specoff

Date Posted: June 09, 2007, 06:29:36 PM
And don't forget
Code: [Select]
begin
swearWord_OnJoinTeam(ID, Team);
end;

Modify networkcore.pas with this code just like Perro said.



Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Move to Spectator if name...
« Reply #11 on: June 09, 2007, 08:00:20 pm »
That seems to be right. One thing only: 'Unabled' = 'Disabled' :P
urraka

Offline NeoniK

  • Major(1)
  • Posts: 7
Re: Move to Spectator if name...
« Reply #12 on: June 10, 2007, 07:24:49 am »
It doesn't work

Offline Geistlort

  • Major(1)
  • Posts: 6
Re: Move to Spectator if name...
« Reply #13 on: August 28, 2007, 05:29:55 pm »
thanks

Offline dragus

  • Major(1)
  • Posts: 23
Re: Move to Spectator if name...
« Reply #14 on: November 19, 2008, 08:56:44 am »
who can give to me scripts  a    /specall