• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Welcome back, "Player Name"!

artofwork

Well-Known Member
Joined
Dec 3, 2008
Messages
420
Reaction score
61
When the player logs in they will be greeted by a little welcome message.

I forget where i got this from, but I'd like to share it.
Place this in
data\creaturescripts\scripts\welcome.lua
Code:
function onLogin(cid)
doPlayerSendTextMessage(cid,22,"Welcome back "..getPlayerName(cid).."!")
		return TRUE
	end

Place this in
data\creaturescripts\creaturescripts.xml
Code:
<event type="login" name="FirstItems" script="welcome.lua"/>
 
This sucks!
If is your first login, it will say: "Welcome, BACK" ?
Lol, add a storage value :), is easy :D
 
Code:
function onLogin(cid)
if getPlayerStorageValue(cid, 13331) == 1 then
doPlayerSendTextMessage(cid, 22, "Welcome back "..getPlayerName(cid).."!")
else
doPlayerSendTextMessage(cid, 22, "Welcome "..getPlayerName(cid)..", its your first visit!")
setPlayerStorageValue(cid, 13331, 1)
return TRUE
end
end

:)
 
My acc. maker create column 'created' in 'players' table. You can use too 'lastlogin'/'lastlogout' ('players') to load lastlogin/logout time and send.. "back" (3+ days?).
I send msg when player login first time or get rooked (-10 lvl).
 
Here is my version onLogin.

PHP:
function onLogin(cid)

 local serverName = getConfigInfo('serverName')
 local storage = getPlayerStorageValue(cid, 1000)
 
 if storage == -1 then
 doPlayerSendTextMessage(cid, 22, "Hello "..getPlayerName(cid).." this is your first visit to "..serverName..". Enjoy your time on "..serverName..".")
 setPlayerStorageValue(cid, 1000, 1)
 else
 doPlayerSendTextMessage(cid, 22, "Welcome back "..getPlayerName(cid).."!")
 return TRUE
end
 
Hehe , is this your first LUA Script? In that case, it is ok.

My first one was a script that gave you 100 gold when you said "!gold" :D
 
Here is my version onLogin.

PHP:
function onLogin(cid)

 local serverName = getConfigInfo('serverName')
 local storage = getPlayerStorageValue(cid, 1000)
 
 if storage == -1 then
 doPlayerSendTextMessage(cid, 22, "Hello "..getPlayerName(cid).." this is your first visit to "..serverName..". Enjoy your time on "..serverName..".")
 setPlayerStorageValue(cid, 1000, 1)
 else
 doPlayerSendTextMessage(cid, 22, "Welcome back "..getPlayerName(cid).."!")
 return TRUE
end

Zonet it is wrong.you add "end" script's end.

Here script:
Code:
function onLogin(cid)

 local serverName = getConfigInfo('serverName')
 local storage = getPlayerStorageValue(cid, 1000)
 
 if storage == -1 then
 doPlayerSendTextMessage(cid, 22, "Hello "..getPlayerName(cid).." this is your first visit to "..serverName..". Enjoy your time on "..serverName..".")
 setPlayerStorageValue(cid, 1000, 1)
 else
 doPlayerSendTextMessage(cid, 22, "Welcome back "..getPlayerName(cid).."!")
 return TRUE
end  
end
 
Oh ye, i forget one more end, thank you:p
PHP:
function onLogin(cid)

 local serverName = getConfigInfo('serverName')
 local storage = getPlayerStorageValue(cid, 1000)
 
 if storage == -1 then
 doPlayerSendTextMessage(cid, 22, "Hello "..getPlayerName(cid).." this is your first visit to "..serverName..". Enjoy your time on "..serverName..".")
 setPlayerStorageValue(cid, 1000, 1)
 else
 doPlayerSendTextMessage(cid, 22, "Welcome back "..getPlayerName(cid).."!")
 end
 return TRUE
end

This also checks the servername automatic
PHP:
 local serverName = getConfigInfo('serverName')
 
Oh ye, i forget one more end, thank you:p
PHP:
function onLogin(cid)

 local serverName = getConfigInfo('serverName')
 local storage = getPlayerStorageValue(cid, 1000)
 
 if storage == -1 then
 doPlayerSendTextMessage(cid, 22, "Hello "..getPlayerName(cid).." this is your first visit to "..serverName..". Enjoy your time on "..serverName..".")
 setPlayerStorageValue(cid, 1000, 1)
 else
 doPlayerSendTextMessage(cid, 22, "Welcome back "..getPlayerName(cid).."!")
 end
 return TRUE
end

This also checks the servername automatic
PHP:
 local serverName = getConfigInfo('serverName')

local variables should be declared before function so script will by the loaded once ;]
 
local variables should be declared before function so script will by the server once ;]

You cant put local storage = getPlayerStorageValue(cid, int) outside of the function, because 'cid' will return nil ;]
 
umm ye ;D You are right, I did not actually saw it's onLogin lol, so it has to be called everytime someone will login :D

That "rule" about certain variables not to be placed inside of function is not about being "local". It's about if the value won't be changed by the script :)
 
Here my idea...
"Welcome back Aneroth! Your last visit was on Fri May 07 21:50:57 2010."

I modify the loing.lua... ;)
PHP:
local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
local player, str = getPlayerName(cid), config.loingMessage
if(lastLogin > 0) then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	str = "Welcome back "..(player).."! Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
else
	str = str .. " Please choose your outfit."
	doPlayerSendOutfitWindow(cid)
end

And when I enter the game says me this: :(
Code:
22:39 
22:39 Welcome back Aneroth! Your last visit was on Fri May 07 21:50:57 2010.

How remove the time coming first? :confused:
 
try
Code:
function onLogin(cid)
	local lastLogin = getPlayerLastLoginSaved(cid)
	local player = getPlayerName(cid)
	if(lastLogin > 0) then    
		local str = "Welcome back "..player.."! Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
	else
		local str = "Welcome on <servname>"..player.."! Please choose your outfit."
		doPlayerSendOutfitWindow(cid)
	end  
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	return TRUE
end
 
Back
Top