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

[HELP] Fix skull-related Creaturescript

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
Hi everyone, I need to help to fix this script:
When a PK or RS or NO-SKULL player is killed, a storage value is modified, I need it for a system I'm gonna develop. I shall rep+ and also include in the sys's credits.

The bug is that the storage isn't modified when the player is killed. I dont know if I have to make a registercreature. I use tfs 0.2.2. Here it is:

Lua:
  function onKill(cid, target)
        if isPlayer(target) == TRUE then  

		local victim = getCreatureName(target)
		local playerpos = getPlayerPosition(cid)
		local exp = getPlayerStorageValue(cid, 2010)

			if getPlayerSkullType(victim) == 3 then
                doSendAnimatedText(playerpos, "+REP", TEXTCOLOR_LIGHTBLUE)
				setPlayerStorageValue(cid, 2010, (exp+15))
				
			elseif getPlayerSkullType(victim) == 4 then
                doSendAnimatedText(playerpos, "+REP", TEXTCOLOR_LIGHTBLUE)
				setPlayerStorageValue(cid, 2010, (exp+30))
				
			elseif getPlayerSkullType(victim) == 0 then
				doSendAnimatedText(playerpos, "-REP", TEXTCOLOR_RED)
				setPlayerStorageValue(cid, 2010, (exp-30))
			end
        end
        return TRUE
end
 
I've made it a bit shorter, it's also easier to configure now.

Lua:
rep = 
{
[0] = {reputation = -15, text = "-REP", color = 35},
[3] = {reputation = 15, text = "+REP", color = 35},
[4] = {reputation = 30, text = "+REP", color = 180}
}


function onKill(cid, target)
	if isPlayer(target) == TRUE then  
	local exp = getPlayerStorageValue(cid, 2010)
	local skull =  getCreatureSkullType(target)
		if rep[skull] then
			doSendAnimatedText(getPlayerPosition(cid), rep[skull].text, rep[skull].color)
			setPlayerStorageValue(cid, 2010, ((exp)+(rep[skull].reputation))
        end
	end
    return TRUE
end

Another thing, tfs 0.2.x doesn't support multiply creatureevent files of the same type, so you can just have 1 file with onKill function in it, the rest of the other files wont work.


kind regards, Evil Hero
 
Hm didnt know that from 0.2.x's
anyway for that what you said the solution would be to include all scripts into one OnKill script, maybe
 
Back
Top Bottom