Author Topic: OnPlayerSpeak  (Read 874 times)

0 Members and 1 Guest are viewing this topic.

Offline Rey.

  • Major(1)
  • Posts: 6
OnPlayerSpeak
« on: May 25, 2013, 02:47:11 pm »
Hello guys, I have problem. How to change this command alter the map:

!map ctf_Name  to  !map Name (without ctf_) ?

Code: [Select]

if Copy(Text,1,1) = '!' then
begin
Delete(Text,1,1);
if MaskCheck(Text,'map *') then
begin
Delete(Text,1,4);
if FileExists('maps/'+Text+'.PMS') or FileExists('maps/'+Text+'.pms') then
Command('/map '+Text)
else
WriteConsole(ID,'Map not found ('+Text+')', Color);
exit;
end;


Please, help me.
« Last Edit: May 25, 2013, 02:52:32 pm by Rey. »

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: OnPlayerSpeak
« Reply #1 on: May 25, 2013, 04:15:22 pm »
Code: [Select]

if Copy(Text,1,1) = '!' then
begin
Delete(Text,1,1);
if MaskCheck(Text,'map ctf_*') then
begin
Delete(Text,1,8);
if FileExists('maps/ctf_'+Text+'.PMS') or FileExists('maps/ctf_'+Text+'.pms') then
Command('/map ctf_'+Text)
else
WriteConsole(ID,'Map not found (ctf_'+Text+')', Color);
exit;
end;

"My senses are so powerful that I can hear the blood pumping through your veins."

Offline SyavX

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 338
Re: OnPlayerSpeak
« Reply #2 on: May 26, 2013, 08:27:48 pm »
Uhm... Furai, I guess this
!map ctf_Name  to  !map Name (without ctf_) ?
means the use of !map command without specifying the "ctf_" prefix for CTF maps.

It could be done like this:
Code: [Select]
    if (Length(Text) > 5) and (Copy(Text,1,5) = '!map ') then begin
        Delete(Text,1,5);
        Text := Trim(Text);
        if Length(Text) > 0 then begin
            if FileExists('maps/'+Text+'.PMS') or FileExists('maps/'+Text+'.pms') then
                Command('/map '+Text)
            else
                if Copy(Text,1,4) <> 'ctf_' then
                    if FileExists('maps/ctf_'+Text+'.PMS') or FileExists('maps/ctf_'+Text+'.pms') then
                        Command('/map ctf_'+Text)
                    else
                        WriteConsole(ID,'Map not found (ctf_'+Text+')', Color)
                else
                    WriteConsole(ID,'Map not found ('+Text+')', Color);
            exit;
        end;
    end;

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: OnPlayerSpeak
« Reply #3 on: May 27, 2013, 07:10:00 am »
He didn't say that he wants to retain old functionality as well. :P

But yeah, I haven't touched single script in years...If anything - use SyavX version.
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline Rey.

  • Major(1)
  • Posts: 6
Re: OnPlayerSpeak
« Reply #4 on: May 28, 2013, 06:43:32 am »
Thanks SyavX, Furai for help.