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

creaturescript bug

Darqneez

ShaC-Ohhhh
Joined
Dec 30, 2009
Messages
72
Reaction score
2
Location
Poland/Wroclaw
EDIT: See my post at the bottom

Hello, I've made a script but console gives me an error. Script should give player +1 storage value for every killed monster that is in config.
here's script:
Lua:
    config = {
    message = "You have deafeated me, but my brothers will take a revenge on you!",
    amuthepmessage = "Impossible!",
    pharaohs = {
        "ashmunrah",
        "dipthrah",
        "mahrdis",
        "morguthis",
        "omruc",
        "rahemos",
        "thalas",
        "vashresamun"
        }
}


function onDeath(cid, corpse, killer)
        if name == getCreatureName(config.pharaohs) then
        doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
        setPlayerStorageValue(cid,20001,(getPlayerStorageValue(cid,20001))+1)
        setGlobalStorageValue(cid,20002,-1)

        elseif name == getCreatureName(amuthep) then
        doCreatureSay(cid, config.amuthepmessage, TALKTYPE_ORANGE_1)
        setPlayerStorageValue(cid,20001,(getPlayerStorageValue(cid,20001))+1)
        setGlobalStorageValue(cid,20002,-1)
        end
    return TRUE
end
That GlobalStorage is necessary, so dont delete it. Maybe I did a mistake, but global storage should work so: When using lever (in another script, there is a setglobalstoragevalue command) player gets global storage value 1, so he cant pull lever again until he kills pharaoh. After killing pharaoh script changes global storage value to -1, which is necessary to use lever.

here's error:
Code:
[02/09/2010 17:28:24] [Error - CreatureScript Interface] 
[02/09/2010 17:28:24] data/creaturescripts/scripts/pharaohs.lua:onDeath
[02/09/2010 17:28:24] Description: 
[02/09/2010 17:28:24] (luaGetCreatureName) Creature not found

PS. I made in creaturescript.xml this:
XML:
<event type="death" name="Pharaoh" event="script" value="pharaohs.lua"/>
in login.lua this:
Lua:
registerCreatureEvent(cid, "Pharaoh")
and in every pharaoh.xml script this bettwen </flags> and <attack...>:
XML:
   <script>
<event name="Pharaoh"/>
</script>

EDIT: See my post at the bottom
 
Last edited:
Lua:
local config = {
    message = "You have deafeated me, but my brothers will take a revenge on you!",
    amuthepmessage = "Impossible!",
    pharaohs = {
        "ashmunrah",
        "dipthrah",
        "mahrdis",
        "morguthis",
        "omruc",
        "rahemos",
        "thalas",
        "vashresamun"
        }
}
 
 
function onDeath(cid, corpse, killer)
	if config.pharaos[getCreatureName(cid):lower()] then
		doCreatureSay(killer, config.message, TALKTYPE_ORANGE_1)
		setPlayerStorageValue(killer, 20001, (getPlayerStorageValue(killer, 20001)) + 1)
		setGlobalStorageValue(killer, 20002, -1)
        elseif getCreatureName(cid):lower() == "amuthep" then
		doCreatureSay(cid, config.amuthepmessage, TALKTYPE_ORANGE_1)
		setPlayerStorageValue(killer, 20001, (getPlayerStorageValue(killer, 20001)) + 1)
		setGlobalStorageValue(killer, 20002, -1)
        end
    return true
end
 
Last edited:
I have next problem. After I kill first pharaoh, second one doesn't appear. I don't even get the message written in config, so there must be an error at beginning of the script. I have also checked PMA and I can see that global storage is not changed from 1 to -1. Please help me, here's script:

creaturescripts -> pharaohs.lua:
Lua:
local config = {
    message = "You have deafeated me, but my brothers will take a revenge on you!",
    amuthepmessage = "Impossible!",
    pharaohs = {
        "ashmunrah",
        "dipthrah",
        "mahrdis",
        "morguthis",
        "omruc",
        "rahemos",
        "thalas",
        "vashresamun"
        }
}

function onKill(cid, corpse, killer)
	if config.pharaohs[getCreatureName(cid):lower()] then
		doCreatureSay(killer, config.message, TALKTYPE_ORANGE_1)
		    if getGlobalStorageValue(20001) == -1 then
		    setGlobalStorageValue(20001, 1)
		    else
	    	setGlobalStorageValue(20001, (getGlobalStorageValue(20001)) + 1)
	    	end
		setGlobalStorageValue(20002, (getGlobalStorageValue(20001))-2)

        elseif getCreatureName(cid):lower() == "amuthep" then
		doCreatureSay(cid, config.amuthepmessage, TALKTYPE_ORANGE_1)
		setGlobalStorageValue(20002, (getGlobalStorageValue(20001))-2)
		setGlobalStorageValue(20001, (getGlobalStorageValue(20001))+1)
        end
    return true
end
 
Last edited:
I edited the script, copy it again. :thumbup:

Code:
function onDeath(cid, corpse, deathList)
	local monsters = {
		["Ashmunrah"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
			amuthep = "Impossible!"
		},
		["Dipthrah"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
			amuthep = "Impossible!"
		}
	}
	local monster = monsters[(getCreatureName(cid))]
	if not monster then
		return true
	end
	if monster then
		return doCreatureSay(cid, monster.succeed, TALKTYPE_ORANGE_1) and setPlayerStorageValue(deathList[1], 20001, (getPlayerStorageValue(cid, 20001)) + 1) and setGlobalStorageValue(deathList[1], 20002, -1)
	elseif monster == "Amuthep" then
		return doCreatureSay(cid, monster.amuthep, TALKTYPE_ORANGE_1) and setPlayerStorageValue(deathList[1], 20001, (getPlayerStorageValue(cid, 20001)) + 1) and setGlobalStorageValue(deathList[1], 20002, -1)
	end
	return true
end
 
Last edited:
Hey man, I have a question, would you look at your a little bit modified script. I did it because I want this script to work on global storages, because it's impossible to do this quest alone. So I wanted this quest look like this:
there is a group of players, for example 10. One of them (random one) pulls a lever and first pharaoh spawns. it's impossible to pull lever again as long as current pharaoh lives, because of global storage 20001 which is changed to -1 on creaturescript. Then doesnt matter what person will pull lever again and next pharaoh will spawn, so it can't be made on Player's Storage but Global. And here comes the problem, because I never did things like this. I mostly understand the code but I can't understand yours, so I am not sure if I did it good, please take a look:
EDIT: at the beginning player has globalstorage(20001) = -1. after killing first pharaoh globlastorage = 1, that after killing next one its 2 etc. if it reaches its last number after 30 min it will reset to -1. Yeah I know complicated, but it's very nice quest
Lua:
function onDeath(cid, corpse, deathList)
	local monsters = {
		["Ashmunrah"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Dipthrah"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Mahrdis"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Morguthis"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Omruc"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Rahemos"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Thalas"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Vashresamun"] = {
			succeed = "You have deafeated me, but my brothers will take a revenge on you!",
		},
		["Amuthep"] = {
			amuthep = "Impossible!",
		}
	}
	local monster = monsters[(getCreatureName(cid))]
	if not monster then
		return true
	end
	if monster then
		return doCreatureSay(cid, monster.succeed, TALKTYPE_ORANGE_1) and setGlobalStorageValue(deathList[1], 20001, (getGlobalStorageValue(20001)) + 1) and setGlobalStorageValue(deathList[1], 20002, -1)
	elseif monster == "Amuthep" then
		return doCreatureSay(cid, monster.amuthep, TALKTYPE_ORANGE_1) and setGlobalStorageValue(deathList[1], 20001, (getGlobalStorageValue(20001)) + 1) and setGlobalStorageValue(deathList[1], 20002, -1)
	end
	return true
end
Please tell me if I modified this script good, if not I did my best to explain how should it work, so maybe you would help me again. :)
 
Just erase...

Lua:
	elseif monster == "Amuthep" then
		return doCreatureSay(cid, monster.amuthep, TALKTYPE_ORANGE_1) and setGlobalStorageValue(deathList[1], 20001, (getGlobalStorageValue(20001)) + 1) and setGlobalStorageValue(deathList[1], 20002, -1)
	end
 
Back
Top