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

CreatureEvent Frag reward

Here's the script I use:
PHP:
local rewards = {4330, 4334}
rand = math.random(#rewards)
function onKill(cid,target)	
	if isPlayer(target) == TRUE then	
		item = doPlayerAddItem(cid,rewards[rand],1)
			if getPlayerSex(target) == 0 then
				sex = "She"
			else
				sex = "He"
			end
		doSetItemSpecialDescription(item,"This is the "..getItemName(rewards[rand]).." of "..getPlayerName(target).." at level "..getPlayerLevel(target)..". "..sex.." was killed by "..getPlayerName(cid).." at level "..getPlayerLevel(cid)..".")
	end
end
 
Can you post your creature event?
<event type="blah blah" etc...
 
Last edited:
Will This Work Correctly With TFS 0.2/0.3?

Code:
local rewards = {4330, 4334} 
rand = math.random(#rewards) 
function onKill(cid,target)     
    if isPlayer(target) == TRUE then     
        item = doPlayerAddItem(cid,rewards[rand],1) 
            if getPlayerSex(target) == 0 then 
                sex = "She" 
            else 
                sex = "He" 
            end 
        doSetItemSpecialDescription(item,"This is the "..getItemName(rewards[rand]).." of "..getPlayerName(target).." at level "..getPlayerLevel(target)..". "..sex.." was killed by "..getPlayerName(cid).." at level "..getPlayerLevel(cid)..".") 
    end 
end
 
This script describes all the targets on the reward a "She"
Can anyone fix it?


PHP:
local rewards = {4330, 4334}
rand = math.random(#rewards)
function onKill(cid,target)	
	if isPlayer(target) == TRUE then	
		item = doPlayerAddItem(cid,rewards[rand],1)
			if getPlayerSex(target) == 0 then
				sex = "She"
			else
				sex = "He"
			end
		doSetItemSpecialDescription(item,"This is the "..getItemName(rewards[rand]).." of "..getPlayerName(target).." at level "..getPlayerLevel(target)..". "..sex.." was killed by "..getPlayerName(cid).." at level "..getPlayerLevel(cid)..".")
	end
end
 
script onkill

I using function onKill and receive that error in my console: [23/12/2008 08:48:19] [Error - CreatureEvent::configureEvent] No valid type for creature event.onKill
[23/12/2008 08:48:19] [Warning - BaseEvents::loadFromXml] Can not configure event
what's problem?
i use onPrepareDeath receive that error.
in creaturescripts.xml i put what ? event="... anyone know ?
 
I using function onKill and receive that error in my console: [23/12/2008 08:48:19] [Error - CreatureEvent::configureEvent] No valid type for creature event.onKill
[23/12/2008 08:48:19] [Warning - BaseEvents::loadFromXml] Can not configure event
what's problem?
i use onPrepareDeath receive that error.
in creaturescripts.xml i put what ? event="... anyone know ?

Anyone?
 
Why isn't this working? No errors, it's just not working.
PHP:
fragReward = "yes"

function onPrepareDeath(cid, killer)
	if fragReward == "yes" then
		if isPlayer(killer) == TRUE then
			local levelDiffHigh = getPlayerLevel(killer) * 1.1
			local levelDiffLow = getPlayerLevel(killer) * 0.9
			if getPlayerLevel(killer) <= 20 and getPlayerLevel(killer) >= 1 then
				addReward = TRUE
			else
				if getPlayerLevel(cid) >= levelDiffLow and getPlayerLevel(cid) <= levelDiffHigh then
					addReward = TRUE
				else
					addReward = FALSE
				end
			end
			if addReward == TRUE then
				if getPlayerSex(cid) == 0 then
					cidGender = 'She'
				else
					cidGender = 'He'
				end
				doSendMagicEffect(getPlayerPosition(cid),CONST_ME_MAGIC_RED)
				doSetItemSpecialDescription(doPlayerAddItem(killer,5943,1), 'This is a heart of ' .. getPlayerName(cid) .. '. ' .. cidGender .. ' was killed at level ' .. getPlayerLevel(cid) .. ' by ' .. getPlayerName(killer) .. ' (Level ' .. getPlayerLevel(killer) .. ').')
				doSendMagicEffect(getPlayerPosition(killer),CONST_ME_MAGIC_RED)
			end 
		end
	end
end
 
Ah, now i remember, i put register event blalbla "FragReward" but when a player dies he just stands there, without falling to the ground.

like this:
registerCreatureEvent(cid, "FragReward")
 
Please said me , where i need copy this parts. In what for folder... In globalevents or in what for folder. really big Thanks...

In creaturescripts/scripts create a new file and name it frags.lua:

Paste your script in frags.lua and save it.

Then ho to creaturescripts/ and open creaturescripts.xml
and add this to it:

PHP:
<event type="preparedeath" name="Frags" script="frags.lua"/>

After that go to creaturescripts/scripts and open login.lua and add this below function onLogin(cid)

PHP:
registerCreatureEvent(cid, "Frags")
 
Back
Top