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

Lua Some Scripts Not Working Correctly

Alyhide

Banned User
Joined
Aug 21, 2010
Messages
1,945
Reaction score
54
Location
Switzerland
Hello, I am here to give you some scripts that don't work and you can fix them. Simple? mmkay..

Rep++

First // Reports.lua : Problem on line 17 and line 5

PHP:
local config = {
	expireReportsAfterReads = getConfigInfo('expireReportsAfterReads')
}

function onSay(cid, words, param, channel)
	if(isNumber(param) == TRUE) then
		local reportId = tonumber(param)
		local report = db.getResult("SELECT * FROM `server_reports` WHERE `id` = " .. reportId)
		if(report:getID() ~= -1) then
			db.executeQuery("UPDATE `server_reports` SET `reads` = `reads` + 1 WHERE `id` = " .. reportId)
			doPlayerPopupFYI(cid, "Report no. " .. reportId .. "\n\nName: " .. getPlayerNameByGUID(report:getDataInt("player_id")) .. "\nPosition: [X: " .. report:getDataInt("posx") .. " | Y: " .. report:getDataInt("posy") .. " | Z: " .. report:getDataInt("posz") .. "]\nDate: " .. os.date("%c", report:getDataInt("timestamp")) .. "\nReport:\n" .. report:getDataString("report"))
			report:free()
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Report with no. " .. reportId .. " does not exists.")
		end
	else
		local list = db.getResult("SELECT `id`, `player_id` FROM `server_reports` WHERE `reads` < " .. config.expireReportsAfterReads)
		if(list:getID() ~= -1) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New reports:")
			repeat
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, list:getDataInt("id") .. ", by " .. getPlayerNameByGUID(list:getDataInt("player_id")) .. ".")
			until not list:next()
			list:free()
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no active reports.")
		end
	end

	return TRUE
end

Second // Broadcast Command (Doesn't Show Broadcast) :

PHP:
function onSay(cid, words, param, channel)
	if(param == "") then
		return TRUE
	end

	doPlayerBroadcastMessage(cid, param)
	return TRUE
end

Third // Monster Not Appearing :

The monster, Strong Freak is not appearing on my map, he is in my monster folder and in monsters.xml but he will just not appear..


If you fix those, you will get Rep++

:)
 
Broadcast
Lua:
function onSay(cid, words, param, channel)
	if(param == '') then
		return true
	end

	doPlayerBroadcastMessage(cid, param)
	return true
end

About the 3rd, you put the monster in your map and it doesnt spawn? or you cant /m it?
 
about strong freak, if your trying to make a forgotten legend map... i know the bug...
on monsters.xml, make sure, the creature name is Strong Freak, the filename is correct. then go to the file, and make sure the name is Strong Freak.
I had that problem too^^
 
about strong freak, if your trying to make a forgotten legend map... i know the bug...
on monsters.xml, make sure, the creature name is Strong Freak, the filename is correct. then go to the file, and make sure the name is Strong Freak.
I had that problem too^^

Yay!! thanks Rep++ :)
 
WOAHHH 600 POSTS ;o
btw NP ^^
And u are working on a forgotten legend map? if so i have some scripts of it if u need....
i have bosses (bat digga etcs) - just need put correct loot rate, because loot rate is kind over :S
 
WOAHHH 600 POSTS ;o
btw NP ^^
And u are working on a forgotten legend map? if so i have some scripts of it if u need....
i have bosses (bat digga etcs) - just need put correct loot rate, because loot rate is kind over :S

sure, just pm me with some stuff if you have it :)
 
Lua:
function onSay(cid, words, param, channel)
	if(param == '') then
		return true
	end
 
	doPlayerBroadcastMessage(cid, param)
	return true
end

Still does not work =/
 
first
Lua:
local config = { 
    expireReportsAfterReads = 2   -- number of read then the report is deleted
} 

function onSay(cid, words, param, channel) 
    if(isNumber(param) == TRUE) then 
        local reportId = tonumber(param) 
        local report = db.getResult("SELECT * FROM `server_reports` WHERE `id` = " .. reportId) 
        if(report:getID() ~= -1) then 
            db.executeQuery("UPDATE `server_reports` SET `reads` = `reads` + 1 WHERE `id` = " .. reportId) 
            doPlayerPopupFYI(cid, "Report no. " .. reportId .. "\n\nName: " .. getPlayerNameByGUID(report:getDataInt("player_id")) .. "\nPosition: [X: " .. report:getDataInt("posx") .. " | Y: " .. report:getDataInt("posy") .. " | Z: " .. report:getDataInt("posz") .. "]\nDate: " .. os.date("%c", report:getDataInt("timestamp")) .. "\nReport:\n" .. report:getDataString("report")) 
            report:free() 
        else 
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Report with no. " .. reportId .. " does not exists.") 
        end 
    else 
        local list = db.getResult("SELECT `id`, `player_id` FROM `server_reports` WHERE `reads` < " .. config.expireReportsAfterReads) 
        if(list:getID() ~= -1) then 
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New reports:") 
            repeat 
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, list:getDataInt("id") .. ", by " .. getPlayerNameByGUID(list:getDataInt("player_id")) .. ".") 
            until not list:next() 
            list:free() 
        else 
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There are no active reports.") 
        end 
    end 

    return TRUE 
end


Broad cast
Lua:
function onSay(cid, words, param, channel) 
    if param == '' then
		return doPlayerSendTextMessage(cid,27,"Param required.")
	end
	doBroadcastMessage(getCreatureName(cid).."["..getPlayerLevel(cid).."] : "..tostring(param))
    return true 
end
 
It broadcasts, it shows in console, Nova Broadcasts : Hello but it dosen't broadcast to any of the players. it dosen't show up in red on the screen ect. i used your script doggynub =/
 
Are all of your problems solved, or are there any unsolved still?


little update plx.
If unsolved, please list which. (lazy to read whole thread)

If all solved, let me knowwwww. D:
 
Another Error : When player dies, it says "Unkown Column 'time' in 'order clause'
Playerdeath.lua
I use MYSQL

Lua:
local config = {
	deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
	sqlType = getConfigInfo('sqlType'),
	maxDeathRecords = getConfigInfo('maxDeathRecords')
}

config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL

function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
	if(config.deathListEnabled ~= TRUE) then
		return
	end

	local hitKillerName = "field item"
	local damageKillerName = ""
	if(lastHitKiller ~= FALSE) then
		if(isPlayer(lastHitKiller) == TRUE) then
			hitKillerName = getPlayerGUID(lastHitKiller)
		else
			hitKillerName = getCreatureName(lastHitKiller)
		end

		if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
			if(isPlayer(mostDamageKiller) == TRUE) then
				damageKillerName = getPlayerGUID(mostDamageKiller)
			else
				damageKillerName = getCreatureName(mostDamageKiller)
			end
		end
	end

	db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
	local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
	if(rows:getID() ~= -1) then
		local amount = rows:getRows(true) - config.maxDeathRecords
		if(amount > 0) then
			if(config.sqlType == DATABASE_ENGINE_SQLITE) then
				for i = 1, amount do
					db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
				end
			else
				db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
			end
		end
	end
end


@ no, only 1 of them is solved, that's the one with the spawning monsters
 
Back
Top