• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Addons on Frags

no it wasn't human it was demon , feb , orsh ect

Lua Code: is fixed?

this is error when addon gain from monster

[03/07/2010 09:13:05] [Error - CreatureScript Interface]
[03/07/2010 09:13:05] data/creaturescripts/scripts/addonsForKill.lua:eek:nKill
[03/07/2010 09:13:05] Description:
[03/07/2010 09:13:05] data/creaturescripts/scripts/addonsForKill.lua:51: attempt to index a nil value
[03/07/2010 09:13:05] stack traceback:
[03/07/2010 09:13:05] data/creaturescripts/scripts/addonsForKill.lua:51: in function <data/creaturescripts/scripts/addonsForKill.lua:39>
 
Last edited:
i lol'd script can't work when killing monster, i programmed it like that :p
new one, checks if frag is nil:
Lua:
local t =  {
    baseSt = 3633, --storages from 3633 to +21 up will be used
    frags = 999 --storage to store the amount of kills of the player
    }

local s = { --frags, storage, outfitID, name
    {1200,t.baseSt+21,22,'Warmaster'},
    {1000,t.baseSt+20,21,'Yalaharian'},
    {900,t.baseSt+19,20,'Demonhunter'},
    {800,t.baseSt+18,19,'Brotherhood'},
    {700,t.baseSt+17,18,'Jester'},
    {600,t.baseSt+16,17,'Nightmare'},
    {525,t.baseSt+15,16,'Norsemen'},
    {450,t.baseSt+14,15,'Shaman'},
    {375,t.baseSt+13,14,'Beggar'},
    {325,t.baseSt+12,13,'Assassin'},
    {275,t.baseSt+11,12,'Pirate'},
    {225,t.baseSt+10,11,'Oriental'},
    {175,t.baseSt+9,10,'Wizard'},
    {150,t.baseSt+8,9,'Druid'},
    {125,t.baseSt+7,8,'Barbarian'},
    {100,t.baseSt+6,7,'Warrior'},
    {75,t.baseSt+5,6,'Summoner'},
    {50,t.baseSt+4,5,'Noble'},
    {35,t.baseSt+3,4,'Knight'},
    {20,t.baseSt+2,3,'Mage'},
    {10,t.baseSt+1,2,'Hunter'},
    {5,t.baseSt,1,'Citizen'}
    }

function getFrags(cid,storage)
    for _, t in ipairs(s) do
        if getCreatureStorage(cid,storage) >= t[1] then
            return t
        end
    end
end

function onKill(cid, target, lastHit)
    if not isPlayer(cid) and not isPlayer(target) then
        return true
    end
    
    doCreatureSetStorage(cid,t.frags,getCreatureStorage(cid,t.frags)+1)
   
    if getCreatureStorage(cid, t.frags) < 5 or getCreatureStorage(cid, t.frags) > 1200 then
        return true
    end

    if getFrags(cid,t.frags)[2] == nil then
        return true
    end
    
    if getCreatureStorage(cid,getFrags(cid,t.frags)[2]) == 1 then
        return true
    end
        
    doPlayerAddOutfitId(cid,getFrags(cid,t.frags)[3],3)
    doPlayerSendTextMessage(cid,21,'For obtaining '.. getCreatureStorage(cid,t.frags) ..' kills in total you are rewarded with full '.. getFrags(cid,t.frags)[4] ..' outfit addons!')
    doSendMagicEffect(getCreaturePosition(cid), math.random(67))        
    doCreatureSetStorage(cid,getFrags(cid,t.frags)[2],1)
    return true
end
 
Last edited:
anyways, we really, (yes, this time it works 101% perfect) did it
i post it later, making it shorter
 
when i kill any x monsters i get addons ;s
Code:
local t = {
    baseSt = 3633, --storages from 3633 to +21 up will be used
    frags = 999 --storage to store the amount of kills of the player
    }
 
local s = { --frags, storage, outfitID, name
    {1200,t.baseSt+22,24,'Wayfarer'},
    {100,t.baseSt+21,22,'Warmaster'},
    {80,t.baseSt+20,21,'Yalaharian'},
    {70,t.baseSt+19,20,'Demonhunter'},
    {60,t.baseSt+18,19,'Brotherhood'},
    {55,t.baseSt+17,18,'Jester'},
    {52,t.baseSt+16,17,'Nightmare'},
    {48,t.baseSt+15,16,'Norsemen'},
    {45,t.baseSt+14,15,'Shaman'},
    {42,t.baseSt+13,14,'Beggar'},
    {40,t.baseSt+12,13,'Assassin'},
    {35,t.baseSt+11,12,'Pirate'},
    {32,t.baseSt+10,11,'Oriental'},
    {30,t.baseSt+9,10,'Wizard'},
    {25,t.baseSt+8,9,'Druid'},
    {21,t.baseSt+7,8,'Barbarian'},
    {18,t.baseSt+6,7,'Warrior'},
    {15,t.baseSt+5,6,'Summoner'},
    {12,t.baseSt+4,5,'Noble'},
    {10,t.baseSt+3,4,'Knight'},
    {7,t.baseSt+2,3,'Mage'},
    {5,t.baseSt+1,2,'Hunter'},
    {2,t.baseSt,1,'Citizen'}
    }
 
function getFrags(cid,storage)
    for _, t in ipairs(s) do
        if getCreatureStorage(cid,storage) >= t[1] then
            return t
        end
    end
end
 
function onKill(cid, target, lastHit)
    if not isPlayer(cid) and not isPlayer(target) then
        return true
    end
 
    doCreatureSetStorage(cid,t.frags,getCreatureStorage(cid,t.frags)+1)
 
    if getCreatureStorage(cid, t.frags) < 5 or getCreatureStorage(cid, t.frags) > 1200 then
        return true
    end
 
    if getFrags(cid,t.frags)[2] == nil then
        return true
    end
 
    if getCreatureStorage(cid,getFrags(cid,t.frags)[2]) == 1 then
        return true
    end
 
    doPlayerAddOutfitId(cid,getFrags(cid,t.frags)[3],3)
    doPlayerSendTextMessage(cid,21,'For obtaining '.. getCreatureStorage(cid,t.frags) ..' kills in total you are rewarded with full '.. getFrags(cid,t.frags)[4] ..' outfit addons!')
    doSendMagicEffect(getCreaturePosition(cid), math.random(67))        
    doCreatureSetStorage(cid,getFrags(cid,t.frags)[2],1)
    return true
end

dunno why
and that's what i got in creaturescripts.xml
Code:
<event type="kill" name="addonsForKill" event="script" value="addonsForKill.lua"/>
 
fixed

Lua:
local t = {
    baseSt = 3633, --storages from 3633 to +21 up will be used
    frags = 999 --storage to store the amount of kills of the player
    }
 
local s = { --frags, storage, outfitID, name
    {1200,t.baseSt+21,22,'Warmaster'},
    {1000,t.baseSt+20,21,'Yalaharian'},
    {900,t.baseSt+19,20,'Demonhunter'},
    {800,t.baseSt+18,19,'Brotherhood'},
    {700,t.baseSt+17,18,'Jester'},
    {600,t.baseSt+16,17,'Nightmare'},
    {525,t.baseSt+15,16,'Norsemen'},
    {450,t.baseSt+14,15,'Shaman'},
    {375,t.baseSt+13,14,'Beggar'},
    {325,t.baseSt+12,13,'Assassin'},
    {275,t.baseSt+11,12,'Pirate'},
    {225,t.baseSt+10,11,'Oriental'},
    {175,t.baseSt+9,10,'Wizard'},
    {150,t.baseSt+8,9,'Druid'},
    {125,t.baseSt+7,8,'Barbarian'},
    {100,t.baseSt+6,7,'Warrior'},
    {75,t.baseSt+5,6,'Summoner'},
    {50,t.baseSt+4,5,'Noble'},
    {35,t.baseSt+3,4,'Knight'},
    {20,t.baseSt+2,3,'Mage'},
    {10,t.baseSt+1,2,'Hunter'},
    {5,t.baseSt,1,'Citizen'}
    }
 
function getFrags(cid,storage)
    for _, t in ipairs(s) do
        if getCreatureStorage(cid,storage) >= t[1] then
            return t
        end
    end
end
 
function onKill(cid, target, lastHit)
    if isPlayer(cid) and  isPlayer(target) then
        
    doCreatureSetStorage(cid,t.frags,getCreatureStorage(cid,t.frags)+1)
 
    if getCreatureStorage(cid, t.frags) < 5 or getCreatureStorage(cid, t.frags) > 1200 then
        return true
    end
 
    if getFrags(cid,t.frags)[2] == nil then
        return true
    end
 
    if getCreatureStorage(cid,getFrags(cid,t.frags)[2]) == 1 then
        return true
    end
 
    doPlayerAddOutfitId(cid,getFrags(cid,t.frags)[3],3)
    doPlayerSendTextMessage(cid,21,'For obtaining '.. getCreatureStorage(cid,t.frags) ..' kills in total you are rewarded with full '.. getFrags(cid,t.frags)[4] ..' outfit addons!')
    doSendMagicEffect(getCreaturePosition(cid), math.random(67))        
    doCreatureSetStorage(cid,getFrags(cid,t.frags)[2],1)
    return true
	end
	return true
	
end
 
Code:
local config = {
	[100] = {130, 136}
}

function onKill(cid, target)
	for x, v in ipairs(config) do
		if getPlayerFrags(cid) >= x then
			if not canPlayerWearOutfit(cid, getPlayerSex(cid) == 0 and v[2] or v[1], 1 and 2) then
				doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and v[2] or v[1], 1 and 2)
				break
			end
		end
	end

	return true
end
 
Last edited:
Lua:
local config = {
	[100] = { -- FRAGS
		looktypes = {
			130, 136 -- MALE/FEMALE
		}
	}
}

function onKill(cid, target)
	local v = config[getPlayerFrags(cid)]
	if getPlayerFrags(cid) >= v then
		if not canPlayerWearOutfit(cid, getPlayerSex(cid) == 0 and v.looktypes[2] or v.looktypes[1], 1 and 2) then
			doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and v.looktypes[2] or v.looktypes[1], 1 and 2)
		end
		
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have received a new outfit for gaining " .. v .. "x frags.")
	end

	return true
end

bugged on getPlayersFrags function
 
Is it possible to make so that you recive addons only for the outfit you wear during kills? Meaning all outfits have their own kill counter. 20 kills on that outfit = 1 addon. 50 = 2nd addon
 
you can use the same script but in random
bone, to have 10 frags get a random addon
 
Back
Top