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

Solution To Pvp Enforced. (FREE KILL)

dukzin

New Member
Joined
Aug 18, 2008
Messages
161
Reaction score
3
Pvp Enforced; Frag Rank. [Bugged]

Frag Ranks Isn't Working.

OnKill;
Code:
function onKill(cid, target, lastHit)
	if isPlayer(target) then
		if getPlayerIp(cid) == getPlayerIp(target) then
			return doPlayerAddExp(cid, -40000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same IP.")
		elseif getPlayerParty(cid) and getPlayerParty(target) and getPlayerParty(cid) == getPlayerParty(target) then
			return doPlayerAddExp(cid, -15000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same Party.")
		end
		return doPlayerAddItem(cid, 2152, 1) and setPlayerStorageValue(cid, 3943, getPlayerStorageValue(cid, 3943)+1) and doPlayerSave(cid)
	end
	return true
end

Frag Rank;
Code:
function getPlayerNameByGUID2(n)
	local ret = 'SQL_ERROR['..n..']'
	local c = db.getResult('SELECT `name` FROM `players` WHERE `id` = '..n..' LIMIT 1;')
	if c:getID() ~= -1 then
		ret = c:getDataString('name')
	end
	c:free()
	return ret
end

local max = 10

function onSay(cid, words, param)
	local letters_to_next, name_now, name, param, l, space = 20, nil, 'Highscore for level\n', param:lower(), nil, nil
	if param == 'frag' or param == 'frags' then
		name = name..'Rank Frags - Nome do Jogador\n'
		local v = db.getResult('SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = 3943 ORDER BY `value` DESC;')
		local i = 0
		repeat
			if i == max or v:getID() == -1 then
				break
			end
			i = i + 1
			name_now, l = getPlayerNameByGUID2(v:getDataInt('player_id')), getPlayerNameByGUID2(v:getDataInt('player_id')):len()
			space = ''
			for i = 1, letters_to_next-l do
				space = space..' '
			end
			if not name_now then
				name_now = 'sql error['..v:getDataInt('player_id')..']'
			end
			name = name..i..'. '..v:getDataInt('value')..'  -  '..name_now..space..' \n'
		until not v:next()
		v:free()
	end
	if name ~= 'Highscore\n' then 
		doPlayerPopupFYI(cid, name)
	end
	return true
end

Screen;
rankzh.jpg



[The Frag Rank Isn't in sequence..] (AS U CAN SEE)
 
Last edited:
fixed i think...
and what abou this errors:
Code:
[16/05/2010 19:36:42] [Error - CreatureScript Interface] 
[16/05/2010 19:36:42] data/creaturescripts/scripts/fragreward.lua:onKill
[16/05/2010 19:36:42] Description: 
[16/05/2010 19:36:42] (internalGetPlayerInfo) Player not found when requesting player info #28

[16/05/2010 19:36:42] [Error - CreatureScript Interface] 
[16/05/2010 19:36:42] data/creaturescripts/scripts/fragreward.lua:onKill
[16/05/2010 19:36:42] Description: 
[16/05/2010 19:36:42] (luaGetPlayerParty) Player not found

SCRIPT:
Code:
function onKill(cid, target, lastHit)
	if getPlayerIp(cid) == getPlayerIp(target) then
		return doPlayerAddExp(cid, -40000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same IP.")
	elseif getPlayerParty(cid) == getPlayerParty(target) then
		return doPlayerAddExp(cid, -5000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same Party.")
	end
    return doPlayerAddItem(cid, 2152, 1) and setPlayerStorageValue(cid, 3943, getPlayerStorageValue(cid, 3943)+1) 
end
 
Code:
function onKill(cid, target, lastHit)
	if isPlayer(target) then
		if getPlayerIp(cid) == getPlayerIp(target) then
			return doPlayerAddExp(cid, -40000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same IP.")
		elseif getPlayerParty(cid) and getPlayerParty(target) and getPlayerParty(cid) == getPlayerParty(target) then
			return doPlayerAddExp(cid, -15000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same Party.")
		end
		return doPlayerAddItem(cid, 2152, 1) and setPlayerStorageValue(cid, 3943, getPlayerStorageValue(cid, 3943)+1)
	end
	return true
end
 
Last edited:
i think that is working,
let's wait somethime and see the result...
another thing..

ERROR: (WHEN I Say '!ranks Frags'
Code:
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).
[16/05/2010 20:15:14] Error during getDataInt(play er_id).

SCRIPT:
Code:
function getPlayerNameByGUID2(n)
        local c = db.getResult("SELECT `name` FROM `players` WHERE `id` = "..n..";")
        if c:getID() == -1 then
                return "SQL_ERROR["..n.."]"
        end
                return c:getDataString("name")
        end

function onSay(cid, words, param)
        local max = 10
        local letters_to_next = 20

local skills = {
        ['fist'] = 0,
        ['club'] = 1,
        ['sword'] = 2,
        ['axe'] = 3,
        ['distance'] = 4,
        ['shielding'] = 5,
        ['fishing'] = 6,
        ['dist'] = 4,
        ['shield'] = 5,
        ['fish'] = 6,
}
        local name_now
        local name = "Highscore for level\n"
        local rkn = 0
        local no_break = 0
                param = string.lower(param)
                dofile('config.lua')
    if param == "" or param == "level" and ( param ~= "magic" and param == "ml") and skills[param] == nil then
                name = name.."\n"
                name = name.."Rank Level - Nome do Jogador\n"
        local v = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` <= 2 ORDER BY `experience` DESC LIMIT 0,"..(max)..";")
        repeat
                no_break = no_break +1
        if v:getID() == -1 then
        break
        end
                rkn = rkn+1
                name_now, l = v:getDataString("name"), string.len(v:getDataString("name"))
                space = ""
        for i=1, letters_to_next-l do
                space = space.." "
        end
                name = name..rkn..". "..v:getDataInt("level") .."  -  "..name_now..space.." ".."\n" 
        if no_break >= 20 then
        break
        end
        until v:next() == false

        elseif param == "magic" or param == "ml" then
                name = name.."\n"
                name = name.."Rank Magic - Nome do Jogador\n"
        local v = db.getResult("SELECT `name`, `level`, `maglevel` FROM `players` WHERE `group_id` <= 2 ORDER BY `maglevel` DESC LIMIT 0,"..(max)..";")
        repeat
        if v:getID() == -1 then
        break
        end
                rkn = rkn+1
                name_now, l = v:getDataString("name"), string.len(v:getDataString("name"))
                space = ""
        for i=1, letters_to_next-l do
                space = space.." "
        end
                name = name..rkn..". "..v:getDataInt("maglevel").."  -  "..name_now..space.." ".." ".."".."\n" 
        until v:next() == false

        elseif param == "frag" or param == "frags" then
                name = name.."\n"
                name = name.."Rank Frags - Nome do Jogador\n"
        local v = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = 3943 ORDER BY `value` DESC;")
        local kk = 0

        repeat
        if kk == max or v:getID() == -1 then
        break
        end
                kk = kk+1
                name_now, l = getPlayerNameByGUID2(v:getDataInt("player_id")), string.len(getPlayerNameByGUID2(v:getDataInt("play er_id")))
                space = ""
        for i=1, letters_to_next-l do
                space = space.." "
        end
        if name_now == nil then
                name_now = 'sql error['..v:getDataInt("player_id")..']'
        end
                name = name..kk..". "..v:getDataInt("value").."  -  "..name_now..space.." \n"
        until v:next() == false

        elseif skills[param] ~= nil then
                name = name.."\n"
                name = name.."Rank "..param.." fighting - Nome do Jogador\n"
        local v = db.getResult("SELECT `player_id`, `value` FROM `player_skills` WHERE `skillid` = "..skills[param].." ORDER BY `value` DESC;")
        local kk = 0

        repeat
        if kk == max or v:getID() == -1 then
        break
        end
                kk = kk+1
                name_now, l = getPlayerNameByGUID2(v:getDataInt("player_id")), string.len(getPlayerNameByGUID2(v:getDataInt("play er_id")))
                space = ""
        for i=1, letters_to_next-l do
                space = space.." "
        end
        if name_now == nil then
                name_now = 'sql error['..v:getDataInt("player_id")..']'
        end
                name = name..kk..". "..v:getDataInt("value").."  -  "..name_now..space.." \n"
        until v:next() == false
        end
        if name ~= "Highscore\n" then 
                doPlayerPopupFYI(cid, name)
        end

        return TRUE
end

i want only the Frags part. can you remove the rest and fix the script?
 
Code:
function getPlayerNameByGUID2(n)
	local ret = 'SQL_ERROR['..n..']'
	local c = db.getResult('SELECT `name` FROM `players` WHERE `id` = '..n..' LIMIT 1;')
	if c:getID() ~= -1 then
		ret = c:getDataString('name')
	end
	c:free()
	return ret
end

local max = 10

function onSay(cid, words, param)
	local letters_to_next, name_now, name, param, l, space = 20, nil, 'Highscore for level\n', param:lower(), nil, nil
	if param == 'frag' or param == 'frags' then
		name = name..'Rank Frags - Nome do Jogador\n'
		local v = db.getResult('SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = 3943 ORDER BY `value` DESC;')
		local i = 0
		repeat
			if i == max or v:getID() == -1 then
				break
			end
			i = i + 1
			name_now, l = getPlayerNameByGUID2(v:getDataInt('player_id')), getPlayerNameByGUID2(v:getDataInt('player_id')):len()
			space = ''
			for i = 1, letters_to_next-l do
				space = space..' '
			end
			if not name_now then
				name_now = 'sql error['..v:getDataInt('player_id')..']'
			end
			name = name..i..'. '..v:getDataInt('value')..'  -  '..name_now..space..' \n'
		until not v:next()
		v:free()
	end
	if name ~= 'Highscore\n' then 
		doPlayerPopupFYI(cid, name)
	end
	return true
end
 
Edit your onKill script
Code:
function onKill(cid, target, lastHit)
	if isPlayer(target) then
		if getPlayerIp(cid) == getPlayerIp(target) then
			return doPlayerAddExp(cid, -40000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same IP.")
		elseif getPlayerParty(cid) and getPlayerParty(target) and getPlayerParty(cid) == getPlayerParty(target) then
			return doPlayerAddExp(cid, -15000000) and doPlayerSendTextMessage(cid, 27, "You have been punished for killing a player of the same Party.")
		end
		return doPlayerAddItem(cid, 2152, 1) and setPlayerStorageValue(cid, 3943, getPlayerStorageValue(cid, 3943)+1)[B][COLOR="Red"] and doPlayerSave(cid)[/COLOR][/B]
	end
	return true
end
Then try killing a few players and see if it rises.
 
tried,
the numbers changed alot..

but the rank script it's not in sequence. (as u can see in the screen.)
i want that to see if the script is working correctly

and i need to remove that dosaveplayer.
everytime u kill somebody you get a small freeze.
but it's too hard.
;s

i have auto save.. but i need the ranks working.
 
Last edited:
Back
Top