Author Topic: Scripting failure experiences?  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.

Offline Fryer

  • Camper
  • ***
  • Posts: 261
  • Game dev
Scripting failure experiences?
« on: June 10, 2012, 02:17:29 am »
I've decided to make a topic about it, because I decided to start my own server and do all the scripting for it, and apparently bugs appear sometimes...

Starting with something that just happened...

Yesterday I completed (or thought so) a script for my server, Haywire CTF, that makes it put players as spectator if there are already an amount of people playing. On my server I set this limit to 10. I had tested it on bots first and it was working quite well, so I did some small final adjustments before going live. BAD IDEA. I changed the server setting to add the server to the lobby; I joined; I waited... Slowly, people started joining.

At some point in time, the player count was being about 6-9, going up and down a bit, kinda like a cubed sine wave. I was ofc thinking about how the 11th player would react to the awesome script! ("omfg wtf stupid queue qq") Then the 10th player joined, and all havok occurred:
Quote
[...]
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
► +          .from russia with love has joined alpha team.
► +          .from russia with love has joined spectators.
[...]

Why? I had somehow in my haste to get the script done put ">=" instead of ">"! :o

So what was happening was that the 10th guy joined, and the script checked this:
Code: [Select]
if (AlphaPlayers + BravoPlayers >= PlayerLimit) [...]That was true, which sent him to the join queue (spectator). Then there was another code right after it which looked like this:
Code: [Select]
while (AlphaPlayers + BravoPlayers < PlayerLimit)[...]And that code sent him back to alpha team...

I guess someone must have had similar stuff happen, considering how little time I've spent on scripting. So yeah, let everyone know about those stupid mistakes, so people can laugh at you. 8)

Related link
...PC vs Mac is like AK47 vs M4A1...
<DutchFlame`> i once heard running runescape in the background gave you a speedboost
<Mr> yes, it allocates more electrons, so there are more electrons available for Soldat -> they are streched less and it is more fluent

Soldat PolyWorks 1.5.0.13 - AimMode - Aim practise gamemode script - Fryer's SoldatStream Mod

Offline ExHunter

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 154
  • Speedy go!
Re: Scripting failure experiences?
« Reply #1 on: June 12, 2012, 02:12:55 pm »
On Hide and Seek:

something like (out of my head):

Code: [Select]
procedure randomevent();
begin
  lastevent := currentevent;
  repeat
    currentevent := Random(10, 11);
  until(lastevent <> currentevent);
end;

Random(10,11); because I wanted to test a certain thing. Yea.. I like endless loops. Tested it on a full server (15 of 15 slots) - I took like 3 server restarts to finally get it :(

---

I could tell alot more, but I approve - every scripter knows that feel.. xD

Edit: Random(10,11); will always have 10 as result.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Scripting failure experiences?
« Reply #2 on: June 12, 2012, 08:43:08 pm »
Random's 2nd parameter will never be reached. If you want integers form A (inclusive) to B (inclusive), you need to add 1 to B: Random(A, B+1).

Offline ExHunter

  • Inactive Soldat Developer
  • Soldier
  • ******
  • Posts: 154
  • Speedy go!
Re: Scripting failure experiences?
« Reply #3 on: June 13, 2012, 01:49:42 pm »
Random's 2nd parameter will never be reached. If you want integers form A (inclusive) to B (inclusive), you need to add 1 to B: Random(A, B+1).

Yea, I know that. But the problem was, that I just wanted to test one certain event (so I made out of 1 a 10, so that it will always be 10), which made it crash. I thought this topic was supposed to post to show up our scripting fails. :D

Offline Fryer

  • Camper
  • ***
  • Posts: 261
  • Game dev
Re: Scripting failure experiences?
« Reply #4 on: June 13, 2012, 02:04:40 pm »
Something that was bothering me when making my team balancer and queue scripts was that at a certain point I just couldn't get it to work with bots anymore (since bots sometimes don't fire the joined team event). That would require me to ask people to join my server for script testing, which gets kinda annoying when they were not clear as to what they were doing and the script crashes. :P

I should probably try to fix that thing with bots anyways...
...PC vs Mac is like AK47 vs M4A1...
<DutchFlame`> i once heard running runescape in the background gave you a speedboost
<Mr> yes, it allocates more electrons, so there are more electrons available for Soldat -> they are streched less and it is more fluent

Soldat PolyWorks 1.5.0.13 - AimMode - Aim practise gamemode script - Fryer's SoldatStream Mod

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Scripting failure experiences?
« Reply #5 on: June 15, 2012, 09:17:45 am »
Use a boolean variable and set it to false when the server starts or a player leaves the game.
Then check if it's false in OnPlayerRespawn and you know if a player has just joined.
It's already a known problem for a long time :P

Offline Fryer

  • Camper
  • ***
  • Posts: 261
  • Game dev
Re: Scripting failure experiences?
« Reply #6 on: June 15, 2012, 04:58:57 pm »
Use a boolean variable and set it to false when the server starts or a player leaves the game.
Then check if it's false in OnPlayerRespawn and you know if a player has just joined.
It's already a known problem for a long time :P
Ah, I didn't think about checking with OnPlayerRespawn; that's quite a nice quick fix for the way scripting works now, until I fix the bug. Got any cool ideas for how to check if the bot was added in spectators? :)

The boolean check thing I'm already using. (It's a bit more complex than boolean, but w/e.)
...PC vs Mac is like AK47 vs M4A1...
<DutchFlame`> i once heard running runescape in the background gave you a speedboost
<Mr> yes, it allocates more electrons, so there are more electrons available for Soldat -> they are streched less and it is more fluent

Soldat PolyWorks 1.5.0.13 - AimMode - Aim practise gamemode script - Fryer's SoldatStream Mod

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Scripting failure experiences?
« Reply #7 on: June 16, 2012, 07:49:36 am »
You move bots to the spectator team by scripting (except the rare case when you already assign them to spec), get the point?