• 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!

Xikini's Free Scripting Service. [0.3.7 & (0.3.6/0.4)]

Status
Not open for further replies.

Xikini

I whore myself out for likes
Senator
Premium User
Joined
Nov 17, 2010
Messages
6,800
Solutions
582
Reaction score
5,363
Doing quick (30 min or less) scripts for [0.3.7 & (0.3.6/0.4)]
I am not here to fix your broken scripts, although I will give advice if requested.
I am here for script requests of scripts not already available on the forum.
If you require support for your scripting issues please make a thread in the support section.

For clarity's sake,
I will script actionscripts, creaturescripts, globalevents, talkactions, movements, npcs for you.
I will not script spells, weapons, raids or monster scripts.
Additionally, source editing, websites and database queries are a no go as well.

Code:
How to make shorter links to posts.
https://otland.net/threads/234306/page-14#post-2330703
 
Last edited:
Storage values can be thought of as a number representation of a variable, they are used to reference a value.
Code:
local mystorage = 45001
setPlayerStorageValue(cid, mystorage, 1)
Is the same as
Code:
setPlayerStorageValue(cid, 45001, 1)
The value in mystorage is passed to setPlayerStorageValue and stored in the database to reference the value assigned to it.

Using an 8.6 server, if we look at the sql code you can see how the information is stored in a table
Code:
CREATE TABLE `player_storage`
(
    `player_id` INT NOT NULL DEFAULT 0,
    `key` INT UNSIGNED NOT NULL DEFAULT 0,
    `value` VARCHAR(255) NOT NULL DEFAULT '0',
    KEY (`player_id`), UNIQUE (`player_id`, `key`),
    FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE = InnoDB;
player_id is the player's cid, key is a number representing the number to reference, value is character value to store
Code:
setPlayerStorageValue(cid, storage, value)

The same thing can be said for global storage, except that it isn't assigned to any particular player
Code:
CREATE TABLE `global_storage`
(
    `key` INT UNSIGNED NOT NULL,
    `world_id` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
    `value` VARCHAR(255) NOT NULL DEFAULT '0',
    UNIQUE  (`key`, `world_id`)
) ENGINE = InnoDB;
Code:
setGlobalStorageValue(key, newValue)

When you call
Code:
getPlayerStorageValue(cid, mystorage)
-- or
getGlobalStorageValue(key)
You are retrieving the value stored in the database that is associated with this number.

I hope that helps :)
Wowa, thanks for the tutorial! It becomes a bit more clear now. It's quite a hard thing imo xD

Thanks! ;)
 
Hey, Xik

I'm trying to make a script but I think I need add storageValue's in it and I don't really understand how to use them/what they do.

Do you know a good and understandable tutorial about StorageValue's?

Regards,
Code:
getPlayerStorageValue(uid, key)
doPlayerSetStorageValue(uid, key, newValue)

Above is some functions associated with storage values.
There is usually a compat like this, which just make it a little less confusing when writing it out. (at least I find it easier)

Code:
setPlayerStorageValue = doPlayerSetStorageValue

A very simple script to show you how to use both functions.
Code:
function onStepIn(cid, item, position, fromPosition)

     -- Get player storage value and compare it to a number.
     if getPlayerStorageValue(uid, key) < n then

         -- Then do something if it is true!
         doPlayerSetStorageValue(uid, key, newValue)
    
     end
     return true
end

-- Now with a real storage value
function onStepIn(cid, item, position, fromPosition)

     --[[
         All storage values start at -1
         Many people use 0 to start a quest, and use 1 as the finished state.
         In many cases like a one-time chest for example, you can skip straight to the finished state of 1, by-passing 0 altogether.
         Using this as your base knowledge let's continue
     ]]--

     -- If cid (players) storage value is "less then" 1 then
     if getPlayerStorageValue(cid, 45001) < 1 then

         -- Set the players storage value to 1.
         doPlayerSetStorageValue(cid, 45001, 1)
    
         -- Now you could just as easily change the number to 3000, or 5700, or 9999.
         -- There is no reason to do so, but you can effectively jump around, or even go backward in numbers if you need too.
    
     end
     return true
end

--[[
   Now that you know the bare minimum, try to create a action script, which gives you a brown backpack, only once.
]]--
Once you are done creating and testing your script, check inside the spoiler to see how I did it.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, 45001) < 1 then
         doPlayerAddItem(cid, 1988, 1)
         doPlayerSetStorageValue(cid, 45001, 1)
     end
     return true
end

It's really that easy.

Now that you know the basics, the rest is simply imagination.

If you want to get a player to use 4 pillars before opening a chest and getting that backpack from before, you could do it like this.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, 45001) < 4 then
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
         doPlayerSendCancel(cid, "You must touch the 4 pillars surrounding this room before obtaining your reward.")
         if getPlayerStorageValue(cid, 45001) < 1 then
             doPlayerSetStorageValue(cid, 45001, 0)
         end
     elseif getPlayerStorageValue(cid, 45001) == 4 then
         doPlayerAddItem(cid, 1988, 1)
         doPlayerSetStorageValue(cid, 45001, 5)
     end
     return true
end
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, 45001) >= 0 and getPlayerStorageValue(cid, 45001) < 4 then
         doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
         doPlayerSetStorageValue(cid, 45001, getPlayerStorageValue(cid, 45001) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have touched ".. getPlayerStorageValue(cid, 45001) .."/4 pillars.")
     end
     return true
end
If you want a player to start a quest at one npc and end at another npc, the inside of an npc could look like this. (very basic of course..)
Code:
if msgcontains(msg, "secrets") and (getPlayerStorageValue(cid, 45070) < 0) then
     selfSay("Congratulations. Secret keyword obtained! Go tell NPC 2!", cid)
     setPlayerStorageValue(cid, 45070, 0)
end
Code:
if msgcontains(msg, "secret keyword") and (getPlayerStorageValue(cid, 45070) == 0) then
   selfSay("Wow you know the secret keyword! Fantastic! Have a backpack.", cid)
   doPlayerAddItem(cid, 1988, 1)
   setPlayerStorageValue(cid, 45070, 1)
end
Now something we didn't cover earlier is this
Code:
getGlobalStorageValue(valueid)
setGlobalStorageValue(key, newValue)
This is the exact same as a storage value for players, but it affects everyone who comes in contact with it.
Whether you use it in a globalevent, or in a movement script, doesn't matter, but you use it exactly the same as above.
For example.. you could make a couch fart when someone walks over it, with a small delay for everyone.

Code:
local storage = 45001
local seconds = 5
function onStepIn(cid, item, position, fromPosition)
     time = os.time()
     if getGlobalStorageValue(storage)+seconds < time then
         setGlobalStorageValue(storage, os.time())
         doCreatureSay(cid, "Pffrrt!", TALKTYPE_ORANGE_1)
     end
     return true
end
Not very useful, but hey you can do it.
You can obviously use it in more fantastic and fun ways, but it's just an example.

When it comes to storage values, it's simply limited by your imagination on how you plan to use it.

Hope it helps.

Cheers,

Xikini
 
Last edited:
Storage values can be thought of as a number representation of a variable, they are used to reference a value.
Code:
local mystorage = 45001
setPlayerStorageValue(cid, mystorage, 1)
Is the same as
Code:
setPlayerStorageValue(cid, 45001, 1)
The value in mystorage is passed to setPlayerStorageValue and stored in the database to reference the value assigned to it.

Using an 8.6 server, if we look at the sql code you can see how the information is stored in a table
Code:
CREATE TABLE `player_storage`
(
    `player_id` INT NOT NULL DEFAULT 0,
    `key` INT UNSIGNED NOT NULL DEFAULT 0,
    `value` VARCHAR(255) NOT NULL DEFAULT '0',
    KEY (`player_id`), UNIQUE (`player_id`, `key`),
    FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE = InnoDB;
player_id is the player's cid, key is a number representing the number to reference, value is character value to store
Code:
setPlayerStorageValue(cid, storage, value)

The same thing can be said for global storage, except that it isn't assigned to any particular player
Code:
CREATE TABLE `global_storage`
(
    `key` INT UNSIGNED NOT NULL,
    `world_id` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
    `value` VARCHAR(255) NOT NULL DEFAULT '0',
    UNIQUE  (`key`, `world_id`)
) ENGINE = InnoDB;
Code:
setGlobalStorageValue(key, newValue)

When you call
Code:
getPlayerStorageValue(cid, mystorage)
-- or
getGlobalStorageValue(key)
You are retrieving the value stored in the database that is associated with this number.

I hope that helps :)
haha. :p
You type way faster then me.
 
Code:
getPlayerStorageValue(uid, key)
doPlayerSetStorageValue(uid, key, newValue)

Above is some functions associated with storage values.
There is usually a compat like this, which just make it a little less confusing when writing it out. (at least I find it easier)

Code:
setPlayerStorageValue = doPlayerSetStorageValue

A very simple script to show you how to use both functions.
Code:
function onStepIn(cid, item, position, fromPosition)

     -- Get player storage value and compare it to a number.
     if getPlayerStorageValue(uid, key) < n then

         -- Then do something if it is true!
         doPlayerSetStorageValue(uid, key, newValue)
  
     end
     return true
end

-- Now with a real storage value
function onStepIn(cid, item, position, fromPosition)

     --[[
         All storage values start at -1
         Many people use 0 to start a quest, and use 1 as the finished state.
         In many cases like a one-time chest for example, you can skip straight to the finished state of 1, by-passing 0 altogether.
         Using this as your base knowledge let's continue
     ]]--

     -- If cid (players) storage value is "less then" 1 then
     if getPlayerStorageValue(cid, 45001) < 1 then

         -- Set the players storage value to 1.
         doPlayerSetStorageValue(cid, 45001, 1)
  
         -- Now you could just as easily change the number to 3000, or 5700, or 9999.
         -- There is no reason to do so, but you can effectively jump around, or even go backward in numbers if you need too.
  
     end
     return true
end

--[[
   Now that you know the bare minimum, try to create a action script, which gives you a brown backpack, only once.
]]--
Once you are done creating and testing your script, check inside the spoiler to see how I did it.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, 45001) < 1 then
         doPlayerAddItem(cid, 1988, 1)
         doPlayerSetStorageValue(cid, 45001, 1)
     end
     return true
end

It's really that easy.

Now that you know the basics, the rest is simply imagination.

If you want to get a player to use 4 pillars before opening a chest and getting that backpack from before, you could do it like this.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, 45001) < 4 then
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
         doPlayerSendCancel(cid, "You must touch the 4 pillars surrounding this room before obtaining your reward.")
         if getPlayerStorageValue(cid, 45001) < 1 then
             doPlayerSetStorageValue(cid, 45001, 0)
         end
     elseif getPlayerStorageValue(cid, 45001) == 4 then
         doPlayerAddItem(cid, 1988, 1)
         doPlayerSetStorageValue(cid, 45001, 5)
     end
     return true
end
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, 45001) >= 0 and getPlayerStorageValue(cid, 45001) < 4 then
         doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
         doPlayerSetStorageValue(cid, 45001, getPlayerStorageValue(cid, 45001) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have touched ".. getPlayerStorageValue(cid, 45001) .."/4 pillars.")
     end
     return true
end
If you want a player to start a quest at one npc and end at another npc, the inside of an npc could look like this. (very basic of course..)
Code:
if msgcontains(msg, "secrets") and (getPlayerStorageValue(cid, 45070) < 0) then
     selfSay("Congratulations. Secret keyword obtained! Go tell NPC 2!", cid)
     setPlayerStorageValue(cid, 45070, 0)
end
Code:
if msgcontains(msg, "secret keyword") and (getPlayerStorageValue(cid, 45070) == 0) then
   selfSay("Wow you know the secret keyword! Fantastic! Have a backpack.", cid)
   doPlayerAddItem(cid, 1988, 1)
   setPlayerStorageValue(cid, 45070, 1)
end
Now something we didn't cover earlier is this
Code:
getGlobalStorageValue(valueid)
setGlobalStorageValue(key, newValue)
This is the exact same as a storage value for players, but it affects everyone who comes in contact with it.
Whether you use it in a globalevent, or in a movement script, doesn't matter, but you use it exactly the same as above.
For example.. you could make a couch fart when someone walks over it, with a small delay for everyone.

Code:
local storage = 45001
local seconds = 5
function onStepIn(cid, item, position, fromPosition)
     time = os.time()
     if getGlobalStorageValue(storage)+seconds < time then
         setGlobalStorageValue(storage, os.time())
         doCreatureSay(cid, "Pffrrt!", TALKTYPE_ORANGE_1)
     end
     return true
end
Not very useful, but hey you can do it.
You can obviously use it in more fantastic and fun ways, but it's just an example.

When it comes to storage values, it's simply limited by your imagination on how you plan to use it.

Hope it helps.

Cheers,

Xikini
Also thanks for the tutorial! I'll try to do the mission with the backpack.

Thanks! :D
 
Requested by @tokenzz for a way to display available tasks to players through npc text.
Here it is. :p
Code:
local task = {
   [1] = {thing = "task 1", storageID = 45001, valueMin = -1, valueMax = 2},
   [2] = {thing = "task 2", storageID = 45002, valueMin = -1, valueMax = 2},
   [3] = {thing = "task 3", storageID = 45003, valueMin = -1, valueMax = 2},
   [4] = {thing = "task 4", storageID = 45004, valueMin = -1, valueMax = 2}
}

if msgcontains(msg, "task") then
   local npcmsg = ""
   for i = 1, #task do
   local storage = getPlayerStorageValue(cid, task[i].storageID)
     if storage <= task[i].valueMax and storage >= task[i].valueMin then
       if npcmsg ~= "" then
         npcmsg = npcmsg.. ", "
       end
       npcmsg = npcmsg..task[i].thing
     end
   end
selfSay("Tasks available: " ..npcmsg.. ".", cid)
end
 
Could I get a little assistance with converting this script to 1.0? ;D Please, and thank you!
EDIT: I should I mention I found this in my old files, but I remember finding it on OTland. Cant remember who made it though. :c
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   return
   hasCondition(cid, CONDITION_INFIGHT) and
     doPlayerSendCancel(cid, "Sorry, you are in a fight.")
   or getPlayerLevel(cid) < getConfigInfo("levelToBuyHouse") and
     doPlayerSendCancel(cid, "Sorry, not possible.")
   or not getHouseByPlayerGUID(getPlayerGUID(cid)) and
     doPlayerSendCancel(cid, "Sorry, but you do not own a house.")
   or doTeleportThing(cid, getHouseEntry(getHouseByPlayerGUID(getPlayerGUID(cid))))
end

I had a stab at it (not much scripting experience... or at least with 1.0 stuff and what not - least I gave it a try, eh? xD)

This is what I tried... it's probably wrong on so many levels. But Hopefully I got SOMETHING right? :p
Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
   return
   player:isPzLocked and
     player:sendCancelMessage("Lose battle-signs first!")
   or getPlayerLevel(cid) < getConfigInfo("levelToBuyHouse") and
     player:sendCancelMessage("Sorry, not possible.")
   or not player:getHouse() and
     player:sendCancelMessage("Sorry, but you do not own a house.")
   or doTeleportThing(player:getHouseEntry(player:gethouse()))
end

For those wondering, it's a basic house tp scroll. You use it, and it send you to the front door of your house.. or something.
Anyway, I don't wanna be a burden, but I figure it shouldn't be too hard for a pro to figure out. xD A noob like me is still learning, I suppose.

Thanks! ;D
 
Last edited:
Could I get a little assistance with converting this script to 1.0? ;D Please, and thank you!
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   return
   hasCondition(cid, CONDITION_INFIGHT) and
     doPlayerSendCancel(cid, "Sorry, you are in a fight.")
   or getPlayerLevel(cid) < getConfigInfo("levelToBuyHouse") and
     doPlayerSendCancel(cid, "Sorry, not possible.")
   or not getHouseByPlayerGUID(getPlayerGUID(cid)) and
     doPlayerSendCancel(cid, "Sorry, but you do not own a house.")
   or doTeleportThing(cid, getHouseEntry(getHouseByPlayerGUID(getPlayerGUID(cid))))
end

I had a stab at it (not much scripting experience... or at least with 1.0 stuff and what not - least I gave it a try, eh? xD)

This is what I tried... it's probably wrong on so many levels. But Hopefully I got SOMETHING right? :p
Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
   return
   player:isPzLocked and
     player:sendCancelMessage("Lose battle-signs first!")
   or getPlayerLevel(cid) < getConfigInfo("levelToBuyHouse") and
     player:sendCancelMessage("Sorry, not possible.")
   or not player:getHouse() and
     player:sendCancelMessage("Sorry, but you do not own a house.")
   or doTeleportThing(player:getHouseEntry(player:gethouse()))
end

For those wondering, it's a basic house tp scroll. You use it, and it send you to the front door of your house.. or something.
Anyway, I don't wanna be a burden, but I figure it shouldn't be too hard for a pro to figure out. xD A noob like me is still learning, I suppose.

Thanks! ;D
Both scripts are incorrectly written, btw @Xikini doesn't write scripts for 1.x servers, I do for any version tho..
 
Try this
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = type(cid) == 'userdata' and cid or Player(cid)
    if player:isPzLocked() then
        player:sendCancelMessage("Lose battle-signs first!")
        return false
    end
   
    if player:getLevel() < levelToBuyHouse then
        player:sendCancelMessage("Sorry, not possible.")
        return false
    end
   
    if not player:getHouse() then
        player:sendCancelMessage("Sorry, but you do not own a house.")
        return false
    end
   
    player:teleportTo( House( player:gethouse():getId() ):getExitPosition(), false)
    return true
end
 
Last edited:
Try this
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = type(cid) == 'userdata' and cid or Player(cid)
    if player:isPzLocked() then
        player:sendCancelMessage("Lose battle-signs first!")
        return false
    end
  
    if player:getLevel() < levelToBuyHouse then
        player:sendCancelMessage("Sorry, not possible.")
        return false
    end
  
    if not player:getHouse() then
        player:sendCancelMessage("Sorry, but you do not own a house.")
        return false
    end
  
    player:teleportTo( House( player:gethouse():getId() ):getExitPosition(), false)
    return true
end
Just out of curiosity.. what if the house is already owned?
What happens?
 
Try this
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = type(cid) == 'userdata' and cid or Player(cid)
    if player:isPzLocked() then
        player:sendCancelMessage("Lose battle-signs first!")
        return false
    end
  
    if player:getLevel() < levelToBuyHouse then
        player:sendCancelMessage("Sorry, not possible.")
        return false
    end
  
    if not player:getHouse() then
        player:sendCancelMessage("Sorry, but you do not own a house.")
        return false
    end
  
    player:teleportTo( House( player:gethouse():getId() ):getExitPosition(), false)
    return true
end

Erm.. am I missing a function or something? ;o
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/custom/house_deed.lua:onUse
data/actions/scripts/custom/house_deed.lua:20: attempt to call method 'gethouse'
 (a nil value)
stack traceback:
  [C]: in function 'gethouse'
  data/actions/scripts/custom/house_deed.lua:20: in function <data/actions
/scripts/custom/house_deed.lua:3>
 
Just out of curiosity.. what if the house is already owned?
What happens?
They get sent to the firey pits of hell..

Erm.. am I missing a function or something? ;o
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/custom/house_deed.lua:onUse
data/actions/scripts/custom/house_deed.lua:20: attempt to call method 'gethouse'
(a nil value)
stack traceback:
  [C]: in function 'gethouse'
  data/actions/scripts/custom/house_deed.lua:20: in function <data/actions
/scripts/custom/house_deed.lua:3>
my bad
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = type(cid) == 'userdata' and cid or Player(cid)
    if player:isPzLocked() then
        player:sendCancelMessage("Lose battle-signs first!")
        return false
    end
  
    if player:getLevel() < levelToBuyHouse then
        player:sendCancelMessage("Sorry, not possible.")
        return false
    end
  
    if not player:getHouse() then
        player:sendCancelMessage("Sorry, but you do not own a house.")
        return false
    end
  
    player:teleportTo( House( getHouseByPlayerGUID( player:getId() ) ):getExitPosition(), false)
    return true
end
 
Last edited by a moderator:
my bad
Code:
player:teleportTo( House( getHouseByPlayerGUID( player:getId() ) ):getExitPosition(), false)
FYI, you can access House meta methods by using Player.getHouse.
Code:
local house = player:getHouse()
if not house then
    player:sendCancelMessage("Sorry, but you do not own a house.")
    return false
end

player:teleportTo(house:getExitPosition())
 
FYI, you can access House meta methods by using Player.getHouse.
Code:
local house = player:getHouse()
if not house then
    player:sendCancelMessage("Sorry, but you do not own a house.")
    return false
end

player:teleportTo(house:getExitPosition())
for 1.0?

try this..
If it doesn't work then @Ninja will fix it coz he is a ninja and loves correcting my code :p
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = type(cid) == 'userdata' and cid or Player(cid)
    if player:isPzLocked() then
        player:sendCancelMessage("Lose battle-signs first!")
        return false
    end
 
    if player:getLevel() < levelToBuyHouse then
        player:sendCancelMessage("Sorry, not possible.")
        return false
    end
    local houseId = getHouseByPlayerGUID( player:getId() )
    if not houseId then
        player:sendCancelMessage("Sorry, but you do not own a house.")
        return false
    end
 
    player:teleportTo( House( houseId ):getExitPosition(), false)
    return true
end
 
Last edited by a moderator:
try this..
If it doesn't work then @Ninja will fix it coz he is a ninja and loves correcting my code :p
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = type(cid) == 'userdata' and cid or Player(cid)
    if player:isPzLocked() then
        player:sendCancelMessage("Lose battle-signs first!")
        return false
    end

    if player:getLevel() < levelToBuyHouse then
        player:sendCancelMessage("Sorry, not possible.")
        return false
    end
    local houseId = getHouseByPlayerGUID( player:getId() )
    if houseId then
        player:sendCancelMessage("Sorry, but you do not own a house.")
        return false
    end

    player:teleportTo( House( houseId ):getExitPosition(), false)
    return true
end
Didn't work. xD
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/custom/house_deed.lua:onUse
data/actions/scripts/custom/house_deed.lua:20: attempt to index a nil value
stack traceback:
  [C]: in function '__index'
  data/actions/scripts/custom/house_deed.lua:20: in function <data/actions
/scripts/custom/house_deed.lua:3>
BUT! @Ninja 's little addition worked like a charm. :3
Thank you all so much! ;D It's currently 7:45am, been up all night trying to get a head start on these scripting ideas, and this whole new lua stuff is frustrating. xD

So yeah. As said, I'm eternally grateful for the help guys! ;D <3 <3 <3
And, sorry @Xikini for posting in your thread on accident. Sleep deprived and honestly thought the titled included 1.0+ scripts or something. xD I usually refrain from asking for help, but I caved. So thanks again everyone! ;D Love you all!!

P.S. In the future, if I need scripting help/requests, where should I post about it? ;o
 
...spoke too soon, perhaps. One last thing, my amigos.. It seems none of the sendCancelMessage work.. Maybe I inserted wrongly?
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
  local player = type(cid) == 'userdata' and cid or Player(cid)
  if player:isPzLocked() then
  player:sendCancelMessage("Lose battle-signs first!")
  return false
  end
   
  if player:getLevel() < levelToBuyHouse then
  player:sendCancelMessage("Sorry, not possible.")
  return false
  end
   
   local house = player:getHouse()
   if not house then
     player:sendCancelMessage("You do not own a house.")
     return false
   end

   player:teleportTo(house:getExitPosition())
  return true
end
 
...spoke too soon, perhaps. One last thing, my amigos.. It seems none of the sendCancelMessage work.. Maybe I inserted wrongly?
Code:
local levelToBuyHouse = 8
-- this should work for 1.0 or 1.1+
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
  local player = type(cid) == 'userdata' and cid or Player(cid)
  if player:isPzLocked() then
  player:sendCancelMessage("Lose battle-signs first!")
  return false
  end
  
  if player:getLevel() < levelToBuyHouse then
  player:sendCancelMessage("Sorry, not possible.")
  return false
  end
  
   local house = player:getHouse()
   if not house then
     player:sendCancelMessage("You do not own a house.")
     return false
   end

   player:teleportTo(house:getExitPosition())
  return true
end
Try changing the return false, to return true.
 
Status
Not open for further replies.
Back
Top