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

Lua When kill gain gold

Thixz

New Member
Joined
Jun 13, 2009
Messages
65
Reaction score
0
Hey guys im confuse about a script
when i kill a person i gain 500 platinum coin its possible?
please post here
thank you
 
This will give you 500 platinum coins, precise.
Code:
function onKill(cid, target, lastHit)
local m = 500 -- amount of gold
	doPlayerAddItem(cid,2152,m)
	doPlayerSendTextMessage(cid,20,'You gained '..m..'platinum coins.')
	return true
end

This one will give a random amount between min and max (100,500)
Code:
function onKill(cid,target,lastHit)
local min, max = 100, 500
local m = math.random[min,max]
	doPlayerAddItem(cid,2152,m)
	doPlayerSendTextMessage(cid,20,'You gained '..m..'platinum coins.')
	return true
end

The random would be better, but it's your OT :).

add this to creaturescripts.xml
Code:
<event type="death" name="[B]TRIGGER_NAME[/B]" event="script" value="[B]SCRIPT_NAME[/B].lua"/>
 
Look when i put the random one give this

Code:
[01/06/2010 14:26:05] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/gaingold.lua:3: ']' expected near ','
[01/06/2010 14:26:05] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/gaingold.lua)
[01/06/2010 14:26:05] data/creaturescripts/scripts/gaingold.lua:3: ']' expected near ','

in the 500platinum coin give this
Code:
[01/06/2010 14:28:13] [Warning - Event::loadScript] Event onDeath not found (data/creaturescripts/scripts/gaingold.lua)
 
Code:
function onKill(cid,target,lastHit)
local min, max = 100, 500
local m = math.random(min,max)
	doPlayerAddItem(cid,2152,m)
	doPlayerSendTextMessage(cid,20,'You gained '..m..'platinum coins.')
	return true
end

Code:
<event type="death" name="TRIGGER_NAME" event="script" value="SCRIPT_NAME.lua"/>

try now.
 
Now give this

Code:
[01/06/2010 15:41:05] [Warning - Event::loadScript] Event onDeath not found (data/creaturescripts/scripts/gaingold.lua)

in xml i put

Code:
<event type="death" name="gaingold" event="script" value="gaingold.lua"/>
 
Code:
function onKill (cid, target, lastHit)
  doPlayerAddItem(cid, 2152, math.random(100,500))
  doPlayerSendTextMessage(cid,20,'You gained '..m..'platinum coins.')
  return true
end
 
Back
Top