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

[LuaSQL] Need help

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,657
Solutions
125
Reaction score
1,103
Location
Germany
GitHub
slawkens
Hey.

I want take from database some number, to be it was INTEGER, not STRING. When i try take something its always STRING, and i cant make (if numberfromDB >= 30 then) becouse it always shows "attempt to compare number with string"!

Some part of script:
Code:
    cur = assert(con:execute("SELECT `account_id` FROM `players` WHERE `id` = "..getPlayerGUID(cid)..";"))
    row = cur:fetch({}, "a")
    curr = assert(con:execute("SELECT `type` FROM `accounts` WHERE `id` = "..row.account_id..";"))
    roww = curr:tuple({}, "a")
        if roww.type >= 4 then
 
Last edited by a moderator:
And next, with tables.

I want make talkaction command for addons, but optimized.

But how i can make it?

I tried

Code:
function onSay(cid, words, param)
local addons =
{
	{['citizenfirst'] = {6,64}},
	{['citizensecond'] = {3,6}}
}

if addons[param] ~= nil then
	doPlayerSendTextMessage(cid, 22, "good")
else
	doPlayerSendTextMessage(cid, 22, "no good")
end
end
attempt to index field '?' (a nil value)

isInArray(addons, param) also doesnt work.
 
Last edited:
Change
{['citizenfirst'] = {6,64}},
{['citizensecond'] = {3,6}}
to:
{citizenfirst = {6,64}},
{citizensecond = {3,6}}

If I understood you correct :p

However, looking at your script, I think this is what you're really trying to do:
Code:
 function onSay(cid, words, param)
local addons =
{
    citizenfirst = {6,64},
    citizensecond = {3,6}
}

if addons[param] ~= nil then
    doPlayerSendTextMessage(cid, 22, "good")
else
    doPlayerSendTextMessage(cid, 22, "no good")
end
end
 
Last edited:
Last. Thats my table: :D
Code:
local addons =
{
	citizenbo =	{128, 1, 136, 1, 10001, 2},
	citizenhat =	{128, 2, 136, 2, 10002, 2},
	hunterhood =	{129, 1, 137, 2, 20002, 2},
	huntergloves =	{129, 2, 137, 1, 20001, 2},
	knightsword =	{131, 1, 139, 1, 30001, 2},
	knighthelmet =	{131, 2, 139, 2, 30002, 2},
	magefirst =	{141, 1, 130, 1, 40001, 2},
	magesecond =	{141, 2, 130, 2, 40002, 2},
	summonerfirst =		{138, 1, 133, 1, 50001, 2},
	summonersecond =	{138, 2, 133, 2, 50002, 2},
	barbarianhair =	{143, 2, 147, 2, 60001, 2},
	barbarianaxe =	{143, 1, 147, 1, 60002, 2},
	druidpaws =	{144, 1, 148, 1, 70001, 2},
	druidhead =	{144, 2, 148, 2, 70002, 2},
	noblefirst =	{132, 1, 140, 1, 80001, 2},
	noblesecond =	{132, 2, 140, 2, 80002, 2},
	orientalsabre =		{146, 1, 150, 1, 90001, 2},
	orientalturban =	{146, 2, 150, 2, 90002, 2},
	warriorspike =	{134, 1, 142, 1, 100001, 2},
	warriorsword =	{134, 2, 142, 2, 100002, 2},
	wizardskull =	{145, 2, 149, 2, 110001, 2},
	wizardarms =	{145, 1, 149, 1, 110002, 2},
	assassinsabre = {152, 2, 156, 2, 120001, 2},
	assassinhood =	{152, 1, 156, 1, 120002, 2},
	beggarbeard =	{153, 1, 157, 1, 130001, 2},
	beggarstaff =	{153, 2, 157, 2, 130002, 2},
	piratesabre =	{151, 1, 155, 1, 140001, 2},
	piratehat =	{151, 2, 155, 2, 140002, 2},
	shamanmask =	{154, 1, 158, 1, 150001, 2},
	shamanstaff =	{154, 2, 158, 2, 150002, 2},
	norsefirst =	{251, 1, 252, 1, 160001, 2},
	norsesecond =	{251, 1, 252, 1, 160002, 2},
	brotherhoodfirst = 	{128, 1, 136, 1, 10001, 2},
	brotherhoodsecond = 	{128, 1, 136, 1, 10001, 2},
	jesterfirst =	{128, 1, 136, 1, 10001, 2},
	jestersecond =	{128, 1, 136, 1, 10001, 2},
	nightmarefirst =	{128, 1, 136, 1, 10001, 2},
	nightmaresecond =	{128, 1, 136, 1, 10001, 2}
}
 
Back
Top