Jump to content
  • We need you!

    You must register to discover all the features of our community!

  • 0

Empire lock from source


regal

Question

Posted (edited)

Version of Files : 40k

 

1. Description of the problem / Question :

 

Hello everyone. I want to make  only one kingdom available for players , I changed everything from client side according to one tutorial found here(in locale/root) and now, in my client, you cannot choose anymore another empire.

The problem is I want to put also something in source to check the empire and if it is different from empire id 1 for example(shinso), disconnect the player or something similar.

I've come across this code from input_login.cpp, as I guess here I should work. Can someone help me to solve it out as I don't really know how I should change the values to make what I want. Right now I can change another empire if I use another client to login, so I want to forbid this, we all know that some people like to make problems, you're never safe enough...

void CInputLogin::Empire(LPDESC d, const char * c_pData)
{
	const TPacketCGEmpire* p = reinterpret_cast<const TPacketCGEmpire*>(c_pData);

	if (EMPIRE_MAX_NUM <= p->bEmpire)
	{
		d->SetPhase(PHASE_CLOSE);
		return;
	}

	const TAccountTable& r = d->GetAccountTable();

	if (r.bEmpire != 0)
	{
		for (int i = 0; i < PLAYER_PER_ACCOUNT; ++i)
		{
			if (0 != r.players[i].dwID)
			{
				sys_err("EmpireSelectFailed %d", r.players[i].dwID);
				return;
			}
		}
	}

	TEmpireSelectPacket pd;

	pd.dwAccountID = r.id;
	pd.bEmpire = p->bEmpire;

	db_clientdesc->DBPacket(HEADER_GD_EMPIRE_SELECT, d->GetHandle(), &pd, sizeof(pd));
}

 

 

 

Thank you very much for spending your time to read my problem,

regal.

 

Edited by regal (see edit history)
Link to post

5 answers to this question

Recommended Posts

  • 0
Posted (edited)

In your situation since the empires only "softlocked" then i would just use a quest like this:

when login begin

 if pc.get_empire() > 1 then

  pc.change_empire(1)
  --command("quit") --This command will force close the client if you want to punish the cheating player

 end

end

You can add this if case to your give_basic_weapon.quest for example.

Edit: I added the quit command if you want to close the player's client.

Edited by TMP4 (see edit history)
  • Love 1
Link to post
  • 0
Posted (edited)
2 hours ago, TMP4 said:

In your situation since the empires only "softlocked" then i would just use a quest like this:

when login begin  if pc.get_empire() > 1 then   pc.change_empire(1) --command("quit") --This command will force close the client if you want to punish the cheating player  end end

when login begin

 if pc.get_empire() > 1 then

  pc.change_empire(1)
  --command("quit") --This command will force close the client if you want to punish the cheating player

 end

end

You can add this if case to your give_basic_weapon.quest for example.

Edit: I added the quit command if you want to close the player's client.

First, thank you for answering this topic.

So, I made a quest like this:

quest empire begin
    state start begin
		when login begin
			if pc.get_empire() > 1
			then pc.change_empire(1)
				command("quit")						
			end
		end
	end
end

But, when I login, nothing happens. The empire doesn't change and I'm not logged out. Do you know what I did wrong?

Thank you

Edited by regal (see edit history)
Link to post
  • 0
Posted (edited)

Your "if" "then" in different line is weird but if qc can compile it then it's ok. 

Try to check where it stucks like this:

quest empire begin
    state start begin
		when login begin
			say("Test1") --Every character should see this, otherwise you did not compiled your quest
			if pc.get_empire() > 1 then 
				say("Just empire 2 and 3 should see this")
				wait() -- ok button
				pc.change_empire(1)
				command("quit")
			end
		end
	end
end   

If you do not even see the "Test1" then you did not compiled your quest.

 

Also metin2's lua implementation sometimes weird so maybe instead of this: if pc.get_empire() > 1 then 

try this: if pc.get_empire() == 2 or pc.get_empire() == 3 then

 

 

Edited by TMP4 (see edit history)
  • Love 1
Link to post
  • 0
Posted (edited)
42 minutes ago, TMP4 said:

Try to check where it stucks like this:

 

quest empire begin state start begin when login begin say("Test1") --Every character should look this, otherwise you did not compiled your quest if pc.get_empire() > 1 then say("Just empire 2 and 3 should look this") wait() -- ok button pc.change_empire(1) command("quit") end end end end

quest empire begin
    state start begin
		when login begin
			say("Test1") --Every character should look this, otherwise you did not compiled your quest
			if pc.get_empire() > 1 then 
				say("Just empire 2 and 3 should look this")
				wait() -- ok button
				pc.change_empire(1)
				command("quit")
			end
		end
	end
end   

If you do not even see the "Test1" then you did not compiled your quest.

The Test1 appears everytime I login or change map, still it doesn't do anything.

In syserr I've got this:

SYSERR: May 24 20:37:57 :: RunState: LUA_ERROR: [string "empire"]:2: attempt to compare nil with number
SYSERR: May 24 20:37:57 :: WriteRunningStateToSyserr: LUA_ERROR: quest empire.start click

Actually I solved it out, it worked by changing pc.get_empire() > 1 then like you said.

Thank you very much! 

Edited by regal (see edit history)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.