• 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 [CHECK] Useful Ot Scripts

gigastar

Member
Joined
Jan 25, 2009
Messages
252
Reaction score
15
Here's a few scripts that might be useful to people. Ill add script to this page as I make/think of them.

playerDB.lua
Code:
!set noob, health, 100
Lua:
--function setPlayerSkill(cid, skill, amount)
--return db.executeQuery("UPDATE `players_skills` SET `".. skill .. "` = ".. amount .." WHERE `name` = ".. getPlayerAccount(cid).."")
--end

--function setPlayerValue(cid, value, amount)
--return db.executeQuery("UPDATE `players` SET `".. value .. "` = ".. amount .." WHERE `name` = ".. getPlayerAccount(cid).."")
--end

function onSay(cid, words, param, channel)
if (words == "!set") then -- if the command is said
if not getPlayerAccess(cid) > 3 then
doPlayerSendCancel(cid, "You cannot execute this talkaction")
return false
end

if isPlayer(param) then
if (playerExists(param)) then --If the second word is a player
t = string.explode(param, ",") --reconizse seperate params with comma

t[1] = attribute --what to change
t[2] = amount --what to change it to

if (attribute == true) then
if not (amount == true) then
	doPlayerSendCancel(cid, "You must type an amount")
return false
end
	local getInfo = db.getResult('SELECT `value` FROM `players_skills` WHERE `key` = '..attribute..' and `id` = '..getPlayerIdByName(param)..'')
	local getInfo2 = db.getResult('SELECT `value` FROM `players` WHERE `key` = '..attribute..' and `id` = '..getPlayerIdByName(param)..'')
	if (getInfo == true) then
		setPlayerSkill(cid, attribute, amount)
		doPlayerSendTextMessage(cid, 22, "You have successfully changed "..getPlayerName(param).."('s) "..attribute.." skill to "..amount.."")
	else
	if (getInfo2 == true) then
		setPlayerValue(param, attribute, amount)
		doPlayerSendTextMessage(cid, 22, "You have successfully changed "..getPlayerName(param).."('s) "..attribute.." value to "..amount.."")
	else
		doPlayerSendCancel(cid, "This is not a value that can be set in the database.")
	return false
end
end
else
	doPlayerSendCancel(cid, "You must type and attribute from the database to change.")
return false
end
else
	doPlayerSendCancel(cid, "This player does not exist.")
return false
end
end
end
end

updateDB.lua
Code:
!database server_motd, text, Welcome to my server!
Lua:
--function updateDatabase(location, value, amount[, cid])
--return db.executeQuery("UPDATE `"..location.."` SET `".. value .. "` = ".. amount .." WHERE `name` = ".. getPlayerAccount(cid).."")
--end

local db_locations = {"account", "account_viplist", "players", "player_deaths", "player_depotitems", "player_items", "player_namelocks", "player_skills", "player_spells", "player_storage", "player_viplist",  "killers", "player_killers", "environement_killers", "houses", "house_auctions", "house_list", "house_data", "tiles", "tile_items", "guilds", "guild_invites", "guild_ranks", "bans", "global_storage", "server_config", "server_motd", "server_record", "server_reports"}

function onSay(cid, words, param, channel)
if (param == "!database") then
if not getPlayerAccess(cid) >= 6 then
	doPlayerSendCancel(cid, "You cannot execute this talkaction.")
return false
end

t = string.explode(param, ",")

t[1] = db_location
t[2] = db_value
t[3] = amount
t[4] = player --not required

if (db_location == db_locations) then
	if (db_value == true) then
		if (amount == true) then
			if (player == true) then
			if	(updateDatabase(db_location, db_value, amount, player) == true)
				doPlayerSendTextMessage(cid, 22, "You have succefully changed the database.")
			else
				doPlayerSendCancel(cid, "You did not enter the command correctly. !database players_skills, fist, 10, NoobsOnMyServName")
			return false
			end
			else
			if (updateDatabase(db_location, db_value, amount) == true) then
				doPlayerSendTextMessage(cid, 22, "You have succesfully changed the database.")
			else
				doPlayerSendCancel(cid, "You did not enter the command correctly. !database server_motd, text, THIS IS THE NEW MOTD!")
			return false
			end
			end
		else
			doPlayerSendCancel(cid, "You must enter an amount to change the value to.")
		return false
		end
	else
		doPlayerSendCancel(cid, "You must enter a database value to change.")
	return false
	end
else
	doPlayerSendCancel(cid, "You must type the name of a database table.")
return false
end
end
end

serverinfo.lua
Lua:
--You can take out the scripts in talkactions for: !Uptime, !pvp they are included in the script.--
local config = {
	rateExperience = getConfigInfo('rateExperience'),
	rateSkill = getConfigInfo('rateSkill'),
	rateLoot = getConfigInfo('rateLoot'),
	rateMagic = getConfigInfo('rateMagic'),
	rateSpawn = getConfigInfo('rateSpawn'),
	protectionLevel = getConfigInfo('protectionLevel'),
	stages = getBooleanFromString(getConfigInfo('experienceStages')),
	fragToRedSkill = getConfigInfo('fragsToRedSkull'),
	fragsSecondToRedSkull = getConfigInfo('fragsSecondToRedSkull'),
	fragsThirdToRedSkull = getConfigInfo('fragsThirdToRedSkull'),
	maxPlayers = getConfigInfo('maxPlayers')
}

local MOTD_FROM_CONFIG = false -- false for custom, true for config MOTD --
local message_of_the_day = "Welcome to the server." -- If you want custom MOTD for this script--
local motd = getConfigInfo('motd') --If you want to use config MOTD--

local worlds = {
	[WORLD_TYPE_NO_PVP] = "No-PVP",
	[WORLD_TYPE_PVP] = "PVP",
	[WORLD_TYPE_PVP_ENFORCED] = "PVP-Enforced"
}

function onSay(cid, words, param, channel)
---------World type config---------
	local world = worlds[getWorldType()]
	if(not world) then
		return true
	end
-----------Uptime config----------
local tmp = getWorldUpTime()
local hours = math.ceil(tmp / 3600) - 1
local minutes = math.ceil((tmp - (3600 * hours)) / 60)
if(minutes == 60) then
	minutes = 0
	hours = hours + 1
end
-----------Server info----------
local countPlayers = 0
for i, pid in ipairs(getPlayersOnline()) do   
if isPlayer(pid) 
countPlayers = countPlayers + 1 
end 
end

	local exp = config.rateExperience
	if(config.stages) then
		exp = getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
	end
	------part of message--------
	skullinfo = "Daily kills to redskull:"..config.fragsToRedSkull.."\nWeekly kills to redskull:"..config.fragsSecondToRedSkull.."\nMonthly kills to redskull:"..config.fragsThirdToRedSkull..""
	----------Message------------
	text = "[Server Information]\nExperience rate: x" .. exp .. "\nSkill rate: x" .. config.rateSkill .. "\nLoot rate: x" .. config.rateLoot .. "\nMagic rate: x" .. config.rateMagic .. "\nSpawn rate: x" .. config.rateSpawn .. "\nProtection level: " .. config.protectionLevel.. "\nWebsite: Ot.jocce.nu \nTime:"..getWorldTime().."/nPlayers Online: "..countPlayers.."/ "..max_players.."\nWorld:"..world.."\nServer Uptime:"..hours.." hours and "..minutes.." minutes \n \n [SKULL INFORMATION]"..skullinfo..""
	--------Part of script that send message-------------
	local item_in_corner = {8977, 2141}
	if math.random(1, 2) == 1 then
	doShowTextDialog(cid, 8977,text)
	else
	doShowTextDialog(cid, 2141,text)
	end
	if (MOTD_FROM_CONFIG == false) then
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT_GREEN, message_of_the_day)
	else
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT_GREEN, motd)
	end
	return true
end

checkskill.lua
Code:
!skill fist
Lua:
function onSay(cid, words, param, channel)
if (words == "!skill") then
	if (param == true) then
		if not getPlayerSkillLevel(cid, param) then
		doPlayerSendCancel(cid, "You must type the name of a skill: fist, club, sword, axe, distance, sheild, or fishing.")
	return false
	end
	if (param == "1") or (param == "fist") then
		tries_left = getPlayerRequiredSkillTires(cid, SKILL_FIST) - getPlayerSkillTries(cid, SKILL_FIST)
		doPlayerPopupFYI(cid, "[SKILL FIST]\nLevel:"..getPlayerSkillLevel(cid, SKILL_FIST).."\nSkilltries:"..getPlayerSkillTries(cid, SKILL_FIST).."\nTries left:"..tries_left.."")
	elseif (param == "2") or (param == "club") then
		tries_left = getPlayerRequiredSkillTires(cid, SKILL_CLUB) - getPlayerSkillTries(cid, SKILL_CLUB)
		doPlayerPopupFYI(cid, "[SKILL CLUB]\n"..getPlayerSkillLevel(cid, SKILL_CLUB).."\nSkilltries:"..getPlayerSkillTries(cid, SKILL_CLUB).."\nTries left:"..tries_left.."")
	elseif (param == "3") or (param == "sword") then
		tries_left = getPlayerRequiredSkillTires(cid, SKILL_SWORD) - getPlayerSkillTries(cid, SKILL_SWORD)
		doPlayerPopupFYI(cid, "[SWORD]\nLevel:"..getPlayerSkillLevel(cid, SKILL_SWORD).."\nSkilltries:"..getPlayerSkillTries(cid, SKILL_SWORD).."\nTris left:"..tries_left.."")
	elseif (param == "4") or (param == "axe") then
		tries_left = getPlayerRequiredSkillTires(cid, SKILL_AXE) - getPlayerSkillTries(cid, SKILL_AXE)
		doPlayerPopupFYI(cid, "[SKILL AXE]\nLevel:"..getPlayerSkillLevel(cid, SKILL_AXE).."\nSkilltries:"..getPlayerSkillTries(cid, SKILL_AXE).."\nTries left:"..tries_left.."")
	elseif (param == "5") or (param == "distance") or (param == "dis") then
		tries_left = getPlayerRequiredSkillTires(cid, SKILL_DISTANCE) - getPlayerSkillTries(cid, SKILL_DISTANCE)
		doPlayerPopupFYI(cid, "[SKILL DISTANCE]\nLevel:"..getPlayerSkillLevel(cid, SKILL_DISTANCE).."\nSkilltries:"..getPlayerSkillTries(cid, SKILL_DISTANCE).."\nTries left:"..tries_left.."")
	elseif (param == "6") or (param == "shield") or (param == "shielding") then
		tries_left = getPlayerRequiredSkillTires(cid, SKILL_SHIELD) - getPlayerSkillTries(cid, SKILL_SHIELD)
		doPlayerPopupFYI(cid, "[SKILL SHIELD]\nLevel:"..getPlayerSkillLevel(cid, SKILL_SHIELD).."\nSkilltries:"..getPlayerSkillTries(cid, SKILL_SHIELD).."\nTries left:"..tries_left.."")
	elseif (param == "7") or (param == "fish") or (param == "fishing") then
		tries_left = getPlayerRequiredSkillTires(cid, SKILL_FISHING) - getPlayerSkillTries(cid, SKILL_FISHING)
		doPlayerPopupFYI(cid, "[SKILL FISHING]\nLevel:"..getPlayerSkillLevel(cid, SKILL_FISHING).."\nSkilltries:"..getPlayerSkillTries(cid, SKILL_FISHING).."\nTries left:"..tries_left.."")
	end
	else
	doPlayerSendCancel(cid, "You must type the name of a skill")
return false
end
end
end

itemInfo.lua
Code:
!item spiked sword
Lua:
function onSay(cid, words, param, channel)
if (words == "!info") then
	if (getThing(param) == true) then --If the param is a thing

	local description = getItemDescriptionsById(param)
	local weight = getItemWeight(param, true)
	local attack = getItemAttack(param)
	local extra_attack = getItemExtraAttack(param)
	local defence = getItemDefense(param)
	local extra_defence = getItemExtraDefense(param)
	local armor = getItemArmor(param)
	local range = getItemShootRange(param)
	local name = getItemIdByName(param)
	---------Set this up so the first thing is the first thing showing in game...thats how it is...So if u want weight first, put it before description...
	if (description == true) then
		itemDesc = "\nDescription: "..description
		text = text + itemDesc
	end
	
	if (weight == true) then
		itemWeight = "\nWeight: "..weight
		text = text + itemWeight
	end
	
	if (attack == true) then
		itemAttack = "\nAttack: "..attack
		text = text + itemAttack
	end
	
	if (extra_attack == true) then
		itemExAttack = "\nExt Attack: "..extra_attack
		text = text + itemExAttack
	end
	
	if (defence == true) then
		itemDef = "\nDefence: "..defence
		text = text + itemDef
	end
	
	if (extra_defence == true) then
		itemExDef = "\nExt Defence: "..defence
		text = text + itemExDef
	end
	
	if (armor == true) then
		itemArmor = "\nArmor: "..armor
		text = text + itemArmor
	end
	
	if (range == true) then
		itemRange = "\nRange: "..range
		text = text + itemRange
	end
	
	doShowTextDialog(cid, getItemIdByName(param), text)
else
	doPlayerSendCancel(cid, "You can only look up item info with this command.")
return false
end
end
end

checkbags.lua --untested--
Code:
!check playername
Lua:
local backpack = {}
local backpack2 = {}
local backpack3 = {}

function onSay(cid, words, param, channel)
if (param == "") then
	doPlayerSendCancel(cid, "command required name")
return false
end

if isPlayer(param) then

local backpack = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)

if (backpack == true) then
	if not isContainer(backpack) then
		doPlayerSendCancel(cid, "You must have a container item.")
		return false
	else
	for i, slot in ipairs(getContainerItem(backpack))
		if isItemMoveable(item.itemid) then
			table.insert(backpack, item.itemid)
			table.insert(backpack, item.amount)
		elseif isContainer(item.itemid) then
			table.insert(backpack2, item.itemid)
		end
	end
end
end

local backpack_2 = table.find(backpack2, item.itemid)
if (backpack_2 == true) then
	for i, itemid in ipairs(backpack_2) do
		if isItemMoveable(item.itemid) then
			table.insert(items, item.itemid)
			table.insert(items, item.amount)
		elseif isContainer(item.itemid) then
			table.insert(backpack3, item.itemid)
		end
	end
end
local backpack_3 = table.find(backpack3, item.itemid)

if (backpack == true) then
local text = "[PLAYER ITEMS]:\n"
for i, v in ipairs(backpack) do
	v = itemid, amount
	itemid = getItemNameById(itemid)
		text = text + "\n"..v
end
if (backpack_3 == true) then
for i, v in ipairs(backpack_3) do
	v = itemid, amount
	itemid = getItemNameById(itemid)
		text = text + "\n"..v
end
doShowTextDialog(cid, 2157, text)
end
end
end

dropEvent.lua
Code:
!dropevent
Lua:
local items = {}

local player_area = {
tl = {x = 1000, y = 1000, z = 7},
br = {x = 1000, y = 1000, z = 7},
area = tl,br
}

function onSay(cid, words, param, channel)
if getPlayerAccess(cid) < 3 then
	doPlayerSendCancel(cid, "You cannot execute this talkaction.")
return false
end


if (words == "!dropevent") then --This one takes your backpack in backpack slot, and drops the items in it on the ground around you--
	if not isItemContainer(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)) then
		doPlayerSendCancel(cid, "You must have a container with items in your backpack slot.")
	else
		local backpackitems = getContainerItem(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK))
		for i, slot in ipairs(backpackitems) do
			if isItemMoveable(slot).itemid then
				table.insert(items, item.itemid)
				table.insert(items, item.amount)
				doRemoveItem(item.itemid, item.amount)
			end
		end
		
		for i, itemid in ipairs(items) do
		local rand_spot = math.random(player_area.area)
			doCreateItem(itemid, item.amount, rand_spot)
			doSendMagicEffect(rand_spot, math.random(1, 22))
			table.remove(items, item.itemid)
			table.remove(items, item.amount)
		end
		end
	end
end

kickunconnected.lua --globalevent
Lua:
function onThink(cid, intraval)
for i, pid in ipairs(getPlayersOnline()) do
if isPlayer(pid) then
	if not getPlayerIp(pid) then
		doRemoveCreature(pid, true)
end
end
end
end
 
The only real useful script is the last one and maaaaaaaaybe the !serverinfo if you don't have website...
But thanks for the share tho!
 
Back
Top