• 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 Proplem with my script

Seumion

★ Spell Maker & Mapper ★
Joined
Feb 24, 2015
Messages
172
Reaction score
2
hello otland i have proplem with my script that if player get storage 2000 he will get auto message always when he log in i tried to open my normal account its works perfect but with my admin account it won't work

USING TFS 0.4 DEv
 
but when i use book with my admin account it set storage perfect to it but 1 time only like when he login he get message only one time but with my normal account it's get when it log in it always get message
 
when i use book that get me an storage to get message when log in ,when i use it with my normal character it work's perfect and always get message when log in but,when i use that book with my gm account it give me storage but 1 time only that mean it will get me message 1 time only
 
I suggest posting the script so we all have something to look at.
this is my login script VV
PHP:
if (getCreatureStorage(cid, storageItem) == 1 and getPlayerBlessing(cid, 1) == false) then
     doPlayerAddItem(cid, idAol, 1)
     for i = 1,5 do
       doPlayerAddBlessing(cid, i)
     end
     doCreatureSay(cid,'Automaticly blessed and amulet of loss equiped!',TALKTYPE_ORANGE_1)
     doSendMagicEffect(getThingPosition(cid), CONST_ME_HOLYAREA)

   end


and this my action script VV
PHP:
function onUse(cid, item, fromPos, item2, toPos)
    if (getCreatureStorage(cid, storageitem) < 0) then
     doCreatureSetStorage(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

@Xikini
 
this is why we use getCreatureStorage instead of getPlayerStorageValue

Do please explain how a compat function would work better then the actual function?
Taken from smth-compat.lua
Code:
doPlayerSetStorageValue = doCreatureSetStorage
setPlayerStorageValue = doPlayerSetStorageValue
getPlayerStorageValue = getCreatureStorage

@Topic, print out the things you are expecting.
Code:
print(getPlayerStorageValue(cid, storageItem))

Might be that the player does not have the correct storage or already has that blessing.
If you get the correct values post your full login.lua file.
 
Do please explain how a compat function would work better then the actual function?
Taken from smth-compat.lua
Code:
doPlayerSetStorageValue = doCreatureSetStorage
setPlayerStorageValue = doPlayerSetStorageValue
getPlayerStorageValue = getCreatureStorage

@Topic, print out the things you are expecting.
Code:
print(getPlayerStorageValue(cid, storageItem))

Might be that the player does not have the correct storage or already has that blessing.
If you get the correct values post your full login.lua file.
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
  
   function onLogin(cid)
    if getPlayerStorageValue(cid, 57928) == 1 then
    doCreatureSay(cid, "Automaticly", TALKTYPE_MONSTER_SAY)
    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, "onPrepareDeath")
   registerCreatureEvent(cid, "ZombieEvent")
   registerCreatureEvent(cid, "AutoBuyer")
   registerCreatureEvent(cid, "skullsystem")
   registerCreatureEvent(cid, "skulllvls")
   registerCreatureEvent(cid, "BlockEffect")
   registerCreatureEvent(cid, "GuildMotd")
   registerCreatureEvent(cid, "Idle")
   if(config.useFragHandler) then
     registerCreatureEvent(cid, "SkullCheck")
   end
   registerCreatureEvent(cid, "ReportBug")
   registerCreatureEvent(cid, "AdvanceSave")

   if (getCreatureStorage(cid, storageItem) == 1 and getPlayerBlessing(cid, 1) == false) then
     doPlayerAddItem(cid, idAol, 1)
     for i = 1,5 do
       doPlayerAddBlessing(cid, i)
     end
     doCreatureSay(cid,'Automaticly blessed and amulet of loss equiped!',TALKTYPE_ORANGE_1)
     doSendMagicEffect(getThingPosition(cid), CONST_ME_HOLYAREA)

   end
   return true
end
 
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

    if getPlayerStorageValue(cid, 57928) == 1 then
        doCreatureSay(cid, "Automaticly", TALKTYPE_MONSTER_SAY)
    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, "onPrepareDeath")
    registerCreatureEvent(cid, "ZombieEvent")
    registerCreatureEvent(cid, "AutoBuyer")
    registerCreatureEvent(cid, "skullsystem")
    registerCreatureEvent(cid, "skulllvls")
    registerCreatureEvent(cid, "BlockEffect")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
   
    if(getBooleanFromString(getConfigValue('useFragHandler'))) then
        registerCreatureEvent(cid, "SkullCheck")
    end
   
    print(getCreatureStorage(cid, storageItem), getPlayerBlessing(cid, 1))
    if (getCreatureStorage(cid, storageItem) == 1 and getPlayerBlessing(cid, 1) == false) then
        doPlayerAddItem(cid, idAol, 1)
        doCreatureSay(cid,'Automaticly blessed and amulet of loss equiped!',TALKTYPE_ORANGE_1)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_HOLYAREA)
        for i = 1,5 do
            doPlayerAddBlessing(cid, i)
        end
    end
    return true
end

Please try to keep your code clean, use that and take a screen of what it prints out.
 
this is my login script VV
PHP:
if (getCreatureStorage(cid, storageItem) == 1 and getPlayerBlessing(cid, 1) == false) then
     doPlayerAddItem(cid, idAol, 1)
     for i = 1,5 do
       doPlayerAddBlessing(cid, i)
     end
     doCreatureSay(cid,'Automaticly blessed and amulet of loss equiped!',TALKTYPE_ORANGE_1)
     doSendMagicEffect(getThingPosition(cid), CONST_ME_HOLYAREA)

   end


and this my action script VV
PHP:
function onUse(cid, item, fromPos, item2, toPos)
    if (getCreatureStorage(cid, storageitem) < 0) then
     doCreatureSetStorage(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

@Xikini
storageitem what is this ???
did u define it ?
 
Could be added globaly to make it posible to use it in other scripts.
ORTS uses the same type of storage id fetching.
 
when i open my gm account i got debug
and error im my forgotten
[Error - CreatureScript Interface ]
data/creaturescripts/scripts/login.lua:onLogin
 
when i open my gm account i got debug
and error im my forgotten
[Error - CreatureScript Interface ]
data/creaturescripts/scripts/login.lua:eek:nLogin

test this if not work send me storageItem id

Code:
[code=lua]
if (getCreatureStorage(cid, storageItem) == 1 and getPlayerBlessing(cid, 1) == false) then
doPlayerAddItem(cid,2173, 1)
for i = 1,5 dodoPlayerAddBlessing(cid, i)end
doCreatureSay(cid,'Automaticly blessed and amulet of loss equiped!',TALKTYPE_ORANGE_1)doSendMagicEffect(getThingPosition(cid), CONST_ME_HOLYAREA)
end
[/CODE]
 
Back
Top