Cornwallis
Member
- Joined
- Jan 3, 2010
- Messages
- 480
- Reaction score
- 16
Alright, well anyways, I'm using 0.3.1pl2 ( I know this is extremely outdated but I'm using it until 0.3.7 is stable because I couldn't compile it right.) But what this script does is when you say !shop, itemname - it gives the item for points, I know, simple.
Edit; Now what I'm trying to do with this script is make it have a special description saying "This item was purchased by "Player Name"."
There is no errors in console on startup, or reloads. When i use the command, I get this error in console:
I'm thinking doSetItemSpecialDescription(item, "This item was purchased by "..getPlayerName(cid)..".") might just be set in the wrong place, or where it says item, that might be wrong. I tried v.id, didn't work. Please help
FIXED: I took out the count of items since i won't have stackable items in the list. If you would like the fix the top script and make it so it adds a special description, that would be great, but anyways here is my solution:
Edit; Now what I'm trying to do with this script is make it have a special description saying "This item was purchased by "Player Name"."
PHP:
function onSay(cid, words, param)
local shop = {
["1"] = {
id = 6527, count = 1, points = 1
},
["2"] = {
id = 9933, count = 1, points = 4
},
["3"] = {
id = 2798, count = 100, points = 1
},
["4"] = {
id = 2160, count = 50, points = 2
},
["5"] = {
id = 6132, count = 1, points = 3
},
["6"] = {
id = 2195, count = 1, points = 2
},
["7"] = {
id = 2495, count = 1, points = 5
},
["8"] = {
id = 2495, count = 1, points = 5
},
["9"] = {
id = 2390, count = 1, points = 3
},
["10"] = {
id = 2390, count = 1, points = 3
},
["11"] = {
id = 2390, count = 1, points = 3
},
["12"] = {
id = 2390, count = 1, points = 3
},
["13"] = {
id = 2390, count = 1, points = 3
},
["14"] = {
id = 2390, count = 1, points = 3
}
}
local v = shop[param]
local check = db.getResult("SELECT `points` FROM `accounts` WHERE `id` = '" .. getPlayerAccountId(cid) .. "' LIMIT 1;"):getDataInt("points")
if (v == nil) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, 'Sorry, you are using the wrong param. (Ex: !shop 1) - To see the shop list say "!shoplist". ')
return true
end
if check >= v.points then
local item = doCreateItemEx(v.id, v.count)
if doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR then
doSetItemSpecialDescription(item, "This item was purchased by "..getPlayerName(cid)..".")
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Sorry, you do not have the ability to carry this.")
else
doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Shop: You now have "..check - v.points.." points left.")
db.executeQuery("UPDATE `accounts` SET `points` = `points` - " .. v.points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Sorry, you do not have enough points.")
end
return true
end
There is no errors in console on startup, or reloads. When i use the command, I get this error in console:
Code:
[30/05/2012 09:13:32] luaDoSetItemSpecialDescription(). Item not found
I'm thinking doSetItemSpecialDescription(item, "This item was purchased by "..getPlayerName(cid)..".") might just be set in the wrong place, or where it says item, that might be wrong. I tried v.id, didn't work. Please help
Code:
doSetItemSpecialDescription(item, "This item was purchased by "..getPlayerName(cid)..".")
FIXED: I took out the count of items since i won't have stackable items in the list. If you would like the fix the top script and make it so it adds a special description, that would be great, but anyways here is my solution:
PHP:
function onSay(cid, words, param)
local shop = {
["1"] = {
id = 6527, points = 1
},
["2"] = {
id = 9933, points = 4
},
["3"] = {
id = 2798, points = 1
},
["4"] = {
id = 2160, points = 2
},
["5"] = {
id = 6132, points = 3
},
["6"] = {
id = 2195, points = 2
},
["7"] = {
id = 2495, points = 5
},
["8"] = {
id = 2495, points = 5
},
["9"] = {
id = 2390, points = 3
},
["10"] = {
id = 2390, points = 3
},
["11"] = {
id = 2390, points = 3
},
["12"] = {
id = 2390, points = 3
},
["13"] = {
id = 2390, points = 3
},
["14"] = {
id = 2390, points = 3
}
}
local v = shop[param]
local check = db.getResult("SELECT `points` FROM `accounts` WHERE `id` = '" .. getPlayerAccountId(cid) .. "' LIMIT 1;"):getDataInt("points")
if (v == nil) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, 'Sorry, you are using the wrong param. (Ex: !shop 1) - To see the shop list say "!shoplist". ')
return true
end
if check >= v.points then
local item = doCreateItemEx(v.id, desc)
local desc = doSetItemSpecialDescription(item, "This item was purchased by "..getPlayerName(cid)..".")
if doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Sorry, you do not have the ability to carry this.")
else
doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Shop: You now have "..check - v.points.." points left.")
db.executeQuery("UPDATE `accounts` SET `points` = `points` - " .. v.points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Sorry, you do not have enough points.")
end
return true
end
Last edited: