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

Adding premium points if player is offline command.

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Hi everyone, well, here is a script to add points if player is online, it works like: /addpoints kito, 50 and it will add 50 points if you are online, but if you are offline, it wont do that, so I need help, can someone fix this script and make available to add points if player is offline too?

PHP:
 ‎function onSay(cid, words, param)
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
return TRUE
end

local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
return TRUE
end

local target = getPlayerByName(t[1])
if target ~= 0 then
doAddPoints(target, t[2])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, target.." has received "..t[2].." premium points.")
doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, "You have received "..t[2].." premium points.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
end
return FALSE
end

Thanks.
 
Try this not, not tested.

HTML:
function onSay(cid, words, param)
	local t = string.explode(param, ",")
	if t[1] ~= nil and t[2] ~= nil then
		local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
		db.executeQuery("UPDATE `accounts` SET `premium_points` = premium_ponts + "..t[2].." WHERE `id` = '" .. result .. "';")
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
	end
	return TRUE
end

Regards,
Shawak
 
Error:

PHP:
 ‎[07/08/2009 13:26:04] Lua Script Error: [TalkAction Interface] 
[07/08/2009 13:26:04] data/talkactions/scripts/mtibia/points.lua:onSay
[07/08/2009 13:26:04] 
[07/08/2009 13:26:04] data/talkactions/scripts/mtibia/points.lua:5: attempt to concatenate local 'result' (a table value)
[07/08/2009 13:26:04] stack traceback:
[07/08/2009 13:26:04] data/talkactions/scripts/mtibia/points.lua:5: in function <data/talkactions/scripts/mtibia/points.lua:1>
[07/08/2009 13:26:07] 
[07/08/2009 13:26:07] Lua Script Error: [TalkAction Interface] 
[07/08/2009 13:26:07] data/talkactions/scripts/mtibia/points.lua:onSay
[07/08/2009 13:26:07] 
[07/08/2009 13:26:07] data/talkactions/scripts/mtibia/points.lua:5: attempt to concatenate local 'result' (a table value)
[07/08/2009 13:26:07] stack traceback:
[07/08/2009 13:26:07] data/talkactions/scripts/mtibia/points.lua:5: in function <data/talkactions/scripts/mtibia/points.lua:1>
[07/08/2009 13:26:27] The Patron has logged in.
[07/08/2009 13:26:33] Khako has logged out.
[07/08/2009 13:26:36] Khako has logged in.
[07/08/2009 13:26:43] 
[07/08/2009 13:26:43] Lua Script Error: [TalkAction Interface] 
[07/08/2009 13:26:43] data/talkactions/scripts/mtibia/points.lua:onSay
[07/08/2009 13:26:43] 
[07/08/2009 13:26:43] data/talkactions/scripts/mtibia/points.lua:5: attempt to concatenate local 'result' (a table value)
[07/08/2009 13:26:43] stack traceback:
[07/08/2009 13:26:43] data/talkactions/scripts/mtibia/points.lua:5: in function <data/talkactions/scripts/mtibia/points.lua:1>
 
@Up:
Lua:
function onSay(cid, words, param)
	local t = string.explode(param, ",")
	if t[1] ~= nil and t[2] ~= nil then
		local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
		db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_ponts` + "..t[2].." WHERE `id` = '" .. result .. "';")
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
	end
	return TRUE
end
 
@Up

PHP:
 ‎[07/08/2009 23:49:04] Lua Script Error: [TalkAction Interface] 
[07/08/2009 23:49:04] data/talkactions/scripts/mtibia/points.lua:onSay
[07/08/2009 23:49:04] 
[07/08/2009 23:49:04] data/talkactions/scripts/mtibia/points.lua:5: attempt to concatenate local 'result' (a table value)
[07/08/2009 23:49:04] stack traceback:
[07/08/2009 23:49:04] data/talkactions/scripts/mtibia/points.lua:5: in function <data/talkactions/scripts/mtibia/points.lua:1>

Im using tfs0.3.4pl2
 
Lua:
  function onSay(cid, words, param)
        local t = string.explode(param, ",")
        if t[1] ~= nil and t[2] ~= nil then
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_ponts` + "..t[2].." WHERE `id` = '" .. result .. "';")
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
        end
        return TRUE
end
 
@UP

PHP:
[08/08/2009 12:31:51] Lua Script Error: [TalkAction Interface] 
[08/08/2009 12:31:51] data/talkactions/scripts/mtibia/points.lua:onSay
[08/08/2009 12:31:51] 
[08/08/2009 12:31:51] data/talkactions/scripts/mtibia/points.lua:4: attempt to concatenate global 'result' (a table value)
[08/08/2009 12:31:51] stack traceback:
[08/08/2009 12:31:51] data/talkactions/scripts/mtibia/points.lua:4: in function <data/talkactions/scripts/mtibia/points.lua:1>
 
Lua:
function onSay(cid, words, param)
        local t = string.explode(param, ",")
        if t[1] ~= nil and t[2] ~= nil then
                local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_ponts` + "..t[2].." WHERE `id` = '" .. result .. "';")
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
        end
        return TRUE
end

My miss :(.
 
@Up

PHP:
[08/08/2009 13:50:01] Lua Script Error: [TalkAction Interface] 
[08/08/2009 13:50:01] data/talkactions/scripts/mtibia/points.lua:onSay
[08/08/2009 13:50:01] 
[08/08/2009 13:50:01] data/talkactions/scripts/mtibia/points.lua:5: attempt to concatenate local 'result' (a table value)
[08/08/2009 13:50:01] stack traceback:
[08/08/2009 13:50:01] data/talkactions/scripts/mtibia/points.lua:5: in function <data/talkactions/scripts/mtibia/points.lua:1>
 
Lua:
function onSay(cid, words, param)
        local t = string.explode(param, ",")
        if t[1] ~= nil and t[2] ~= nil then
                local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_ponts` + "..t[2].." WHERE `id` = '" .. result.account_id .. "';") 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
        end
        return TRUE
end

Shawak, read the error messages...

There should be the fix.
 
kito2, what server you use?

tfs0.3.4pl2

Lua:
function onSay(cid, words, param)
        local t = string.explode(param, ",")
        if t[1] ~= nil and t[2] ~= nil then
                local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_ponts` + "..t[2].." WHERE `id` = '" .. result.account_id .. "';") 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is offline or does not exist.")
        end
        return TRUE
end

Shawak, read the error messages...

There should be the fix.

Lua:
 ‎[08/08/2009 21:03:39] Lua Script Error: [TalkAction Interface] 
[08/08/2009 21:03:39] data/talkactions/scripts/mtibia/points.lua:onSay
[08/08/2009 21:03:39] 
[08/08/2009 21:03:39] data/talkactions/scripts/mtibia/points.lua:5: attempt to concatenate field 'account_id' (a nil value)
[08/08/2009 21:03:39] stack traceback:
[08/08/2009 21:03:39] data/talkactions/scripts/mtibia/points.lua:5: in function <data/talkactions/scripts/mtibia/points.lua:1>
 
Lua:
function onSay(cid, words, param)
        local t = string.explode(param, ",")
        if t[1] ~= nil and t[2] ~= nil then
                local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_ponts` + "..t[2].." WHERE `id` = '" ..result:getDataString("account_id").. "';")
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
                result:free()
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command Requires Two Params.")
        end
        return TRUE
end

My Mistake, fix...
 
Lua:
  function onSay(cid, words, param)
        local t = string.explode(param, ",")
        if t[1] ~= nil and t[2] ~= nil then
                local result = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '"..t[1].."';")
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + "..t[2].." WHERE `id` = '" ..result:getDataString("account_id").. "';")
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, ""..t[1].." has received "..t[2].." premium points.")
                result:free()
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command Requires Two Params.")
        end
        return TRUE
end

There is fixed.
Gonna try now, there was a premium_ponts xD
 
Back
Top