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

Joined
Jun 19, 2009
Messages
1,852
Reaction score
5
Hello!

I got stuck in this script... well, I made a function (doPlayerAddPoints(cid,points). Now, I want a talkaction like this;

/addpoints <name>, <amount>...

i got this far:

Code:
function onSay(cid, words, param, channel)
        if(param == '') then
                return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        end
       local target = getPlayerByNameWildcard(param)
        if(not target)then
                return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
        end
     ...

help me? :confused: :D

thanks!
 
Code:
function onSay(cid, words, param, channel)
	if param == '' then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
	end

	local t = string.explode(param, ",")
	if #t ~= 2 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You're doing it wrong. Correct usage: " .. words .. " <name>, <amount>")
	end

	local target = getPlayerByNameWildcard(t[1])
	if not target then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
	end

	if not tonumber(t[2]) then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Second parameter has to be a number.")
	end

	doPlayerAddPoints(target, t[2])
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You added " .. t[2] .. " points to " .. getCreatureName(target) .. ".")
	return true
end
 
Code:
function onSay(cid, words, param, channel)
	if param == '' then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
	end

	local t = string.explode(param, ",")
	if #t ~= 2 then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You're doing it wrong. Correct usage: " .. words .. " <name>, <amount>")
	end

	local target = getPlayerByNameWildcard(t[1])
	if not target then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
	end

	if not tonumber(t[2]) then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Second parameter has to be a number.")
	end

	doPlayerAddPoints(target, t[2])
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You added " .. t[2] .. " points to " .. getCreatureName(target) .. ".")
	return true
end

Thanks mate :D

Can you make so the one who receives points gets a message in his default (?) channel saying: "<name> gave you x amount of points!"

thanks again mate
 
Code:
doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(cid) .. " gave you " .. t[2] .. " points!")
I don't know which msgclasses appear in default channel :p
 
[03/06/2010 11:03:24] [Error - TalkAction Interface]
[03/06/2010 11:03:24] data/talkactions/scripts/addpoints.lua:eek:nSay
[03/06/2010 11:03:24] Description:
[03/06/2010 11:03:24] data/talkactions/scripts/addpoints.lua:20: attempt to call global 'doPlayerAddPoints' (a nil value)
[03/06/2010 11:03:24] stack traceback:
[03/06/2010 11:03:24] data/talkactions/scripts/addpoints.lua:20: in function <data/talkactions/scripts/addpoints.lua:1>
 
data/lib/function.lua

Lua:
function doPlayerAddPremiumPoints(cid, points)
    return db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
Back
Top