Author Topic: Prevent default action from happening  (Read 1375 times)

0 Members and 1 Guest are viewing this topic.

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
Prevent default action from happening
« on: June 04, 2007, 01:50:31 pm »
In an effort to update my Ingame ZitroStats -script/snippet I've come across some questions I couldn't find an answer to.
I've not been scripting for soldat for some months now, and have almost no Pascal experience, so I hope these questions aren't to obvious :)

Question 1: Is it possible to prevent a default event action from happening?
For example, if someone says '!hello' all players see this in there 'log' and above the player. Can I cancel this default action by placing some code in the OnPlayerSpeak procedure?

Question 2: How (if possible) can I send text to the game as if a particular player said this.
For example, can I let a player say 'Look at me, I'm a statswhore' ? :D

Sorry for my terrible English
lol @ the forum censoring 'bad' words
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Prevent default action from happening
« Reply #1 on: June 04, 2007, 02:28:17 pm »
Question 1: Is it possible to prevent a default event action from happening?
For example, if someone says '!hello' all players see this in there 'log' and above the player. Can I cancel this default action by placing some code in the OnPlayerSpeak procedure?
Not for OnPlayerSpeak. Under OnCommand and OnPlayerCommand, you can set the result to false (allow the command to do its thing) or true (command does no default effect) although for OnPlayerSpeak, there is no result thing so I don't believe you can stop that from happening.

Question 2: How (if possible) can I send text to the game as if a particular player said this.
For example, can I let a player say 'Look at me, I'm a stats*****' ? :D
Only for bots can u force to say message with the BotChat procedure. You can't force a human to say anything. You can make it semi-appear like they are speaking, except there would be a ' [.*] ' (w/out the ".") in front of it, when you use WriteConsole.

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
Re: Prevent default action from happening
« Reply #2 on: June 04, 2007, 03:12:45 pm »
Thank you for the reply! Too bad I can't make it work as I would like to, but it's not really important so it's not that bad :)

Could these be feature requests?
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Prevent default action from happening
« Reply #3 on: June 04, 2007, 03:45:54 pm »
Could these be feature requests?
I believe the result part thing for OnPlayerSpeak has already been asked but sense its ran under a different thingy (i really have no idea), it can't be done.

Outside the topic: An admin will yell at you for your sig being too long on the 1 line :P
"Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) now playing: DesertWind (0/32)" = 88 characters
70 characters is the max
I know... its annoying. I've already been yelled at i believe 2 times :)

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
Re: Prevent default action from happening
« Reply #4 on: June 04, 2007, 04:54:36 pm »
I believe the result part thing for OnPlayerSpeak has already been asked but sense its ran under a different thingy (i really have no idea), it can't be done.
That's too bad :/

Outside the topic: An admin will yell at you for your sig being too long on the 1 line :P
"Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) now playing: DesertWind (0/32)" = 88 characters
70 characters is the max
I know... its annoying. I've already been yelled at i believe 2 times :)
Than they should be really mad about the first line, as it's a wopping 123 bytes long ;). Anyway, thx for the tip, I've fixed that now.
I rather see a couple long lines than a bunch of short lines! 640x480 is so 1985... I love my 1600x1200 :P
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Prevent default action from happening
« Reply #5 on: June 04, 2007, 05:21:58 pm »
There is a /mute command to mute a player. I haven't tried it and i actually don't think it would work, but maybe if you call that command inside OnPlayerSpeak it works.
urraka

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
Re: Prevent default action from happening
« Reply #6 on: June 05, 2007, 04:09:50 am »
Sounds really clever, I should give it a try!

EDIT: I'll try it later, stupid  26376347? is not a valid integer error :(

Date Posted: June 05, 2007, 12:30:06 AM
Using /mute isn't going to work :(, I just found out that /mute is a clientside command. So you can't use that.
But is there an other way to mute an user on the server? (Could be very usefull for other scripts, I guess)
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Prevent default action from happening
« Reply #7 on: June 05, 2007, 10:25:55 am »
/gmute mutes a player server side, so no one can hear them scream.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Prevent default action from happening
« Reply #8 on: June 05, 2007, 12:47:06 pm »
When somebody speaks, their Text is replaced with '(Muted)'
Code: [Select]
procedure OnJoinGame(ID, Team: byte);
begin
  Command('/gmute ' + InttoStr(ID));
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin
  Case GetPlayerStat(ID,'Team') of
    0: WriteConsole(0,Text,$FF000000);
    1: WriteConsole(0,Text,$FFFF0000);
    2: WriteConsole(0,Text,$FF0000FF);
    3: WriteConsole(0,Text,$FF00FF00);
    4: WriteConsole(0,Text,$FFFFFF00);
    5: WriteConsole(0,Text,$FFFFFFFF);
  end;
end;
:( Ruins many people's fun right there.

Plus theres that annoying message  that says your muted every time you talk.

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
Re: Prevent default action from happening
« Reply #9 on: June 06, 2007, 05:25:36 am »
Thanks for the replies, but I'll just have to let it go and make the script in an other way. It's not crucial for the script, it only requires some cosmetic changes.

Thanks anyway, and I hope someday these features are implanted.
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)