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

Talkaction, /addpoints {bug, help} (Solved)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
I downloaded this script. It add points. The problem is:
It is not adding, it is replacing points

LUA:
function onSay(cid, words, param)
	  local Data = string.explode(param, ",")
	  if Data then
		  local Target = db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(Data[1]) .. ";")
		  if Data then
			  if (Target:getID() ~= -1) then
				  if Data[2] then
					  if (words:sub(2, 2) == "a") then
						  if isNumber(Data[2]) == TRUE then
							  db.executeQuery("UPDATE `accounts` SET `premium_points` = ".. Data[2] .." WHERE `accounts`.`id` = ".. getAccountIdByName(Data[1]) .." LIMIT 1;")
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Added ".. Data[2] .." points to player ".. Data[1] ..".")
						  else
							  doPlayerSendCancel(cid, "Insert only numbers.")
						  end
					  else
						  doPlayerSendCancel(cid, "To check the points do not need to enter amount of points.")
					  end
				  else
					  if (words:sub(2, 2) == "c") then
						  if premiumPointsByName(Data[1]) == 0 then
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The player ".. Data[1] .." do not have points.")
						  elseif premiumPointsByName(Data[1]) == 1 then
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." points.")
						  else
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." points.")
						  end
					  else
						  doPlayerSendCancel(cid, "Enter the amount of points.")
					  end
				  end
			  else
				  doPlayerSendCancel(cid, "This player ".. Data[1] .." do not exist.")
			  end
		  end
	  else
		  doPlayerSendCancel(cid, "Insert a name.")
	  end
	  return TRUE
  end





EDIT2:

Working 100% now.

LUA:
function onSay(cid, words, param)
	local Data = string.explode(param, ",")
	if Data then
		local Target = db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(Data[1]) .. ";")
		if (Target:getID() ~= -1) then
			if Data[2] then
				if (words:sub(2, 2) == "a") then
					if isNumber(Data[2]) == TRUE then
						db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + ".. Data[2] .." WHERE `accounts`.`id` = ".. getAccountIdByName(Data[1]) .." LIMIT 1;")
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Was added ".. Data[2] .." points to ".. Data[1] ..".")
					else
						doPlayerSendCancel(cid, "Enter only numbers.")
					end
				else
					doPlayerSendCancel(cid, "To check the amount of points not need to enter numbers.")
				end
			else
				if (words:sub(2, 2) == "c") then
					if premiumPointsByName(Data[1]) == 0 then
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." has no points.")
					elseif premiumPointsByName(Data[1]) == 1 then
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." point.")
					else
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." points.")
					end
				else
					doPlayerSendCancel(cid, "Enter the amount of points.")
				end
			end
		else
			doPlayerSendCancel(cid, "This player ".. Data[1] .." does not exist.")
		end
	else
		doPlayerSendCancel(cid, "Enter a name.")
	end
	return TRUE
end
 
Last edited:
LUA:
function onSay(cid, words, param)
	local Data = string.explode(param, ',')
	if Data then
		local Target = db.getResult("SELECT account_id FROM players WHERE name = '" .. db.escapeString(Data[1]) .. " LIMIT 1")
		if (Target:getID() ~= -1) then
			if Data[2] then
				if words:sub(2, 2) == 'a' then
					if tonumber(Data[2]) then
						db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. Data[2] ..' WHERE id='.. Target:getDataInt('account_id'))
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Added '.. Data[2] ..' points to player '.. Data[1] ..'.')
					else
						doPlayerSendCancel(cid, 'Insert only numbers.')
					end
				else
					doPlayerSendCancel(cid, 'To check the points do not need to enter amount of points.')
				end
			elseif words:sub(2, 2) == 'c' then
				local v = premiumPointsByName(Data[1])
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'The player '.. Data[1] ..' '..(v==0 and 'doesn\'t have any points.' or 'has '.. v ..' point'..(v==1 and '' or 's'))..'.')
			else
				doPlayerSendCancel(cid, 'Enter the amount of points.')
			end
			Target:free()
		else
			doPlayerSendCancel(cid, 'This player '.. Data[1] ..' do not exist.')
		end
	else
		doPlayerSendCancel(cid, 'Insert a name.')
	end
	return true
end
 
Last edited:
LUA:
function onSay(cid, words, param)
	local Data = string.explode(param, ',')
	if Data then
		local Target = db.getResult("SELECT account_id FROM players WHERE name = '" .. db.escapeString(Data[1]) .. "' LIMIT 1")
		if (Target:getID() ~= -1) then
			if Data[2] then
				if words:sub(2, 2) == 'a' then
					if tonumber(Data[2]) then
						db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. Data[2] ..' WHERE id='.. Target:getDataInt('account_id'))
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Added '.. Data[2] ..' points to player '.. Data[1] ..'.')
					else
						doPlayerSendCancel(cid, 'Insert only numbers.')
					end
				else
					doPlayerSendCancel(cid, 'To check the points do not need to enter amount of points.')
				end
			elseif words:sub(2, 2) == 'c' then
				local v = premiumPointsByName(Data[1])
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'The player '.. Data[1] ..' '..(v==0 and 'doesn\'t have any points.' or 'has '.. v ..' point'..(v==1 and '' or 's'))..'.')
			else
				doPlayerSendCancel(cid, 'Enter the amount of points.')
			end
			Target:free()
		else
			doPlayerSendCancel(cid, 'This player '.. Data[1] ..' do not exist.')
		end
	else
		doPlayerSendCancel(cid, 'Insert a name.')
	end
	return true
end

It's still not adding points, is replacing.
And this error apears when I execute the talkaction.
asasm.jpg
 
Working 100% now.

LUA:
function onSay(cid, words, param)
	local Data = string.explode(param, ",")
	if Data then
		local Target = db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(Data[1]) .. ";")
		if (Target:getID() ~= -1) then
			if Data[2] then
				if (words:sub(2, 2) == "a") then
					if isNumber(Data[2]) == TRUE then
						db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + ".. Data[2] .." WHERE `accounts`.`id` = ".. getAccountIdByName(Data[1]) .." LIMIT 1;")
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Was added ".. Data[2] .." points to ".. Data[1] ..".")
					else
						doPlayerSendCancel(cid, "Enter only numbers.")
					end
				else
					doPlayerSendCancel(cid, "To check the amount of points not need to enter numbers.")
				end
			else
				if (words:sub(2, 2) == "c") then
					if premiumPointsByName(Data[1]) == 0 then
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." has no points.")
					elseif premiumPointsByName(Data[1]) == 1 then
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." point.")
					else
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." points.")
					end
				else
					doPlayerSendCancel(cid, "Enter the amount of points.")
				end
			end
		else
			doPlayerSendCancel(cid, "This player ".. Data[1] .." does not exist.")
		end
	else
		doPlayerSendCancel(cid, "Enter a name.")
	end
	return TRUE
end
 
Last edited:
Working 100% now.

LUA:
function onSay(cid, words, param)
	  local Data = string.explode(param, ",")
	  if Data then
		  local Target = db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(Data[1]) .. ";")
		  if Data then
			  if (Target:getID() ~= -1) then
				  if Data[2] then
					  if (words:sub(2, 2) == "a") then
						  if isNumber(Data[2]) == TRUE then
							  db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + ".. Data[2] .." WHERE `accounts`.`id` = ".. getAccountIdByName(Data[1]) .." LIMIT 1;")
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Was added ".. Data[2] .." points to ".. Data[1] ..".")
						  else
							  doPlayerSendCancel(cid, "Enter only numbers.")
						  end
					  else
						  doPlayerSendCancel(cid, "To check the amount of points not need to enter numbers.")
					  end
				  else
					  if (words:sub(2, 2) == "c") then
						  if premiumPointsByName(Data[1]) == 0 then
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." has no points.")
						  elseif premiumPointsByName(Data[1]) == 1 then
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." point.")
						  else
							  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." points.")
						  end
					  else
						  doPlayerSendCancel(cid, "Enter the amount of points.")
					  end
				  end
			  else
				  doPlayerSendCancel(cid, "This player ".. Data[1] .." does not exist.")
			  end
		  end
	  else
		  doPlayerSendCancel(cid, "Enter a name.")
	  end
	  return TRUE
  end

Why double data checking?

LUA:
function onSay(cid, words, param)
	local Data = string.explode(param, ",")
	if Data then
		local Target = db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. db.escapeString(Data[1]) .. ";")
		if (Target:getID() ~= -1) then
			if Data[2] then
				if (words:sub(2, 2) == "a") then
					if isNumber(Data[2]) == TRUE then
						db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + ".. Data[2] .." WHERE `accounts`.`id` = ".. getAccountIdByName(Data[1]) .." LIMIT 1;")
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Was added ".. Data[2] .." points to ".. Data[1] ..".")
					else
						doPlayerSendCancel(cid, "Enter only numbers.")
					end
				else
					doPlayerSendCancel(cid, "To check the amount of points not need to enter numbers.")
				end
			else
				if (words:sub(2, 2) == "c") then
					if premiumPointsByName(Data[1]) == 0 then
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." has no points.")
					elseif premiumPointsByName(Data[1]) == 1 then
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." point.")
					else
						doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player ".. Data[1] .." have ".. vipDaysByName(Data[1]) .." points.")
					end
				else
					doPlayerSendCancel(cid, "Enter the amount of points.")
				end
			end
		else
			doPlayerSendCancel(cid, "This player ".. Data[1] .." does not exist.")
		end
	else
		doPlayerSendCancel(cid, "Enter a name.")
	end
	return TRUE
end
 
Back
Top