• 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 Frag Reward

Gothric

New Member
Joined
Feb 6, 2010
Messages
264
Reaction score
1
I want to fix frag reward on my pvpenfo but 3 of my scripts doesnt works ://

1

PHP:
[QUOTE]local fragConfig = {
	ip = getConfigInfo('fragLimitIP'),
	guid = getConfigInfo('fragLimitGUID'),
	account = getConfigInfo('fragLimitAccount')
}

STORAGE_LAST_KILLER_GUID = 10100
STORAGE_LAST_KILLER_GUID_TIMES = 10101
STORAGE_LAST_KILLER_IP = 10200
STORAGE_LAST_KILLER_IP_TIMES = 10201
STORAGE_LAST_KILLER_ACCOUNT = 10300
STORAGE_LAST_KILLER_ACCOUNT_TIMES = 10301

function Regeneration(Param)
	local Player = Param.cid
	doCreatureAddHealth(Player, getCreatureMaxHealth(Player))
	doPlayerAddMana(Player, getPlayerMaxMana(Player))
	return TRUE
end

function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
	doCreatureAddHealth(cid, 9999)	
	addEvent(doCreatureAddHealth, 10,cid, getCreatureMaxHealth(cid))
	removeConditions(cid)
	doTeleportThing(cid, pozycja[math.random(1, #pozycja)], TRUE)
	
	local addFrag = true
	if isPlayer(lastHitKiller) == TRUE then
		-- anti MC, give frag ect.
		if getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_GUID) ~= getPlayerGUID(cid) then
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_GUID, getPlayerGUID(cid))
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_GUID_TIMES, 0)
		else
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_GUID_TIMES, getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_GUID_TIMES)+1)
		end
		if getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_IP) ~= getPlayerIp(cid) then
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_IP, getPlayerIp(cid))
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_IP_TIMES, 0)
		else
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_IP_TIMES, getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_IP_TIMES)+1)
		end
		if getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_ACCOUNT) ~= getPlayerAccountId(cid) then
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_ACCOUNT, getPlayerAccountId(cid))
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_ACCOUNT_TIMES, 0)
		else
			setPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_ACCOUNT_TIMES, getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_ACCOUNT_TIMES)+1)
		end
		if getPlayerIp(lastHitKiller) == getPlayerIp(cid) then
			doPlayerSendTextMessage(lastHitKiller, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed player with same IP as yours. You will not gain frag. Multi-client?")
			addFrag = false
		elseif getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_GUID_TIMES) >= fragConfig.guid then
			doPlayerSendTextMessage(lastHitKiller, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed same player " .. getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_GUID_TIMES) .. " times. You will not gain frag. Friend give you frags?")
			addFrag = false
		elseif getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_IP_TIMES) >= fragConfig.ip then
			doPlayerSendTextMessage(lastHitKiller, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed player with same IP " .. getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_IP_TIMES) .. " times. You will not gain frag. Friend give you frags?")
			addFrag = false
		elseif getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_ACCOUNT_TIMES) >= fragConfig.account then
			doPlayerSendTextMessage(lastHitKiller, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed player with same account number " .. getPlayerStorageValue(lastHitKiller, STORAGE_LAST_KILLER_ACCOUNT_TIMES) .. " times. You will not gain frag. Friend give you frags?")
			addFrag = false
		end
		if addFrag then
			doPlayerAddSoul(lastHitKiller, 1)
			doPlayerAddItem(lastHitKiller, 2151, 1)
			doPlayerAddItem(lastHitKiller, 5944, 1)
			setPlayerStorageValue(lastHitKiller, 666, getPlayerStorageValue(lastHitKiller, 666)+1)
			doBroadcastMessage(getCreatureName(lastHitKiller) .. " (level " .. getPlayerLevel(lastHitKiller) .. ") murdered " .. getCreatureName(cid) .. " (level " .. getPlayerLevel(cid) .. ")",MESSAGE_STATUS_DEFAULT) 
			doPlayerSendTextMessage(lastHitKiller, MESSAGE_EVENT_ADVANCE, "You have " .. getPlayerStorageValue(lastHitKiller, 666) .. " frags and you gained " .. getPlayerSoul(lastHitKiller) .. " frags from login.")
			if (isPlayer(lastHitKiller) == TRUE) then
				if getPlayerSoul(lastHitKiller) >= 10 and getPlayerSoul(lastHitKiller) < 20 then
					doCreatureSetSkullType(lastHitKiller,SKULL_GREEN)
				elseif getPlayerSoul(lastHitKiller) >= 20 and getPlayerSoul(lastHitKiller) < 30 then
					doCreatureSetSkullType(lastHitKiller,SKULL_WHITE)
				elseif getPlayerSoul(lastHitKiller) >= 30 and getPlayerSoul(lastHitKiller) < 40 then
					doCreatureSetSkullType(lastHitKiller,SKULL_YELLOW)
				elseif getPlayerSoul(lastHitKiller) >= 40 then
					doCreatureSetSkullType(lastHitKiller,SKULL_RED)
				end
			end
		end
		local DB_addFrag = 0
		local DB_assist = 0
		local DB_assist_ip = 0
		if addFrag == true then
			DB_addFrag = 1
		end
		if isPlayer(mostDamageKiller) == TRUE then
			DB_assist = getPlayerGUID(mostDamageKiller)
			DB_assist_ip = getPlayerIp(mostDamageKiller)
		end
		db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `player_ip`, `killer`, `killer_level`, `killer_ip`, `killer_2`, `killer_2_level`, `killer_2_ip`, `add_frag`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. getPlayerIp(cid) .. ", " .. getPlayerGUID(lastHitKiller) .. ", " .. getPlayerLevel(lastHitKiller) .. ", " .. getPlayerIp(lastHitKiller) .. ", " .. getPlayerGUID(mostDamageKiller) .. ", " .. getPlayerLevel(mostDamageKiller) .. ", " .. getPlayerIp(mostDamageKiller) .. ", " .. tonumber(DB_addFrag) .. ");")
	end
end[/QUOTE]

2

function onKill(cid, target, lastHit)
local l = 2151
if(isPlayer(target) == true then
return true
end

doPlayerAddItem(lastHitKiller, l, 1)
doPlayerAddItem(lastHitKiller, 5944, 1)
doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You killed "..getCreatureName(cid).."."
end
return true
end


3


function onKill(cid, target)
local l = 2151
if isPlayer(target) == TRUE then
if getPlayerIp(cid) ~= getPlayerIp(target) then
doPlayerAddItem(cid, l, 1)
elseif getPlayerName(cid) == getPlayerName(target) then
doPlayerAddItem(cid, l, 1)
else
doPlayerAddExperience(cid, -1000000)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"You have been punished for killing a player of the same IP.")
end
end
return true
end


help :/
 
#2:
Code:
function onKill(cid, target, lastHit)
	local r1 = 2151
	local r2 = 5944
	if(isPlayer(cid) and isPlayer(target)) then
		doPlayerAddItem(cid, r1, 1)
		doPlayerAddItem(cid, r2, 1) 
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You killed " .. getCreatureName(target) .. ".")
	end
	return true
end

#3:
Code:
function onKill(cid, target, lastHit)
	local reward = 2151
	local exp = 100000
	if(isPlayer(cid) and isPlayer(target)) then
		if(getIpByName(getCreatureName(cid)) ~= getIpByName(getCreatureName(target))) then
			doPlayerAddItem(cid, reward, 1)
		elseif(getPlayerName(cid) == getPlayerName(target)) then
			doPlayerAddItem(cid, reward, 1)
		else
			doPlayerAddExperience(cid, - exp)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been punished for killing a player of the same IP.")
		end
	end
	return true
end
 
Last edited:
[24/03/2010 13:22:29] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/fragreward.lua:8: ')' expected (to close '(' at line 7) near 'end'
[24/03/2010 13:22:29] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/fragreward.lua)
[24/03/2010 13:22:29] data/creaturescripts/scripts/fragreward.lua:8: ')' expected (to close '(' at line 7) near 'end'



<event type="kill" name="Fragreward" event="script" value="fragreward.lua"/>

its ok? so deasnt work ://
 
[24/03/2010 13:31:07] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/fragreward.lua:5: ')' expected near 'then'
[24/03/2010 13:31:07] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/fragreward.lua)
[24/03/2010 13:31:07] data/creaturescripts/scripts/fragreward.lua:5: ')' expected near 'then'

now :s

<event type="kill" name="Fragreward" event="script" value="fragreward.lua"/>
<--- Is it good??
 
u changed sthing?? its the same error

i have:
function onKill(cid, target, lastHit)
local reward = 2151
local exp = 100000
if(isPlayer(cid) and isPlayer(target)) then
if(getIpByName(getCreatureName(cid)) ~= (getIpByName(getCreatureName(target)) then
doPlayerAddItem(cid, reward, 1)
elseif(getPlayerName(cid) == getPlayerName(target)) then
doPlayerAddItem(cid, reward, 1)
else
doPlayerAddExperience(cid, - exp)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been punished for killing a player of the same IP.")
end
end
return true
end


and in xml
<event type="kill" name="Fragreward" event="script" value="fragreward.lua"/>


and its really doesnt work :S dont be angry :D u r cool becouse u r trying
 
yea in console i havent any error but in game player doesnt get reward ;/ maybe i should register this script in login lua?

;/ lots of my scripts doesnt work :s i have war server and when player1 kill player2 there is no any comunicate :s maybe this is reason?? i dont know :/
 
i registered and in game i have been punished for killing mc :D
but i didnt get reward

Because script checks if player kills another player with same IP, then you'll lose exp, if not same IP then reward.
JDB #2
LUA:
function onKill(cid, target, lastHit)
local items = {2151, 5944}
	if isPlayer(cid) and isPlayer(target) then
		for _, item in ipairs(items) do
			doPlayerAddItem(cid, item, 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You killed " .. getCreatureName(target) .. ".")
		end end
	return true
end
 
Last edited:

Similar threads

Back
Top