Author Topic: OnRequestGame(), State var issue.  (Read 982 times)

0 Members and 1 Guest are viewing this topic.

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
OnRequestGame(), State var issue.
« on: October 29, 2009, 07:49:25 pm »
I made a little script:

Code: [Select]
function OnRequestGame(IP: string;State: integer):integer;
var
pass: string;
begin
pass:=ReadINI('soldat.ini','NETWORK','Game_Password','*ERROR*');
if(Password=pass)and(State=3) then State:=1;
Result:=State;
end;

Basically, if current password matches the one specified in the soldat.ini then if someone joins the server with wrong password script should let them in. I've checked the Result at the end, it is set to '1' when that 'if..then' is true. The problem is that the players can't join anyway. It seems the server is sending back Result=3 - wrong password, despite the fact that it had been changed to 1.

Any ideas on how to fix that?

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: OnRequestGame(), State var issue.
« Reply #1 on: October 30, 2009, 12:02:08 am »
Despite the fact that readini is a major memory leak you could add a few debugging lines and post the results for us, like so:
Code: [Select]
function OnRequestGame(IP: string;State: integer):integer;
var
pass: string;
begin
pass:=ReadINI('soldat.ini','NETWORK','Game_Password','*ERROR*');
writeln('pass='+pass+'   password='+password+'    state='+inttostr(state));
if(Password=pass)and(State=3) then State:=1;
Result:=State;
end;

Just noticed: where are you getting this 'Password' variable? If its the global game password then they should always equal.

(Sorry if theres typos, i am posting this from my ipod)


Offline Quantifier

  • Major
  • *
  • Posts: 70
Re: OnRequestGame(), State var issue.
« Reply #2 on: October 30, 2009, 01:34:36 am »
Just noticed: where are you getting this 'Password' variable? If its the global game password then they should always equal.

There is global 'Password' variable with current password to the server. The two variables here don't need to be equal always:
1. password was changed by admin command
2. server was started with different configuration file than soldat.ini


It seems the server is sending back Result=3 - wrong password, despite the fact that it had been changed to 1.

Any ideas on how to fix that?

Check if there are other scripts, OnRequestGame is invoked in every running script, and all but one return values are discarded.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: OnRequestGame(), State var issue.
« Reply #3 on: October 30, 2009, 02:01:19 am »
Why would you want to do this? Trying to make it a public server while paying for a private server?

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: OnRequestGame(), State var issue.
« Reply #4 on: October 30, 2009, 02:51:53 am »
A few things you can try:
1. if(Password=pass) and (State=3) then Result := 1; Get rid of the Result := State; line.
2. In NetworkCore.pas set Result := 1; just to check if that is the problem.

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
Re: OnRequestGame(), State var issue.
« Reply #5 on: October 30, 2009, 07:16:43 am »
Hacktank: I've already tried putting some debugging lines. pass, Password and State have proper values. if...then is true, State is set to 1, Result is set to 1.

EnEsCe: That's exactly what I was trying to do, not for my self though...

Quantifier: There are no other scripts with OnRequestGame(), except for NetworkCore.pas

iDante: I'll try that.

EDIT: I've deleted
Code: [Select]
Result:=State line in NetworkCore.pas and the scipt seems to be working now.
« Last Edit: October 30, 2009, 08:49:19 am by JotEmI »