Jump to content

Quest lua edit from VIP to [] ?


Recommended Posts

hello guys..

im not good on lua and what i understand is not easy to edit with simple replace for []

Quest lua: https://pastebin.com/knnMLXgw >> made by braxy but i want to be update for [] example [Smon] now the default quest is work like this example: [VIP]Smon

original link: #deleted idk if you understand romanian lang :D but are some codes need to add/edit to work to not create some duplicate items about name etc.. exploints fix etc..

 

a fix was after the name etc.. to need to disconect the player to work etc..

Quote

 

questlua_pc.cpp  int pc_change_name(lua_State* L)

bellow this:
ch->SetNewName(szName);

add this:
ch->GetDesc()->DelayedDisconnect(1);

 

 

was more option to make it on the quest to update is:

 

make check_name_for_vip in the source.. where to work [] + 5 characters something like that..

 

idk guys im not good.. but seems to over complicate for me and make so many exploints so i come here to find the perfect solution..

sry if is to easy but i want to be sure.. where are exploints i need to be very sure.. so ye..

if anyone is good on lua and is kind to help me with this little.. edit will be nice :D

  • Good 1
  • Love 1
Link to comment
Share on other sites

  • Premium
quest ChangeNameWithVip begin
	state start begin
		function isNameAlready(pc_name)
			local index, value = mysql_direct_query("SELECT player.player.name as name FROM player.player;");
		   
			if (index > 0) then
				for num, str in ipairs(value) do
					if (string.lower(str.name) == string.lower(pc_name)) then
						return false;
					end -- if
				end -- for
			end -- if
			
			return true;
		end -- function
	   
		function ChangeNameAddVip(new_name)
			mysql_direct_query(string.format("UPDATE player.player SET name = '%s' WHERE name = '%s';", new_name, pc.get_name()));
		end -- function
	   
		function isVipAlreadyAdded()
			return pc.getqf("ChangeNameWithVipUsage") ~= 0;
		end -- function
	   
		when 71173.use begin
			if (ChangeNameWithVip.isVipAlreadyAdded()) then
				return syschat("Poti adauga gradul [VIP] doar odata pe caracter!");
			end -- if
		   
			say_title(string.format("%s:[ENTER]", item_name(item.get_vnum())))
			say("Acest obiect ofera posibilitatea de a adauga")
			say("gradul de [VIP] caracterului tau si")
			say("cu posibilitatea de a schimba numele precedent.[ENTER]")
			say("Doresti sa incepi procesul?[ENTER]")
			if (select("Da", "Nu") == 1) then
				say_title(string.format("%s:[ENTER]", item_name(item.get_vnum())))
				say("Introdu numele dorit:[ENTER]")
				local str_input = string.gsub(input(), "[^A-Za-z0-9]", "");
				local input_len = string.len(str_input);
			   
				if (input_len < 3 or input_len > 7) then
					return say_reward("The length has to be from 3 to 7 characters.[ENTER]");

				elseif (not ChangeNameWithVip.isNameAlready(string.format("[%s]", str_input))) then
					return say_reward("Acest nume a fost luat de catre alta persoana.[ENTER]");
				end -- if/elseif
			   
				pc.remove_item(71173, 1);
				pc.setqf("ChangeNameWithVipUsage", 1);
				ChangeNameWithVip.ChangeNameAddVip(string.format("[%s]", str_input));
				say("Adaugarea gradului [VIP] a avut succes.")
				say("Actualizarea acestuia se face dupa 15 min")
				say("offline de pe caracter/cont.[ENTER]")
			end -- if
		end -- when	
	end -- state
end -- quest

Modifying Braxy's quests is very easy, they're very similiar to mine.. for some reason.

 

But then again, the guy is still using regex when it's completely unneded and uses a query to change the name instead of using a simple function (pc.change_name), pretty disappointing.

Edited by Syreldar
Changed to No Syntax Highlighting until ASIKOO fixes it for dark mode.
  • Love 2

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

Eh old stuff, can be improved so much but i don't quite have the time to improve all my releases for now.

@Syreldar Not sure what you want to say but i guess we both know LUA's syntax is not that complex lol

 

Whatever, Syreldar version is alright but i would avoid that retarded loop anyway so: https://pastebin.com/ngi4ZXvB

(Regarding Duplicate bug, that bug only exists if you use pc.change_name function, since the function that changes name is based on SQL there won't be any Duplicate Bugs)

Edited by Braxy
  • Good 1
  • Love 1

As long as I'll be a threat for you , i will always be your target :3

Link to comment
Share on other sites

  • Premium
34 minutes ago, Braxy said:

Not sure what you want to say but i guess we both know LUA's syntax is not that complex lol

 

Mh?

Do you REALLY want to say that again?

 

Quote

Whatever, Syreldar version is alright but i would avoid that retarded loop anyway so: https://pastebin.com/ngi4ZXvB

 

"My" version? I merely made your code barely readable and changed it according to what the OP asked for.

May God strike me with lightning if I ever post/rework something publicly ever again after seeing this.

 

34 minutes ago, Braxy said:

 

(Regarding Duplicate bug, that bug only exists if you use pc.change_name function, since the function that changes name is based on SQL there won't be any Duplicate Bugs)

 

You sure know a lot.

	ALUA(pc_change_name)
	{
    	//..
        char szQuery[1024];
		snprintf(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM player%s WHERE name='%s'", get_table_postfix(), szName);
		std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery(szQuery));

		if ( pmsg->Get()->uiNumRows > 0 )
		{
			MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);

			int	count = 0;
			str_to_number(count, row[0]);

			// ÀÌ¹Ì ÇØ´ç À̸§À» °¡Áø ij¸¯ÅÍ°¡ ÀÖÀ½
			if ( count != 0 )
			{
				lua_pushnumber(L, 3);
				return 1;
			}
		}
        //..
	}

Because I've always thought pc.change_name also did check for that and many other factors via query (duh, no other way to do that?) and worked pretty fine.

 

I advise you to add me on Discord or Skype if you feel the need to tell me something, because to tell the truth.. I feel that you have had it for a very long time.

Edited by Syreldar
  • Good 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

12 hours ago, Syreldar said:

 

Mh?

Do you REALLY want to say that again?

 

 

"My" version? I merely made your code barely readable and changed it according to what the OP asked for.

May God strike me with lightning if I ever post/rework something publicly ever again after seeing this.

 

 

You sure know a lot.


	ALUA(pc_change_name)
	{
    	//..
        char szQuery[1024];
		snprintf(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM player%s WHERE name='%s'", get_table_postfix(), szName);
		std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery(szQuery));

		if ( pmsg->Get()->uiNumRows > 0 )
		{
			MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);

			int	count = 0;
			str_to_number(count, row[0]);

			// ÀÌ¹Ì ÇØ´ç À̸§À» °¡Áø ij¸¯ÅÍ°¡ ÀÖÀ½
			if ( count != 0 )
			{
				lua_pushnumber(L, 3);
				return 1;
			}
		}
        //..
	}

Because I've always thought pc.change_name also did check for that and many other factors via query (duh, no other way to do that?) and worked pretty fine.

 

I advise you to add me on Discord or Skype if you feel the need to tell me something, because to tell the truth.. I feel that you have had it for a very long time.

 

There was no intention to attack you in any way what so ever so don't take it that personally.

I just resumed to the fact that my quest was written like (3 years ago >> released 2y ago) and yea, it was poorly written, can't lie about that.

 

Even tho, i don't have the time nor the mood to update all my releases.

Anyway, back to the Duplicate bug, i was refering to the update packet part of the func, i said that since the update is made through SQL and you actually have to wait until the DB is updating your player account data there won't be any issue what so ever. I do know that the pc_change name uses SQL but it also uses update packets that are not P2P so it cant be updated on every each core.

 

Whatever, the point is, you are one of the fewest persons that actually know what are doing in LUA so for me, there is no motive to attack and so on. Therefore i'll add you on Discord so we can talk it further :) 

As long as I'll be a threat for you , i will always be your target :3

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • 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.