• 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
 
Simple:
Lua:
function onKill(cid, target)
        if isPlayer(target) == TRUE then  

                local victim = getCreatureName(target)
                local playerpos = getPlayerPosition(cid)

		if getPlayerStorageValue(cid, 2010) == FALSE then
			setPlayerStorageValue(cid, 2010, 0)
		end

                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
 
Lua:
function onKill(cid, target)
    if isPlayer(target) == TRUE then  
        local exp = getPlayerStorageValue(cid, 2010)
		if getCreatureSkullType(target) == SKULL_WHITE then
			doSendAnimatedText(getPlayerPosition(cid), "+REP", TEXTCOLOR_LIGHTBLUE)
			setPlayerStorageValue(cid, 2010, (exp+15))
		elseif getCreatureSkullType(target) == SKULL_RED then
			doSendAnimatedText(getPlayerPosition(cid), "+REP", TEXTCOLOR_LIGHTBLUE)
			setPlayerStorageValue(cid, 2010, (exp+30))
		elseif getCreatureSkullType(target) == SKULL_NONE then
			doSendAnimatedText(getPlayerPosition(cid), "-REP", TEXTCOLOR_RED)
			setPlayerStorageValue(cid, 2010, (exp-30))
		end
        end
    return true
end
;)
 
Still don't work.
You forgot to set the storage value to 0:
Lua:
local storage = 2010

function onKill(cid, target)
    if isPlayer(target) == TRUE then
	if getPlayerStorageValue(cid, storage) == -1 then
		setPlayerStorageValue(cid, storage, 0)
	end
        local exp = getPlayerStorageValue(cid, storage)
                if getCreatureSkullType(target) == SKULL_WHITE then
                        doSendAnimatedText(getPlayerPosition(cid), "+REP", TEXTCOLOR_LIGHTBLUE)
                        setPlayerStorageValue(cid, storage, (exp+15))
                elseif getCreatureSkullType(target) == SKULL_RED then
                        doSendAnimatedText(getPlayerPosition(cid), "+REP", TEXTCOLOR_LIGHTBLUE)
                        setPlayerStorageValue(cid, storage, (exp+30))
                elseif getCreatureSkullType(target) == SKULL_NONE then
                        doSendAnimatedText(getPlayerPosition(cid), "-REP", TEXTCOLOR_RED)
                        setPlayerStorageValue(cid, storage, (exp-30))
                end
        end
    return true
end
 
ok shawak, let'see if yours works
I got other sys'scripts that gotta be fixed, but for later

hmm I forgot to post creaturescripts.xml
Lua:
    <event type="kill" name="RepKill" script="repkill.lua"/>
is it right? Do I have to add registercreatureevent to login.lua?
 
You shouldn't have to register for an "onKill" script.
But you can, it should still work.
 
I was told you didn't have to, but I always register all my creaturescripts.
(So, I wouldn't know from experience).
 
-.- still not working when I kill a PK I dont get rep
using shawak's fix
neither when I kill a non-skulled I don't lose rep neither
maybe I should make it function OnDie
EDIT: I haven't added registerevent
 
Register and it should work fine :thumbup:.

What I most love of this forum is the quick support xd
EDIT: now gonna try:
Lua:
 ... 
        registerCreatureEvent(cid, "inquisitionPortals")
         registerCreatureEvent(cid, "RepKill") 
	registerCreatureEvent(cid, "PlayerDeath")
      ...etc
 
Well, since us scripters have nothing to do,
we sit here and wait for something to do.
Then we're on it.
 
Yeah, I decided to make a whole war server and finished in 3 days, only need map, ;).

haha guys you're the best. I got many cool ideas for ot's hope you are there to help me develop'em. There it is coming ShinraTensei spell, as seen in naruto manga, gotta be a cool one
 
=.= still not working, even registercreatureevent is done -.- what is wrong?
EDIT: I repeat, when I kill unskulled player I dont get rep-storage message neither when a PK is killed
maybe there is something in the return's
 
yep. I order a helper to kill a char of mine, then he gets a white skull.(NO -REP MESSAGE APPEARS)
then I kill him white-skulled(NO +REP FOR ME NEITHER)
hmm xcoose me, dont I need an ELSEIF?

Lua:
    if isPlayer(target) == TRUE then
        if getPlayerStorageValue(cid, 2010) == -1 then
                setPlayerStorageValue(cid, 2010, 0)
        end   <!-- ELSEIF NEEDED? -->
        local rep = getPlayerStorageValue(cid, 2010)
                if getCreatureSkullType(target...etc
 
yep. I order a helper to kill a char of mine, then he gets a white skull.(NO -REP MESSAGE APPEARS)
then I kill him white-skulled(NO +REP FOR ME NEITHER)
hmm xcoose me, dont I need an ELSEIF?

Lua:
    if isPlayer(target) == TRUE then
        if getPlayerStorageValue(cid, 2010) == -1 then
                setPlayerStorageValue(cid, 2010, 0)
        end   <!-- ELSEIF NEEDED? -->
        local rep = getPlayerStorageValue(cid, 2010)
                if getCreatureSkullType(target...etc
You don't need an elseif, perhaps a onKill function don't work, go and try onPrepareDeath().
 
You don't need an elseif, perhaps a onKill function don't work, go and try onPrepareDeath().
There's no onPrepareDeath() in TFS 0.2.x

Tested and working, TFS 0.2.5:
Lua:
local storage = 2010

function onKill(cid, target)
    if isPlayer(target) == TRUE then
        if getPlayerStorageValue(cid, storage) == -1 then
            setPlayerStorageValue(cid, storage, 0)
        end
        local playerPos = getCreaturePosition(cid)
        local exp = getPlayerStorageValue(cid, storage)
        if getPlayerSkullType(target) == SKULL_WHITE then
            doSendAnimatedText(playerPos, "+REP", TEXTCOLOR_LIGHTBLUE)
            setPlayerStorageValue(cid, storage, (exp+15))
        elseif getPlayerSkullType(target) == SKULL_RED then
            doSendAnimatedText(playerPos, "+REP", TEXTCOLOR_LIGHTBLUE)
            setPlayerStorageValue(cid, storage, (exp+30))
        elseif getPlayerSkullType(target) == SKULL_NONE then
            doSendAnimatedText(playerPos, "-REP", TEXTCOLOR_RED)
            setPlayerStorageValue(cid, storage, (exp-30))
		end
    end
    return true
end

2v0emgy.png
11twrd4.png
 
Last edited:
Back
Top Bottom