local cost = 50000,
local experience = 5000,
local player = {}
function onUse(cid, item, frompos, item2, topos)
if getPlayerMoney(cid, .. cost ..) then
doPlayerRemoveMoney(cid, .. cost ..) AND doPlayerAddExperience(cid, .. experience ..)
doPlayerSendMessage(cid, You got ".. experience .." and you lost ".. cost ..")
else
doPlayerSendCancel(cid, Sorry you dont have the money to make this.)
return player
end
end
em.. Please wait 24h before bumping youre thread. But low post = dont know alot...
local cost = 50000,
local experience = 5000,
function onUse(cid, item, frompos, item2, topos)
if doPlayerRemoveMoney(cid, cost) == true then
doPlayerAddExperience(cid, experience)
doPlayerSendMessage(cid, "You got " .. experience .. " and you lost " .. cost .. ".")
else
doPlayerSendCancel(cid, Sorry you dont have the money to make this.)
end
return true
end
local experience = 5000
local cost = 50000
function onUse (cid, item, fromPosition, itemEx, toPosition)
if doPlayerRemoveMoney (cid, cost) then
doPlayerAddExperience (cid, experience)
doPlayerRemoveMoney (cid, cost)
doPlayerSendTextMessage (cid, 25, "You received "..experience.." and lost "..cost.." gold!")
else
doPlayerSendCancel (cid, "You need to have "..cost.." gold!")
end
return true
end
if doPlayerRemoveMoney (cid, cost) then
doPlayerAddExperience (cid, experience)
doPlayerRemoveMoney (cid, cost)
local .player = {}
doPlayerRemoveMoney(cid, .. cost ..)
return .player
end
Code:local experience = 5000 local cost = 50000 function onUse (cid, item, fromPosition, itemEx, toPosition) [B][COLOR="SeaGreen"]if doPlayerRemoveMoney (cid, cost) then[/COLOR][/B] doPlayerAddExperience (cid, experience) [COLOR="SeaGreen"][B]doPlayerRemoveMoney (cid, cost)[/B][/COLOR] doPlayerSendTextMessage (cid, 25, "You received "..experience.." and lost "..cost.." gold!") else doPlayerSendCancel (cid, "You need to have "..cost.." gold!") end return true end
Put this in actions..
<action itemid="4850" event="script" value="hydra_egg.lua"/>
local cost = 50000,
local experience = 5000,
local player:end = {}
function onUse(cid, item, frompos, item2, topos)
if getPlayerMoney(cid, .. cost ..) then
doPlayerRemoveMoney(cid, .. cost ..) AND doPlayerAddExperience(cid, .. experience ..)
doPlayerSendMessage(cid, You got ".. experience .." and you lost ".. cost ..")
else
doPlayerSendCancel(cid, Sorry you dont have the money to make this.)
return player:end
end
Lua:local cost = 50000, local experience = 5000, local player:end = {} function onUse(cid, item, frompos, item2, topos) if getPlayerMoney(cid, .. cost ..) then doPlayerRemoveMoney(cid, .. cost ..) AND doPlayerAddExperience(cid, .. experience ..) doPlayerSendMessage(cid, You got ".. experience .." and you lost ".. cost ..") else doPlayerSendCancel(cid, Sorry you dont have the money to make this.) return player:end end
tested and workes on 0.2 & 0.4 (old ver.)
[06/06/2010 13:56:09] [Error - LuaScriptInterface::loadFile] data/actions/scripts/hydra_egg.lua:2: unexpected symbol near 'local'
[06/06/2010 13:56:09] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/hydra_egg.lua)
[06/06/2010 13:56:09] data/actions/scripts/hydra_egg.lua:2: unexpected symbol near 'local'
U know the answer i wrote there up?
Worked? How? You between "" have constant not text and in my opinion player dont get the message.
I tested your script and when server started was error:
Code:[06/06/2010 13:56:09] [Error - LuaScriptInterface::loadFile] data/actions/scripts/hydra_egg.lua:2: unexpected symbol near 'local' [06/06/2010 13:56:09] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/hydra_egg.lua) [06/06/2010 13:56:09] data/actions/scripts/hydra_egg.lua:2: unexpected symbol near 'local'
beacuse u script is very very bad.
Check this:
how to use
and how to use:
script
doPlayerRemoveMoney (cid, cost)
doPlayerRemoveMoney(cid, .. cost ..)
learn lua plox
badLua:doPlayerRemoveMoney (cid, cost)
goodLua:doPlayerRemoveMoney(cid, .. cost ..)
local cfg = {
cost = 50000,
experience = 50000
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(getPlayerMoney(cid) >= cfg.cost) then
doPlayerRemoveMoney(cid, cfg.cost)
doPlayerAddExperience(cid, cfg.experience)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought ".. cfg.experience .." for ".. cfg.cost .." gold coins.")
doSendAnimatedText(fromPosition, "+".. cfg.experience, TEXTCOLOR_WHITE)
doRemoveItem(item.uid)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enough money.")
end
return true
end
local cost = 50000
local exp = 5000
function onUse (cid, item, fromPosition, itemEx, toPosition)
if doPlayerRemoveMoney (cid, cost) then
doPlayerAddExperience (cid, exp)
doPlayerSendTextMessage (cid, 25, "You received "..exp.." experience and lost "..cost.." gold!")
doRemoveItem (item.uid)
else
doPlayerSendCancel (cid, "You need "..cost.." to use this egg.")
end
return true
end