• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Welcome message

Neubbed

New Member
Joined
Jan 15, 2013
Messages
24
Reaction score
0
I tried scripting this welcome message for people/new characters for first time logging in, it will tell them how to get off the starter island/information about the server...

But it won't work??

Code:
local MSG_TYPE = MESSAGE_STATUS_CONSOLE_RED
local storage = new
local name = getCreatureName(cid)

function onLogin (cid)
	if getPlayerStorageValue (cid, new) <= 0 then
		if getPlayerLevel (cid) <65 then
	doPlayerSendTextMessage (cid, MSG_TYPE, "Welcome to OT server " . . name . . " for the first time! ")
	setPlayerStorageValue (cid, new, 1)
else
doPlayerSendTextMessage (cid, MSG_TYPE, "Welcome back!")

end
return TRUE
end

I also get this message through the server start thingy...

Code:
[20/01/2013 17:03:11] Warning: [Event::checkScript] Can not load script. /scripts/welcome.lua
[20/01/2013 17:03:11] data/creaturescripts/scripts/welcome.lua:8: ')' expected near '.'

P.S, new to all this, so please understand if this is a noob mistake
 
Enjoy!
LUA:
function onLogin (cid)
	local MSG_TYPE = MESSAGE_STATUS_CONSOLE_RED
	local storage = 9798
	local name = getCreatureName(cid)

	if getPlayerStorageValue (cid, storage) == 0 and getPlayerLevel (cid) < 65 then
		doPlayerSendTextMessage(cid, MSG_TYPE, "Welcome to OT server "..name.." for the first time! ")
		setPlayerStorageValue (cid, storage, 1)
	else
		doPlayerSendTextMessage (cid, MSG_TYPE, "Welcome back!")
		end
	return TRUE
end
 
Last edited:
I made a new character but it didn't work, it just sends me 'Welcome back' in the Server Log...

I get this message through the console thing -
Code:
[20/01/2013 17:31:57] Lua Script Error: [CreatureScript Interface] 
[20/01/2013 17:31:57] data/creaturescripts/scripts/firstitems.lua:onLogin
[20/01/2013 17:31:57] LuaScriptInterface::luaDoPlayerSendTextMessage(). Player not found
[20/01/2013 17:31:57] stack traceback:
[20/01/2013 17:31:57] 	[C]: in function 'doPlayerSendTextMessage'
[20/01/2013 17:31:57] 	data/creaturescripts/scripts/firstitems.lua:7: in function <data/creaturescripts/scripts/firstitems.lua:3>

I'm not sure why its bringing the other file forward now :S

Also I wanted the message to come up in the middle of the screen? Is that possible?
 
Oh, I know why its bringing up firstitems.lua now, its cos I tried to add this welcome message into it lol... I deleted it and it doesnt get that error now.

But still, it still says Welcome back?

And I don't want in server log, I want it to pop up on screen?
 
At login.lua under function onLogin(cid) paste this code:
LUA:
	if getPlayerStorageValue(cid, 9798) == 0 and getPlayerLevel (cid) < 65 then
		doPlayerPopupFYI(cid, "Welcome to OT server "..getCreatureName(cid).." for the first time! ")
		setPlayerStorageValue (cid, 9798, 1)
	else
		doPlayerPopupFYI(cid, "Welcome Back")
	end
 
Ah... not that sort of popup... more like text in the middle of the screen? Like when a GM broadcasts a message to everyone, except its no GM name, just the text will be in the same spot?

It says... "Welcome to blah blah blah"
"You must get to level 65 before you can leave this island"
"There are also a few quests to do on this island"

And I did it so I changed for the storage

Code:
	if getPlayerStorageValue (cid, storage) <= 0 and getPlayerLevel (cid) < 65 then

And it works now for a new player...
 
Code:
message_first = 18
message_status_console_red = message_first
message_event_orange = 19
message_status_console_orange = 20
message_status_warning = 21
message_event_advance = 22
message_event_default = 23
message_status_default = 24
message_info_descr = 25
message_status_small = 26
message_status_console_blue = 27
message_last = message_status_console_blue
 
So... would I use number 19? I guess?

So like this?

Code:
function onLogin (cid)
	local MSG_TYPE = 19
	local storage = 9798
	local name = getCreatureName(cid)
 
	if getPlayerStorageValue (cid, storage) <= 0 and getPlayerLevel (cid) < 65 then
		doPlayerSendTextMessage(cid, MSG_TYPE, "Welcome to OT server "..name.." for the first time! ")
		setPlayerStorageValue (cid, storage, 1)
	else
		doPlayerSendTextMessage (cid, MSG_TYPE, "Welcome back!")
		end
	return TRUE
end



--edit-
NVM I DIDI T!

local MSG_TYPE = MESSAGE_EVENT_ADVANCE

I changed it to that instead and it comes up on screen! Not checked with a new character but it should work... fingers crossed.

Thanks alot for help! Couldn't do it without you...
But how do I make it so multiple messages come through? Do I make new line of doPlayerSendTextMessage?
 
My global.lua is different to yours:

Code:
MESSAGE_STATUS_CONSOLE_BLUE = 4
MESSAGE_STATUS_CONSOLE_RED = 12
MESSAGE_STATUS_DEFAULT = 16
MESSAGE_STATUS_WARNING = 17
MESSAGE_EVENT_ADVANCE = 18
MESSAGE_STATUS_SMALL = 19
MESSAGE_INFO_DESCR = 20
MESSAGE_DAMAGE_DEALT = 21
MESSAGE_DAMAGE_RECEIVED = 22
MESSAGE_HEALED = 23
MESSAGE_EXPERIENCE = 24
MESSAGE_DAMAGE_OTHERS = 25
MESSAGE_HEALED_OTHERS = 26
MESSAGE_EXPERIENCE_OTHERS = 27
MESSAGE_EVENT_DEFAULT = 28
MESSAGE_EVENT_ORANGE = 34
MESSAGE_STATUS_CONSOLE_ORANGE = 35

And I got multiple messages, sent multiple lines in, thank you :)
 
Back
Top