Custom PrintToPlayer/PrintToServer Stuff

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Custom PrintToPlayer/PrintToServer Stuff

Post by tagban » Sun Jan 03, 2016 2:43 pm

Did you perform all of the specified changes in the various source files before doing that? I'd suggest double checking everything

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: Custom PrintToPlayer/PrintToServer Stuff

Post by Avatarati » Sun Jan 03, 2016 5:27 pm

Sure did. I have the text colors working fine, it's just not wanting to print anything when a user logs in. For testing purposes I used PrintToPlayer, which is standard in the header file to begin with.

I'll have to play with it some more tomorrow...

It's really not a big deal since I can just update the server_message config file for anything important. Honestly the only reason I wanted to implement this was to output string names for added personalization. It would have been a nice touch.

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Custom PrintToPlayer/PrintToServer Stuff

Post by tagban » Sun Jan 03, 2016 10:55 pm

my entire player.lua should help.

Code: Select all

-----------------------------------
--
--
--
-----------------------------------

require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/globals/quests");
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/globals/status");
require("scripts/globals/titles");
require("scripts/globals/gear_sets");

-----------------------------------
-- onGameIn
-----------------------------------

function onGameIn(player, firstlogin, zoning)
    if (not zoning) then -- Things checked ONLY during logon go here.
        if (firstlogin) then
            CharCreate(player);
        end
	player:PrintToServer(string.format("The character %s has logged in...", player:getName()), 0x1C);
	player:addStatusEffect(EFFECT_REFRESH,25,0,0);
    	player:addStatusEffect(EFFECT_REGEN,28,0,0);
	player:addStatusEffect(EFFECT_REGAIN,15,1,0);
	player:addStatusEffect(EFFECT_HASTE,60,1,0);
    end

    if (zoning) then -- Things checked ONLY during zone in go here.
        -- Nothing here yet :P
	player:addStatusEffect(EFFECT_REFRESH,25,0,0);
    	player:addStatusEffect(EFFECT_REGEN,28,0,0);
	player:addStatusEffect(EFFECT_REGAIN,15,1,0);
	player:addStatusEffect(EFFECT_HASTE,60,1,0);
	player:capAllSkills();
    end

    -- Things checked BOTH during logon AND zone in below this line.
    checkForGearSet(player);

    if (player:getVar("GodMode") == 1) then
        -- Add bonus effects to the player..
        player:addStatusEffect(EFFECT_MAX_HP_BOOST,1000,0,0);
        player:addStatusEffect(EFFECT_MAX_MP_BOOST,1000,0,0);
        player:addStatusEffect(EFFECT_SENTINEL,100,0,0);
        player:addStatusEffect(EFFECT_MIGHTY_STRIKES,1,0,0);
        player:addStatusEffect(EFFECT_HUNDRED_FISTS,1,0,0);
        player:addStatusEffect(EFFECT_CHAINSPELL,1,0,0);
        player:addStatusEffect(EFFECT_PERFECT_DODGE,1,0,0);
        player:addStatusEffect(EFFECT_INVINCIBLE,1,0,0);
        player:addStatusEffect(EFFECT_MANAFONT,1,0,0);
        player:addStatusEffect(EFFECT_REGAIN,150,1,0);
        player:addStatusEffect(EFFECT_REFRESH,99,0,0);
        player:addStatusEffect(EFFECT_REGEN,99,0,0);

        -- Add bonus mods to the player..
        player:addMod(MOD_RACC,2500);
        player:addMod(MOD_RATT,2500);
        player:addMod(MOD_ACC,2500);
        player:addMod(MOD_ATT,2500);
        player:addMod(MOD_MATT,2500);
        player:addMod(MOD_MACC,2500);
        player:addMod(MOD_RDEF,2500);
        player:addMod(MOD_DEF,2500);
        player:addMod(MOD_MDEF,2500);

        -- Heal the player from the new buffs..
        player:addHP( 50000 );
        player:setMP( 50000 );
    end

    if (player:getVar("GMHidden") == 1) then
        player:setGMHidden(true);
    end

end;

-----------------------------------
-- CharCreate
-----------------------------------

function CharCreate(player)
	local race = player:getRace();
	local body = nil;
	local leg = nil;
	local hand = nil;
	local feet = nil;

	-- ADD RACE SPECIFIC STARTGEAR
	switch(race) : caseof
	{
		-- HUME MALE
		[1] = function (x)
			body = 0x3157;
			hand = 0x31D2;
			leg = 0x3253;
			feet = 0x32CD;
		end,

		-- HUME FEMALE
		[2] = function (x)
			body = 0x3158;
			hand = 0x31D8;
			leg = 0x3254;
			feet = 0x32D2;
		end,

		-- ELVAAN MALE
		[3] = function (x)
			body = 0x3159;
			hand = 0x31D3;
			leg = 0x3255;
			feet = 0x32CE;
		end,

		-- ELVAAN FEMALE
		[4] = function (x)
			body = 0x315A;
			hand = 0x31D7;
			leg = 0x3259;
			feet = 0x32D3;
		end,

		-- TARU MALE
		[5] = function (x)
			body = 0x315B;
			hand = 0x31D4;
			leg = 0x3256;
			feet = 0x32CF;
		end,

		-- TARU FEMALE
		[6] = function (x)
			body = 0x315B;
			hand = 0x31D4;
			leg = 0x3256;
			feet = 0x32CF;
		end,

		-- MITHRA
		[7] = function (x)
			body = 0x315C;
			hand = 0x31D5;
			leg = 0x3257;
			feet = 0x32D0;
		end,

		-- GALKA
		[8] = function (x)
			body = 0x315D;
			hand = 0x31D6;
			leg = 0x3258;
			feet = 0x32D1;
		end,

		default = function (x) end,
	}

	-- Add starting gear
	if not(player:hasItem(body)) then
		player:addItem(body);
		player:equipItem(body);
	end

	if not(player:hasItem(hand)) then
		player:addItem(hand);
		player:equipItem(hand);
	end

	if not(player:hasItem(leg)) then
		player:addItem(leg);
		player:equipItem(leg);
	end

	if not(player:hasItem(feet)) then
		player:addItem(feet);
		player:equipItem(feet);
	end

	-- ADD JOB SPECIFIC STARTGEAR
	switch(player:getMainJob()) : caseof
	{
		-- WARRIOR JOB
		[0x01]= function (x)
			if not(player:hasItem(0x4096)) then
				player:addItem(0x4096);
			end
		end,

		-- MONK JOB
		[0x02]= function (x)
			if not(player:hasItem(0x3380)) then
				player:addItem(0x3380);
			end
		end,

		-- WHITE MAGE
		[0x03]= function(x)
			if not(player:hasItem(0x42AC)) then
				player:addItem(0x42AC);
			end

			if not(player:hasItem(0x1200)) then
			player:addItem(0x1200);
			end
		end,

		-- BLACK MAGE
		[0x04] = function(x)

			if not(player:hasItem(0x42D0)) then
				player:addItem(0x42D0);
			end

			if not(player:hasItem(0x11FF)) then
				player:addItem(0x11FF);
			end
		end,

		-- RED MAGE
		[0x05]= function (x)
			if not(player:hasItem(0x4062)) then
				player:addItem(0x4062);
			end
			if not(player:hasItem(0x11FE)) then
				player:addItem(0x11FE);
			end
		end,

		-- THIEF
		[0x06]= function (x)
			if not(player:hasItem(0x4063)) then
				player:addItem(0x4063);
			end
		end,

		default = function (x) end,
	}

	-- ADD NATION SPECIFIC STARTGEAR
	switch (player:getNation()) : caseof
	{
		-- SANDY CITIZEN
		[0] = function (x)
			if ((race == 3) or (race == 4))
				then player:addItem(0x34B7);
			end;
			player:addKeyItem(MAP_OF_THE_SAN_DORIA_AREA);
		end,

		-- BASTOK CITIZEN
		[1] = function (x)
			if (((race == 1) or (race == 2) or (race == 8)))
				then player:addItem(0x34B9);
			end;
			player:addKeyItem(MAP_OF_THE_BASTOK_AREA);
		end,

		-- WINDY CITIZEN
		[2] = function(x)
			if (((race == 5) or (race == 6) or (race == 7)))
				then player:addItem(0x34B8);
			end;
			player:addKeyItem(MAP_OF_THE_WINDURST_AREA);
		end,

		default = function (x) end,
	}

   ----- settings.lua Perks -----
    if (ADVANCED_JOB_LEVEL == 0) then
       for i = 6,22 do
          player:unlockJob(i);
       end
    end

    if (SUBJOB_QUEST_LEVEL == 0) then
       player:unlockJob(0);
    end

    if (ALL_MAPS == 1) then
       for i=385,447 do
          player:addKeyItem(i);
       end
       for i=1856,1917 do
          player:addKeyItem(i);
       end
       for i=2302,2305 do
          player:addKeyItem(i);
       end
       for i=2307,2309 do
          player:addKeyItem(i);
       end
    end

    if (INITIAL_LEVEL_CAP ~= 50) then
       player:levelCap(INITIAL_LEVEL_CAP)
    end

    if (START_INVENTORY > 30) then
       player:changeContainerSize(0,(START_INVENTORY - 30))
       player:changeContainerSize(5,(START_INVENTORY - 30))
    end

    if (UNLOCK_OUTPOST_WARPS >= 1) then
       player:addNationTeleport(0,2097120);
       player:addNationTeleport(1,2097120);
       player:addNationTeleport(2,2097120);
       if (UNLOCK_OUTPOST_WARPS == 2) then -- Tu'Lia and Tavnazia
          player:addNationTeleport(0,10485760);
          player:addNationTeleport(1,10485760);
          player:addNationTeleport(2,10485760);
       end
    end
    ----- End settings.lua Perks -----

	-- SET START GIL
    --[[For some intermittent reason m_ZoneList ends up empty on characters, which is
    possibly also why they lose key items.  When that happens, CharCreate will be run and
    they end up losing their gil to the code below.  Added a conditional to hopefully
    prevent that until the bug is fixed.  Used the if instead of addGil to prevent abuse
    on servers with very high values of START_GIL, I guess.]]
    if (player:getGil() < START_GIL) then
       player:setGil(START_GIL);
    end

	-- ADD ADVENTURER COUPON
	player:addItem(0x218);

	--SET TITLE
	player:addTitle(NEW_ADVENTURER);

	-- Needs Moghouse Intro
	player:setVar("MoghouseExplication",1);
    	player:capAllSkills();
end;

function onPlayerLevelUp(player)
player:capAllSkills();
end

function onPlayerLevelDown(player)
player:capAllSkills();
end

babblebab
Posts: 40
Joined: Sat Dec 01, 2012 9:50 pm

Re: Custom PrintToPlayer/PrintToServer Stuff

Post by babblebab » Tue Jan 05, 2016 1:23 am

Is it possible to specify the color of the text printed at all?

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Custom PrintToPlayer/PrintToServer Stuff

Post by tagban » Tue Jan 05, 2016 8:26 am

babblebab wrote:Is it possible to specify the color of the text printed at all?
That's what the 0x1C is at the end of the print to server line. I laid out the different codes in the first page of this.

KOSMOS
Posts: 67
Joined: Thu Jan 29, 2015 10:36 pm

Re: Custom PrintToPlayer/PrintToServer Stuff

Post by KOSMOS » Sun Feb 28, 2016 9:37 pm

These is sweet thank you Tagban.

I have this working it is quite awesome, though I was wondering if anyone has used it for leaving the game?

I tried to add it to the leavegame.lua and it threw an error from luautils. Which makes since the effect lua seem to work a great deal different than the normal lua globals like player.lua.

Just figured it be a kool option. I know there was many times in retail people would be talking to someone and not noticed they got booted or crashed.

If not I will keep working at it and see if I can find a solution.

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Custom PrintToPlayer/PrintToServer Stuff

Post by tagban » Sun Feb 28, 2016 10:06 pm

I was playing around with that to, but I think it would require modifying the code code further and I've been hesitant to do that for fear of breaking something that dsp changes later.

Post Reply