How do I fix this? https://imgur.com/2on83jB
Post scriptHow do I fix this? https://imgur.com/2on83jB
local config = {
teleportAccess = 3
}
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
local teleport = false
local t = string.explode(param, ",")
if(t[2]) then
teleport = getBooleanFromString(t[2])
param = t[1]
end
local house = getHouseByPlayerGUID(getPlayerGUIDByName(param))
if(not house) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " does not own house or doesn't exists.")
return true
end
local houseInfo = getHouseInfo(house)
if(teleport and getPlayerAccess(cid) >= config.teleportAccess) then
doTeleportThing(cid, houseInfo.entry)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param .. " owns house: " .. houseInfo.name .. ".")
return true
end
[code=lua]function onSay(cid, words, param)
local itemid = 9693 -- the items id for addon doll
local msg = {"enter the correct name!", "You no have the Addon Doll!", "Bad param!", "You received your addons!"} -- the messages when use the talkaction
local femaleOutfits =
{
["citizen"]={136},
["hunter"]={137},
["mage"]={138},
["knight"]={139},
["noblewoman"]={140},
["summoner"]={141},
["warrior"]={142},
["barbarian"]={147},
["druid"]={148},
["wizard"]={149},
["oriental"]={150},
["pirate"]={155},
["assassin"]={156},
["beggar"]={157},
["shaman"]={158},
["norsewoman"]={252},
["nightmare"]={269},
["jester"]={270},
["brotherhood"]={279},
["demonhunter"]={288},
["yalaharian"]={324},
["warmaster"]={336},
["wayfarer"]={366},
["afflicted"]={431},
["elementalist"]={433},
["deepling"]={464},
["insectoid"]={466},
["entrepreneur"]={471},
["crystal warlord"]={513},
["soil guardian"]={514}
}
local maleOutfits =
{
["citizen"]={128},
["hunter"]={129},
["mage"]={130},
["knight"]={131},
["nobleman"]={132},
["summoner"]={133},
["warrior"]={134},
["barbarian"]={143},
["druid"]={144},
["wizard"]={145},
["oriental"]={146},
["pirate"]={151},
["assassin"]={152},
["beggar"]={153},
["shaman"]={154},
["norsewoman"]={251},
["nightmare"]={268},
["jester"]={273},
["brotherhood"]={278},
["demonhunter"]={289},
["yalaharian"]={325},
["warmaster"]={335},
["wayfarer"]={366},
["afflicted"]={430},
["elementalist"]={432},
["deepling"]={463},
["insectoid"]={465},
["entrepreneur"]={472},
["crystal warlord"]={512},
["soil guardian"]={516}
}
local param = string.lower(param)
if(getPlayerItemCount(cid, itemid) > 0) then
if(param ~= "" and maleOutfits[param] and femaleOutfits[param]) then
doPlayerRemoveItem(cid, itemid, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[4])
doSendMagicEffect(getCreaturePosition(cid), 33)
doSendAnimatedText(getPlayerPosition(cid), "AddonDoll", TEXTCOLOR_RED)
if(getPlayerSex(cid) == 0)then
doPlayerAddOutfit(cid, femaleOutfits[param][1], 3)
else
doPlayerAddOutfit(cid, maleOutfits[param][1], 3)
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[1])
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[2])
end
return TRUE
end
buyhouse.lua
Code:local config = { teleportAccess = 3 } function onSay(cid, words, param, channel) if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.") return true end local teleport = false local t = string.explode(param, ",") if(t[2]) then teleport = getBooleanFromString(t[2]) param = t[1] end local house = getHouseByPlayerGUID(getPlayerGUIDByName(param)) if(not house) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " does not own house or doesn't exists.") return true end local houseInfo = getHouseInfo(house) if(teleport and getPlayerAccess(cid) >= config.teleportAccess) then doTeleportThing(cid, houseInfo.entry) end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param .. " owns house: " .. houseInfo.name .. ".") return true end
function onSay(cid, words, param, channel)
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return TRUE
end
local house = getHouseByPlayerGUID(getPlayerGUIDByName(param))
if(not house) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " does not own house or doesn't exists.")
return TRUE
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param .. " owns house: " .. getHouseName(house) .. ".")
return TRUE
end
addon.lua
[/CODE]Code:[code=lua]function onSay(cid, words, param) local itemid = 9693 -- the items id for addon doll local msg = {"enter the correct name!", "You no have the Addon Doll!", "Bad param!", "You received your addons!"} -- the messages when use the talkaction local femaleOutfits = { ["citizen"]={136}, ["hunter"]={137}, ["mage"]={138}, ["knight"]={139}, ["noblewoman"]={140}, ["summoner"]={141}, ["warrior"]={142}, ["barbarian"]={147}, ["druid"]={148}, ["wizard"]={149}, ["oriental"]={150}, ["pirate"]={155}, ["assassin"]={156}, ["beggar"]={157}, ["shaman"]={158}, ["norsewoman"]={252}, ["nightmare"]={269}, ["jester"]={270}, ["brotherhood"]={279}, ["demonhunter"]={288}, ["yalaharian"]={324}, ["warmaster"]={336}, ["wayfarer"]={366}, ["afflicted"]={431}, ["elementalist"]={433}, ["deepling"]={464}, ["insectoid"]={466}, ["entrepreneur"]={471}, ["crystal warlord"]={513}, ["soil guardian"]={514} } local maleOutfits = { ["citizen"]={128}, ["hunter"]={129}, ["mage"]={130}, ["knight"]={131}, ["nobleman"]={132}, ["summoner"]={133}, ["warrior"]={134}, ["barbarian"]={143}, ["druid"]={144}, ["wizard"]={145}, ["oriental"]={146}, ["pirate"]={151}, ["assassin"]={152}, ["beggar"]={153}, ["shaman"]={154}, ["norsewoman"]={251}, ["nightmare"]={268}, ["jester"]={273}, ["brotherhood"]={278}, ["demonhunter"]={289}, ["yalaharian"]={325}, ["warmaster"]={335}, ["wayfarer"]={366}, ["afflicted"]={430}, ["elementalist"]={432}, ["deepling"]={463}, ["insectoid"]={465}, ["entrepreneur"]={472}, ["crystal warlord"]={512}, ["soil guardian"]={516} } local param = string.lower(param) if(getPlayerItemCount(cid, itemid) > 0) then if(param ~= "" and maleOutfits[param] and femaleOutfits[param]) then doPlayerRemoveItem(cid, itemid, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[4]) doSendMagicEffect(getCreaturePosition(cid), 33) doSendAnimatedText(getPlayerPosition(cid), "AddonDoll", TEXTCOLOR_RED) if(getPlayerSex(cid) == 0)then doPlayerAddOutfit(cid, femaleOutfits[param][1], 3) else doPlayerAddOutfit(cid, maleOutfits[param][1], 3) end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[1]) end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[2]) end return TRUE end
I replaced the buyhouse code but it did not work. It says Bad Param. in ingame chat when I use the !buyhouse command in front of a door. The other code still shows the same error and I do not know why.Code:function onSay(cid, words, param, channel) if(param == "") then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.") return TRUE end local house = getHouseByPlayerGUID(getPlayerGUIDByName(param)) if(not house) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " does not own house or doesn't exists.") return TRUE end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param .. " owns house: " .. getHouseName(house) .. ".") return TRUE end
what wrong with this ?
" ?
That would be weird (install error maybe), but it would explain the "parsing error on line 1" message.
re buyhouse: "bad param" means something doesn't like the value of variable "param".
Probably this: [CODE]getPlayerGUIDByName(param)
Yes, theDoes addon.lua really start with "LUA:" ? That would be weird (install error maybe), but it would explain the "parsing error on line 1" message. re buyhouse: "bad param" means something doesn't like the value of variable "param". Probably this: [CODE]getPlayerGUIDByName(param)
And please: don't filter the error messages you see. If you get a logged message, copy and paste the log here.
If you knew enough to select the specific things we need to solve your problem, you would already know enough to solve it yourself![]()
is there.
Yes, theDoes addon.lua really start with "LUA:" ? That would be weird (install error maybe), but it would explain the "parsing error on line 1" message. re buyhouse: "bad param" means something doesn't like the value of variable "param". Probably this: [CODE]getPlayerGUIDByName(param)
And please: don't filter the error messages you see. If you get a logged message, copy and paste the log here.
If you knew enough to select the specific things we need to solve your problem, you would already know enough to solve it yourself![]()
is there.
I replaced the buyhouse code but it did not work. It says Bad Param. in ingame chat when I use the !buyhouse command in front of a door. The other code still shows the same error and I do not know why.
Does addon.lua really start with "LUA:" ? That would be weird (install error maybe), but it would explain the "parsing error on line 1" message. re buyhouse: "bad param" means something doesn't like the value of variable "param". Probably this: [CODE]getPlayerGUIDByName(param)
And please: don't filter the error messages you see. If you get a logged message, copy and paste the log here.
If you knew enough to select the specific things we need to solve your problem, you would already know enough to solve it yourself![]()
I was reply on your post and it mistake :)
I use this and work
what TFS you use ?
AboutLUA:I was reply on your post and it mistake :)[/quote] The latest, TFS_10
Yes, theLUA:is there.[/quote] Remove it and try again. That will definitely blow up the Lua parser. [] are used for array/table indexing, and they have to follow a variable name. you can write x = abc[code=lua] and even if the code won't run, the parser doesn't care. AFAIK a bare "[ ]" is always invalid - the parser will blow up, and the script won't load. It might not stop OT starting, but it's likely to cause a lot of other problems :)
Remove it and try again.
That will definitely blow up the Lua parser.
[] are used for array/table indexing, and they have to follow a variable name.
you can write
x = abcLUA:and even if the code won't run, the parser doesn't care. AFAIK a bare "[ ]" is always invalid - the parser will blow up, and the script won't load. It might not stop OT starting, but it's likely to cause a lot of other problems :)[/quote] It is going in the right directions, removing [code=lua] worked :) But now I can not get the script to work. No errors but whenever I use the addon.lua script and say "!addon" it says "enter the correct name!". When I say like "!first mage addon" it does not do anything. No errors or texts. When I use the buyhouse.lua script and say "!buyhouse" it says Command param required. with blue text in the chat. No errors tho.
local config = {
teleportAccess = 3
}
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
local teleport = false
local t = string.explode(param, ",")
if(t[2]) then
teleport = getBooleanFromString(t[2])
end
local house = getHouseByPlayerGUID(getPlayerGUIDByName(t[1]))
if(not house) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " does not own house or doesn't exists.")
return true
end
local houseInfo = getHouseInfo(house)
if(teleport and getPlayerAccess(cid) >= config.teleportAccess) then
doTeleportThing(cid, houseInfo.entry)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[1] .. " owns house: " .. houseInfo.name .. ".")
return true
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
<?xml version="1.0" encoding="UTF-8"?>
<talkactions>
<!-- commands -->
<talkaction words="/ban" separator=" " script="ban.lua" />
<talkaction words="/ipban" separator=" " script="ipban.lua" />
<talkaction words="/unban" separator=" " script="unban.lua" />
<talkaction words="/up" script="up.lua" />
<talkaction words="/down" script="down.lua" />
<talkaction words="/c" separator=" " script="teleport_creature_here.lua" />
<talkaction words="/goto" separator=" " script="teleport_to_creature.lua" />
<talkaction words="/owner" separator=" " script="owner.lua" />
<talkaction words="/t" script="teleport_home.lua" />
<talkaction words="/town" separator=" " script="teleport_to_town.lua" />
<talkaction words="/a" separator=" " script="teleport_ntiles.lua" />
<talkaction words="/pos" separator=" " script="position.lua" />
<talkaction words="/info" separator=" " script="info.lua" />
<talkaction words="/r" separator=" " script="removething.lua" />
<talkaction words="/kick" separator=" " script="kick.lua" />
<talkaction words="/openserver" script="openserver.lua" />
<talkaction words="/closeserver" separator=" " script="closeserver.lua" />
<talkaction words="/B" separator=" " script="broadcast.lua" />
<talkaction words="/m" separator=" " script="place_monster.lua" />
<talkaction words="/i" separator=" " script="create_item.lua" />
<talkaction words="/s" separator=" " script="place_npc.lua" />
<talkaction words="/addtutor" separator=" " script="add_tutor.lua" />
<talkaction words="/removetutor" separator=" " script="remove_tutor.lua" />
<talkaction words="/looktype" separator=" " script="looktype.lua" />
<talkaction words="/summon" separator=" " script="place_summon.lua" />
<talkaction words="/chameleon" separator=" " script="chameleon.lua" />
<talkaction words="/addskill" separator=" " script="add_skill.lua" />
<talkaction words="/mccheck" script="mccheck.lua" />
<talkaction words="/ghost" script="ghost.lua" />
<talkaction words="/clean" script="clean.lua" />
<talkaction words="/hide" script="hide.lua" />
<talkaction words="/save" script="save.lua" />
<!-- player talkactions -->
<talkaction words="!buyhouse" script="buyhouse.lua"/>
<talkaction words="!leavehouse" script="leavehouse.lua"/>
<talkaction words="!changesex" script="changesex.lua"/>
<talkaction words="!uptime" script="uptime.lua"/>
<talkaction words="!deathlist" script="deathlist.lua"/>
<talkaction words="!kills" script="kills.lua"/>
<talkaction words="!online" script="online.lua"/>
<talkaction words="!serverinfo" script="serverinfo.lua"/>
<talkaction words="!spells" script="spells.lua"/>
<talkaction words="!aol" script="aol.lua"/>
<talkaction words="!bless" script="bless.lua"/>
<talkaction words="!addon" script="addon.lua"/>
<talkaction words="!commands" script="commands.lua"/>
<!-- test talkactions -->
<talkaction words="!z" separator=" " script="magiceffect.lua"/>
<talkaction words="!x" separator=" " script="animationeffect.lua"/>
</talkactions>
local config = {
teleportAccess = 3
}
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
local teleport = false
local t = string.explode(param, ",")
if(t[2]) then
teleport = getBooleanFromString(t[2])
end
local house = getHouseByPlayerGUID(getPlayerGUIDByName(t[1]))
if(not house) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " does not own house or doesn't exists.")
return true
end
local houseInfo = getHouseInfo(house)
if(teleport and getPlayerAccess(cid) >= config.teleportAccess) then
doTeleportThing(cid, houseInfo.entry)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[1] .. " owns house: " .. houseInfo.name .. ".")
return true
end
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
-- more lua code after this ...
local t = string.explode(param, ",")
if(t[2]) then
teleport = getBooleanFromString(t[2])
end
function onSay(cid, words, param)
local housePrice = configManager.getNumber(configKeys.HOUSE_PRICE)
if housePrice == -1 then
return true
end
local player = Player(cid)
if player:getPremiumDays() <= 0 then
player:sendCancelMessage("You need a premium account.")
return false
end
local position = player:getPosition()
position:getNextPosition(player:getDirection())
local house = House(getTileHouseInfo(position))
if house == nil then
player:sendCancelMessage("You have to be looking at the door of the house you would like to buy.")
return false
end
if house:getOwnerGuid() > 0 then
player:sendCancelMessage("This house already has an owner.")
return false
end
if player:getHouse() then
player:sendCancelMessage("You are already the owner of a house.")
return false
end
local price = house:getTileCount() * housePrice
if not player:removeMoney(price) then
player:sendCancelMessage("You do not have enough money.")
return false
end
house:setOwnerGuid(player:getGuid())
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.")
return false
end
I have the code for TFS 1.0, and my buyhouse.lua looks very different to yours.
The immediate issue you have is this code at the start of buyhouse:
Code:function onSay(cid, words, param, channel) if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.") return true end -- more lua code after this ...
It tests if "param" (from the method signature) is an empty string. if it is, it issues that message, and exists the script.
Of course we've only explained the symptom, not the problem, but it's a start
If you had provided a valid parameter (I suppose this is some words after !buyhouse, but I don't actually know for sure)
this code would be executed:
It wants param to contain a string with a "," in it. It instects the part after the "," and if it finds anything other than "false" (or maybe one other special value) it will set flag "teleport" to "true".Code:local t = string.explode(param, ",") if(t[2]) then teleport = getBooleanFromString(t[2]) end
Then it checks if the player owns a house, and if they're cool enough to be allowed to teleport. If so it teleports the player to the house. if not, it just says they own the house.
I don't know if that's what you want, but it certainly doesn't match the command. It would be fine if the command was "!teleportMeHome"
So ... if you just want to buy a house, I think you have the wrong script. In case you don't have the TFS 1.0 original, here it is:
PHP:function onSay(cid, words, param) local housePrice = configManager.getNumber(configKeys.HOUSE_PRICE) if housePrice == -1 then return true end local player = Player(cid) if player:getPremiumDays() <= 0 then player:sendCancelMessage("You need a premium account.") return false end local position = player:getPosition() position:getNextPosition(player:getDirection()) local house = House(getTileHouseInfo(position)) if house == nil then player:sendCancelMessage("You have to be looking at the door of the house you would like to buy.") return false end if house:getOwnerGuid() > 0 then player:sendCancelMessage("This house already has an owner.") return false end if player:getHouse() then player:sendCancelMessage("You are already the owner of a house.") return false end local price = house:getTileCount() * housePrice if not player:removeMoney(price) then player:sendCancelMessage("You do not have enough money.") return false end house:setOwnerGuid(player:getGuid()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.") return false end
As you can see, it's nothing like yours, and it doesn't exit if you don't say anything after "!buyhouse"
BTW - this is why I wanted all that information. I thought there must be another script between the XML and you buyhouse.lua that was able to handle the purchase process, and knew how to use the method signature in your buyhouse.lua.
if player:getHouse() then
player:sendCancelMessage("You are already the owner of a house.")
return false
end