function onKill(cid, target)
if isPlayer(target) == TRUE then
loot = 2148
item = doPlayerAddItem(cid, loot, 300)
elseif getPlayerName(cid) == getPlayerName(target) then
doPlayerAddItem(cid, loot, 1)
end
return TRUE
end
local exp = 1000
function onUse(cid, item, frompos, item2, topos)
if getPlayerGroupId(cid) == 1 then
doPlayerAddExp(cid, exp)
doSendMagicEffect(getPlayerPosition(cid), 20)
end
return TRUE
end
registerCreatureEvent(cid, "KillReward")
<event type="kill" name="KillReward" event="script" value="KillReward.lua"/>
<action itemid="xxxx" event="script" value="expegg.lua"/>
First script: Creaturescripts
login.lua:
XML tag:Lua:registerCreatureEvent(cid, "KillReward")
XML:<event type="kill" name="KillReward" event="script" value="KillReward.lua"/>
Second script: Actions
XML tag:
XML:<action itemid="xxxx" event="script" value="expegg.lua"/>
whats up with the third script?
I got this error:
[21/05/2011 20:18:46] [Error - LuaScriptInterface::loadFile] cannot open data/creaturescripts/scripts/KillReward.lua: No such file or directory
[21/05/2011 20:18:46] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/KillReward.lua)
[21/05/2011 20:18:46] cannot open data/creaturescripts/scripts/KillReward.lua: No such file or directory
[21/05/2011 20:18:46] >> Loading chat channels
registerCreatureEvent(cid, "Yourfilename")
Sorry for Iam little slow, but why should I change the names? What is the difference?
Because if you use a name that you don't have your console won't find it.
Tell me what's the name your using in your script.
function onKill(cid, target)
if isPlayer(target) == TRUE then
loot = 2148
item = doPlayerAddItem(cid, loot, 300)
elseif getPlayerName(cid) == getPlayerName(target) then
doPlayerAddItem(cid, loot, 1)
end
return TRUE
end
registerCreatureEvent(cid, "Killreward")
<event type="kill" name="KillReward" event="script" value="KillReward.lua"/>
I'll explain it to you from 0:
First go to data/creaturescripts/scripts & create a new Notepad file there, paste this inside & save it as Killreward.lua:
Lua:function onKill(cid, target) if isPlayer(target) == TRUE then loot = 2148 item = doPlayerAddItem(cid, loot, 300) elseif getPlayerName(cid) == getPlayerName(target) then doPlayerAddItem(cid, loot, 1) end return TRUE end
Now go to data/creatuscripts/scripts/login.lua & paste this inside:
Lua:registerCreatureEvent(cid, "Killreward")
Then go to data/creatuscripts/creaturescripts.xml & paste this:
XML:<event type="kill" name="KillReward" event="script" value="KillReward.lua"/>
local config = {
loginMessage = getConfigValue('loginMessage'),
useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}
function onLogin(cid)
local loss = getConfigValue('deathLostPercent')
if(loss ~= nil) then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
doPlayerAddBlessing(cid, 1)
doPlayerAddBlessing(cid, 2)
doPlayerAddBlessing(cid, 3)
doPlayerAddBlessing(cid, 4)
doPlayerAddBlessing(cid, 5)
doPlayerAddPremiumDays(cid, 2)
doPlayerSetPromotionLevel(cid, 1)
end
local accountManager = getPlayerAccountManager(cid)
if(accountManager == MANAGER_NONE) then
local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
if(lastLogin > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
else
str = str .. " Please choose your outfit."
doPlayerSendOutfitWindow(cid)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
elseif(accountManager == MANAGER_NAMELOCK) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
elseif(accountManager == MANAGER_ACCOUNT) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
end
if(not isPlayerGhost(cid)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end
registerCreatureEvent(cid, "Mail")
registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "Killreward")
registerCreatureEvent(cid, "Idle")
if(config.useFragHandler) then
registerCreatureEvent(cid, "SkullCheck")
end
registerCreatureEvent(cid, "ReportBug")
registerCreatureEvent(cid, "AdvanceSave")
return true
end
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" event="script" value="login.lua"/>
<event type="login" name="FirstItems" event="script" value="firstitems.lua"/>
<event type="login" name="StartSkills" event="script" value="startskills.lua"/>
<event type="login" name="Lowlevellock" event="script" value="lowlevellock.lua"/>
<event type="kill" name="FragReward" event="script" value="fragreward.lua"/>
<event type="kill" name="KillReward" event="script" value="KillReward"/>
<event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
<event type="receivemail" name="Mail" event="script" value="mail.lua"/>
<event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
<event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
<event type="think" name="Idle" event="script" value="idle.lua"/>
<event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
</creaturescripts>
data/creatuscripts/scripts/login.lua
Code:local config = { loginMessage = getConfigValue('loginMessage'), useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')) } function onLogin(cid) local loss = getConfigValue('deathLostPercent') if(loss ~= nil) then doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10) doPlayerAddBlessing(cid, 1) doPlayerAddBlessing(cid, 2) doPlayerAddBlessing(cid, 3) doPlayerAddBlessing(cid, 4) doPlayerAddBlessing(cid, 5) doPlayerAddPremiumDays(cid, 2) doPlayerSetPromotionLevel(cid, 1) end local accountManager = getPlayerAccountManager(cid) if(accountManager == MANAGER_NONE) then local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage if(lastLogin > 0) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str) str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "." else str = str .. " Please choose your outfit." doPlayerSendOutfitWindow(cid) end doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str) elseif(accountManager == MANAGER_NAMELOCK) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?") elseif(accountManager == MANAGER_ACCOUNT) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.") else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.") end if(not isPlayerGhost(cid)) then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT) end registerCreatureEvent(cid, "Mail") registerCreatureEvent(cid, "GuildMotd") registerCreatureEvent(cid, "Killreward") registerCreatureEvent(cid, "Idle") if(config.useFragHandler) then registerCreatureEvent(cid, "SkullCheck") end registerCreatureEvent(cid, "ReportBug") registerCreatureEvent(cid, "AdvanceSave") return true end
data/creatuscripts/creaturescripts.xml
Code:<?xml version="1.0" encoding="UTF-8"?> <creaturescripts> <event type="login" name="PlayerLogin" event="script" value="login.lua"/> <event type="login" name="FirstItems" event="script" value="firstitems.lua"/> <event type="login" name="StartSkills" event="script" value="startskills.lua"/> <event type="login" name="Lowlevellock" event="script" value="lowlevellock.lua"/> <event type="kill" name="FragReward" event="script" value="fragreward.lua"/> <event type="kill" name="KillReward" event="script" value="KillReward"/> <event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/> <event type="receivemail" name="Mail" event="script" value="mail.lua"/> <event type="reportbug" name="SaveReportBug" script="reportbug.lua"/> <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/> <event type="think" name="Idle" event="script" value="idle.lua"/> <event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/> </creaturescripts>
And between, when I create the file Killreward.lua nothing happends, its says that it is a textdocument -.-
<event type="kill" name="KillReward" event="script" value="KillReward.lua"/>