• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Talkaction] /addpoints

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,265
Reaction score
62
Location
Venezuela
I want it to work.. When i say
/addpoints Kekox, 5
add 5 points in the web...

Here is my script but it does not work..
LUA:
function onSay(cid, words, param, channel)
local t = string.explode(param, ",")
local pname = getPlayerGUIDByName(param)
local pid = getPlayerGUID(pname)
local result = db.getResult("SELECT `id`, `name`, `password`, `premdays`, `lastday`, `email`, `key`, `blocked`, `warnings`, `group_id`, `page_lastday`, `email_new`, `email_new_time`, `created`, `rlname`, `location`, `page_access`, `email_code`, `next_email`, `premium_points` FROM `accounts` WHERE `id` = '"..player.."'")
local player = db.getResult("SELECT `account_id` FROM `players` WHERE `id` = '"..pid.."'")
local pacc = db.getResult("SELECT `name` FROM `accounts` WHERE `id` = '"..player.."'")

      if(not t[2]) then
             doPlayerSendTextMessage(cid, 27, "Nesesitas poner el numero de puntos que agregaras. Ejemplo: /addpoints Kekox, 5.")
      return TRUE
      end
      
      if isPlayer(param) then
         db.executeQuery("UPDATE `accounts` SET  `premium_points` =  '1' WHERE `id` ="..player..";")
         doPlayerSendTextMessage(cid, 27, "Agregaste "..t[2].." puntos vip a "..pname..".")
      else
          doPlayerSendCancel(cid, "Player not found")
      end
      return TRUE
end

error:
Code:
[14/09/2009 13:03:44] data/talkactions/scripts/addpoints.lua:5: attempt to concatenate global 'player' (a nil value)
[14/09/2009 13:03:44] stack traceback:
[14/09/2009 13:03:44] 	data/talkactions/scripts/addpoints.lua:5: in function <data/talkactions/scripts/addpoints.lua:1>
 
Maybe thats how ou say but it is not the error that i'm looking for fix.. this is the error:
Code:
[14/09/2009 13:03:44] data/talkactions/scripts/addpoints.lua:5: attempt to concatenate global 'player' (a nil value)
[14/09/2009 13:03:44] stack traceback:
[14/09/2009 13:03:44] 	data/talkactions/scripts/addpoints.lua:5: in function <data/talkactions/scripts/addpoints.lua:1>
 
Huh?
Code:
function onSay(cid, words, param, channel)
	local explo = string.explode(param)
	if (not explo[1] or not explo[2]) then
		return true
	end

	local player = getPlayerByName(explo[1])
	if (not player) then
		return true
	end

	db.executeQuery("UPDATE `accounts` SET `premium_points` + ".. explo[2] .." WHERE `id` = ".. getPlayerAccountId(player) ..";")
	return true
end
 
Huh?
Code:
function onSay(cid, words, param, channel)
	local explo = string.explode(param)
	if (not explo[1] or not explo[2]) then
		return true
	end

	local player = getPlayerByName(explo[1])
	if (not player) then
		return true
	end

	db.executeQuery("UPDATE `accounts` SET `premium_points` + ".. explo[2] .." WHERE `id` = ".. getPlayerAccountId(player) ..";")
	return true
end

Fix:
PHP:
local explo = string.explode(param, ",")
 
This one works:

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

It can add points even if player is offline.
 
Kekox's script fixed
LUA:
function onSay(cid, words, param, channel)

local t = string.explode(param, ",")
local pid = getPlayerByNameWildcard(t[1])
local points = tonumber(t[2])

	if(not points) then
		doPlayerSendTextMessage(cid, 27, "Nesesitas poner el numero de puntos que agregaras. Ejemplo: /addpoints Kekox, 5.")
		return TRUE
	end
     
	if(pid ~= 0 or pid ~= nil) then
	points = math.abs(points)
		db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `id` = " .. player .. ";")
		doPlayerSendTextMessage(cid, 27, "Agregaste " .. points .. " puntos vip a " .. t[1] .. ".")
	else
		doPlayerSendCancel(cid, "Player not found")
	end
	return TRUE
end
 
Kekox's script fixed
LUA:
function onSay(cid, words, param, channel)

local t = string.explode(param, ",")
local pid = getPlayerByNameWildcard(t[1])
local points = tonumber(t[2])

	if(not points) then
		doPlayerSendTextMessage(cid, 27, "Nesesitas poner el numero de puntos que agregaras. Ejemplo: /addpoints Kekox, 5.")
		return TRUE
	end
     
	if(pid ~= 0 or pid ~= nil) then
	points = math.abs(points)
		db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `id` = " .. player .. ";")
		doPlayerSendTextMessage(cid, 27, "Agregaste " .. points .. " puntos vip a " .. t[1] .. ".")
	else
		doPlayerSendCancel(cid, "Player not found")
	end
	return TRUE
end

I don't see player declared O.o
 
Back
Top