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

[ADVANCED] Karma system... >>> BIG REQUEST <<<

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Time to ask for advanced script!
~yeah...

Guys im not pro, and every moment as I try make it i fail...

I need an karma system:
- What is Karma / Types of karma -
Karma is an conscience.

Types of karma:
- Neutral Karma
- Good Karma
- Bad Karma

Good Karma - if we die, we don't lose experience after it. <-- but this karma is dropping very fast down.
Neutral Karma - if we die we lose experience (deathLostPercent) in config.lua
Bad Karma - if we die we lose more experience (deathLostPercent *%bad karma) than deathLostPercent.
We can get 100% of bad/good karma.

We check karma with command: !karma
ex. Your karma is: 100% bad.
Your karma is: neutral.
Your karma is: 100% good.
Your karma is: 34% bad.
Your karma is: 13% good.


-NPC(?)-
Where to reduce karma to normal ?

We have to go talk with an NPC:
- Hi
- reduce karma
- yes

The price of reduce depends on karma percentage, ex. We check karma with command !karma, we got example: 30% bad. If we goin to reduce the price for reduce 30% is 30(%)*1000(based price [1k/%]).

-Where to increase karma? [CreatureScript]-
We gettin karma after killing monsters.


Thanks in advance,
Fresh.
 
I got something for you, but it's not tested, nor well coded cos I'm ill but here you are:

XML part:

XML:
<talkaction words="!karma" hide="yes" event="script" value="karma.lua"/>
<event type="kill" name="karmaKill" event="script" value="karma.lua"/>
<event type="login" name="karmaLogin" event="script" value="karma.lua"/>

/data/creaturescripts/scripts/karma.lua

LUA:
function onKill(cid, target)
	if(isPlayer(target)) then
		if(getPlayerStorageValue(cid, KARMA_STORAGE) < 100 - KARMA_FOR_PLAYER) then
			setPlayerStorageValue(cid, KARMA_STORAGE, getPlayerStorageValue(cid, KARMA_STORAGE) - KARMA_FOR_PLAYER)
		end
	else
		if(getPlayerStorageValue(cid KARMA_STORAGE) < 100) then
			setPlayerStorageValue(cid, KARMA_STORAGE, getPlayerStorageValue(cid, KARMA_STORAGE) + 1)
		end
	end
	return true
end

function onLogin(cid)
	return registerCreatureEvent(cid, "karmaKill"), doPlayerLoseKarma(cid), setPlayerStorageValue(cid, KARMA_STORAGE, 0)
end

/data/talkactions/scripts/karma.lua

LUA:
function onSay(cid, words, param, channel)
	return doPlayerSendCancel(cid, getPlayerStorageValue(cid KARMA_STORAGE) == 0 and "Your karma is neutral." or getPlayerStorageValue(cid KARMA_STORAGE) > 0 and "Your karma is " .. getPlayerStorageValue(cid KARMA_STORAGE) .. "% good." or getPlayerStorageValue(cid KARMA_STORAGE) < 0 and "Your karma is " .. getPlayerStorageValue(cid KARMA_STORAGE) .. "% bad.") 
end

/data/lib/000-constant.lua add:

LUA:
KARMA_STORAGE = 1000 -- storage of karma points
KARMA_FOR_PLAYER = 10 -- karma for killing players
KARMA_LOSE_DELAY = 5 * 1000 -- how fast your karma will go down, in ms

local function doPlayerLoseKarma(cid)
	if(getPlayerStorageValue(cid, KARMA_STORAGE) > 0) then
		setPlayerStorageValue(cid, KARMA_STORAGE, getPlayerStorageValue(cid, KARMA_STORAGE) - 5)
	elseif(getPlayerStorageValue(cid, KARMA_STORAGE) < 0) then
		setPlayerStorageValue(cid, KARMA_STORAGE, getPlayerStorageValue(cid, KARMA_STORAGE) + 1)
	end
	if(getPlayerStorageValue(cid, KARMA_STORAGE) == 0) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, getConfigValue("deathLostPercent") * 10)
	elseif(getPlayerStorageValue(cid, KARMA_STORAGE) == 100) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, 0)
	elseif(getPlayerStorageValue(cid, KARMA_STORAGE) > 0) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, getConfigValue("deathLostPercent") * 10 * (1 - getPlayerStorageValue(cid, KARMA_STORAGE) / 100)
	elseif(getPlayerStorageValue(cid, KARMA_STORAGE) < 0) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, getConfigValue("deathLostPercent") * 10 * (1 + getPlayerStorageValue(cid, KARMA_STORAGE) / 100)
	end
	return addEvent(doPlayerLoseKarma, KARMA_LOSE_DELAY, cid)
end
 
Some guy was asking me for this script before and offered to pay. So you have asked him if you can create it, posted on here and going to scam the money from him?

Smooth.
 
Some guy was asking me for this script before and offered to pay. So you have asked him if you can create it, posted on here and going to scam the money from him?

Smooth.
Can you send it for me on PW ?

The NPC...
-NPC(?)-
Where to reduce karma to normal ?

We have to go talk with an NPC:
- Hi
- reduce karma
- yes

The price of reduce depends on karma percentage, ex. We check karma with command !karma, we got example: 30% bad. If we goin to reduce the price for reduce 30% is 30(%)*1000(based price [1k/%]).
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)
	npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
	npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)
	npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()
	npcHandler:onThink()
end
function creatureSayCallback(cid, type, msg)
	if(not(npcHandler:isFocused(cid))) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local price = getPlayerStorageValue(cid, KARMA_STORAGE) * 10
	if(msgcontains(msg, "reduce karma")) then
		npcHandler:say("Reducing your karma will cost " ..  price.. " gold coins. Do you want me to reduce your karma?", cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1) then
		if(getPlayerMoney(cid, price)) then
			setPlayerStorageValue(cid, KARMA_STORAGE, 0)
			doPlayerRemoveMoney(cid, price)
			npcHandler:say("Your karma was reduced to zero.", cid)
		else
			npcHandler:say("You don't have enought money.", cid)
		end
		talkState[talkUser] = 0
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/

[Error - TalkAction Interface]
data/talkactions/scripts/frags.lua
Description:
data/talkactions/scripts/frags.lua:2: attempt to call global 'getBooleanFromStri
ng' (a nil value)
[Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/frags
.lua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - TalkAction Interface]
data/talkactions/scripts/online.lua
Description:
data/talkactions/scripts/online.lua:2: attempt to call global 'getBooleanFromStr
ing' (a nil value)
[Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/onlin
e.lua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - TalkAction Interface]
data/talkactions/scripts/pvp.lua
Description:
data/talkactions/scripts/pvp.lua:2: table index is nil
[Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/pvp.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'
[Error - LuaScriptInterface::loadFile] data/talkactions/scripts/karma.lua:2: ')'
expected near 'KARMA_STORAGE'
[Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/karma
.lua)
data/talkactions/scripts/karma.lua:2: ')' expected near 'KARMA_STORAGE'
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'

[Error - MoveEvents Interface]
data/movements/scripts/tiles.lua
Description:
data/movements/scripts/tiles.lua:2: attempt to call global 'getConfigInfo' (a ni
l value)
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/tiles.l
ua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/

[Error - CreatureScript Interface]
data/creaturescripts/scripts/login.lua
Description:
data/creaturescripts/scripts/login.lua:3: attempt to call global 'getBooleanFrom
String' (a nil value)
[Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/l
ogin.lua)
data/lib/050-function.lua:32: ')' expected (to close '(' at line 31) near 'elsei
f'
[Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/karma.lua:7:
')' expected near 'KARMA_STORAGE'
[Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/k
arma.lua)
data/creaturescripts/scripts/karma.lua:7: ')' expected near 'KARMA_STORAGE'
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/
>> Loading chat channels
>> Loading outfits
>> Loading experience stages
>> Loading monsters
>> Loading mods...
> 0 mods were loaded.
>> Loading map and spawns...
> Map size: 1500x1500.
> Map descriptions:
"Saved with Remere's Map Editor 2.1"
"SimOne MapEditor 0.4.78"
Duplicate uniqueId 3005
> Map loading time: 2.7 seconds.
[Error - LuaScriptInterface::loadFile] data/lib/050-function.lua:32: ')' expecte
d (to close '(' at line 31) near 'elseif'
[Warning - LuaScriptInterface::initState] Cannot load data/lib/

And all NPC spamming in console with getThingPos ...
What tha fack !?
 
I repaired already most bugs but when im login on character and logout and login next time (reloging) i got that:
[Error - CreatureScript Interface]
In a timer event called from:
data/creaturescripts/scripts/login.lua:onLogin
Description:
(luaGetCreatureStorage) Creature not found

[Error - CreatureScript Interface]
In a timer event called from:
data/creaturescripts/scripts/login.lua:onLogin
Description:
data/lib/050-function.lua:2: attempt to compare number with boolean
stack traceback:
data/lib/050-function.lua:2: in function <data/lib/050-function.lua:1>
 
Last edited:
Back
Top