• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua If item x do send effect every login

Seumion

★ Spell Maker & Mapper ★
Joined
Feb 24, 2015
Messages
172
Reaction score
2
hello otland support and members how can i make script if i have item x do send effect every login
USING tfs 4.0 dev
 
Code:
if(getPlayerItemCount(itemid) >= 1) then
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end

Not sure if the function names are correct tho :p
 
/PHP]
bro this is my login can please add it
PHP:
local config = {
   loginMessage = getConfigValue('loginMessage'),
   useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}
function onLogin(cid)
   doChangeSpeed(cid, 750)
   doCreatureSay(cid, "Welcome!", 19)
   local loss = getConfigValue('deathLostPercent')
   if(loss ~= nil) then
   doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
   end
return true
end

   local accountManager = getPlayerAccountManager(cid)
   if(accountManager == MANAGER_NONE) then
     local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
     if(lastLogin > 0) then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
       str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
     else
       str = str .. " Please choose your outfit."
       doPlayerSendOutfitWindow(cid)
     end
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
   elseif(accountManager == MANAGER_NAMELOCK) then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
   elseif(accountManager == MANAGER_ACCOUNT) then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
   end
   if(not isPlayerGhost(cid)) then
     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
   end
   registerCreatureEvent(cid, "Mail")
   registerCreatureEvent(cid, "Forever Amulet")
   registerCreatureEvent(cid, "onPrepareDeath")
   registerCreatureEvent(cid, "ZombieAttack")
   registerCreatureEvent(cid, "removeghostspell")
   registerCreatureEvent(cid, "removeghostcombat")
   registerCreatureEvent(cid, "AutoBuyer")
   registerCreatureEvent(cid, "skullsystem")
   registerCreatureEvent(cid, "BlockEffect")
   registerCreatureEvent(cid, "GuildMotd")
   registerCreatureEvent(cid, "Idle")
   if(config.useFragHandler) then
     registerCreatureEvent(cid, "SkullCheck")
   end
   registerCreatureEvent(cid, "ReportBug")
   registerCreatureEvent(cid, "AdvanceSave")

   return true
end
 
Last edited:
Wtf haven't I cleaned that script before? Why do you have 2 onLogin functions in it?
Clean the script up and ill help you. If you don't know how to do it then serach through your latest threads for my post.
 
Code:
local config = {
   loginMessage = getConfigValue('loginMessage'),
   useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}
function onLogin(cid)
    doChangeSpeed(cid, 750)
    doCreatureSay(cid, "Welcome!", 19)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end
   
    local item = 1234 -- Change item
    if(getPlayerItemCount(item) >= 1) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
    local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end
    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end
    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "Forever Amulet")
    registerCreatureEvent(cid, "onPrepareDeath")
    registerCreatureEvent(cid, "ZombieAttack")
    registerCreatureEvent(cid, "removeghostspell")
    registerCreatureEvent(cid, "removeghostcombat")
    registerCreatureEvent(cid, "AutoBuyer")
    registerCreatureEvent(cid, "skullsystem")
    registerCreatureEvent(cid, "BlockEffect")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")

    return true
end

Stop messing with the onLogin if you have no idea what you're doing. You ended your script before anything even got registered.
 
Code:
function onLogin(cid)
    doChangeSpeed(cid, 750)
    doCreatureSay(cid, "Welcome!", 19)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end
  
    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), getConfigValue('loginMessage')
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end
  
    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end
  
    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "Forever Amulet")
    registerCreatureEvent(cid, "onPrepareDeath")
    registerCreatureEvent(cid, "ZombieAttack")
    registerCreatureEvent(cid, "removeghostspell")
    registerCreatureEvent(cid, "removeghostcombat")
    registerCreatureEvent(cid, "AutoBuyer")
    registerCreatureEvent(cid, "skullsystem")
    registerCreatureEvent(cid, "BlockEffect")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    if(getBooleanFromString(getConfigValue('useFragHandler'))) then
        registerCreatureEvent(cid, "SkullCheck")
    end
  
    if(getPlayerItemCount(itemid) >= 1) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    end
    return true
end

A tip is to keep your code clean, you will waste ALOT of time just trying to find the error.
Just ask @yogiikke who spent 5h last night trying to get my help, once he had actually tabbed the script I helped him :p
* Was pretty funny from my POV * :p
 
@WibbenZ shouldnt "itemid" declared somewhere? :p
local itemid = 2432
Code:
    if(getPlayerItemCount(itemid) >= 1) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    end
and maybe replace this function for it?
Code:
  local specialItem = 2432
   if getPlayerItemCount(cid, specialItem) >= 1 then
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   elseif(not isPlayerGhost(cid)) then
     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
   end
else it will show 2 login effects?
 
Last edited:
@WibbenZ shouldnt "itemid" declared somewhere? :p
local itemid = 2432

and maybe replace this function for it?
Code:
  local specialItem = 2432
   if getPlayerItemCount(cid, specialItem) >= 1 then
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   elseif(not isPlayerGhost(cid)) then
     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
   end
else it will show 2 login effects?

Miseed the itemid :p was in a hurry.
About the effects, well I guess but still you would have to be a GM+ and have the item.
 
Thanks guys alot work's perfect
but i have proplem in other script i made an script if player use item he will get storage that storage in login make everyone have it able to say work "automatic blessings" when he login it work's perfect but only with normal characters with my admin account it said 1 time and didn't said it more
 
Miseed the itemid :p was in a hurry.
About the effects, well I guess but still you would have to be a GM+ and have the item.

Why GM + item?^^
Code:
elseif(not isPlayerGhost(cid)) then
That part of script is done because it shouldnt show login effect if gm is logging in with ghost mode :)


Thanks guys alot work's perfect
but i have proplem in other script i made an script if player use item he will get storage that storage in login make everyone have it able to say work "automatic blessings" when he login it work's perfect but only with normal characters with my admin account it said 1 time and didn't said it more
show us the script that shows the login message with automatic blessings..
 
Code:
   if (getPlayerStorageValue(cid, storageItem) == 1 and getPlayerBlessing(cid, 1) == false) then
  doPlayerAddItem(cid, 2173, 1)
  for i = 1,5 do
  doPlayerAddBlessing(cid, i)
  end
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You received free AOL and BLESS.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
@Danger II here you are
PHP:
function onUse(cid, item, fromPos, item2, toPos)
   if (getPlayerStorageValue(cid, storageItem) < 1) then
     doPlayerSetStorageValue(cid, storageItem, 1)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations, now you have AOL and BLESS forever.")
     doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
     doRemoveItem(item.uid)
   else
     doPlayerSendCancel(cid, "You already have your forever AOL/BLESS active.")
   end


   return true
end
 
Code:
   if (getPlayerStorageValue(cid, storageItem) == 1 and getPlayerBlessing(cid, 1) == false) then
  doPlayerAddItem(cid, 2173, 1)
  for i = 1,5 do
  doPlayerAddBlessing(cid, i)
  end
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You received free AOL and BLESS.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
@Danger II here you are
PHP:
function onUse(cid, item, fromPos, item2, toPos)
   if (getPlayerStorageValue(cid, storageItem) < 1) then
     doPlayerSetStorageValue(cid, storageItem, 1)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations, now you have AOL and BLESS forever.")
     doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
     doRemoveItem(item.uid)
   else
     doPlayerSendCancel(cid, "You already have your forever AOL/BLESS active.")
   end


   return true
end


storageItem is not declared
Code:
local storageItem = 11741
function onUse(cid, item, fromPos, item2, toPos)
  if (getPlayerStorageValue(cid, storageItem) < 1) then
  doPlayerSetStorageValue(cid, storageItem, 1)
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations, now you have AOL and BLESS forever.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
  doRemoveItem(item.uid)
  else
  doPlayerSendCancel(cid, "You already have your forever AOL/BLESS active.")
  end
  return true
end

If you want players get a message if they login use
creaturescript/login.lua
Code:
local storageItem = 11741
if (getPlayerStorageValue(cid, storageItem) > 0) and (getPlayerBlessing(cid, 1) == false) then
   doPlayerAddItem(cid, 2173, 1)
for i = 1,5 do
   doPlayerAddBlessing(cid, i)
end
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You received free AOL and BLESS.")
   doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
 
Last edited:
work's perfect but this send message when player dei i want it when player login if he login always get message explain"every login
understood me?
 
work's perfect but this send message when player dei i want it when player login if he login always get message explain"every login
understood me?

If you want player gets a message everytime he login use this one

Code:
local storageItem = 11741
if (getPlayerStorageValue(cid, storageItem) > 0) and (getPlayerBlessing(cid, 1) == false) then
  doPlayerAddItem(cid, 2173, 1)
for i = 1,5 do
  doPlayerAddBlessing(cid, i)
end
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You received free AOL and BLESS.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
else
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your character have all blessings.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
 
Back
Top