• 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] Creating some easy scripts

Zippow

Member
Joined
Aug 27, 2011
Messages
454
Reaction score
21
Location
Sweden
This is some useful functions

<-- function onSay(cid, words, param) -->

<-- function onUse(cid, item, frompos, item2, topos) -->

<-- function onStepIn(cid, item, position, fromPosition) -->

<-- function onCastSpell(cid, var) -->

<-- Let's start off with creating a command to buy a rune -->

Code:
function onSay(cid, words, param)

local cost = 10000 <-- enter the number of gps the rune should cost -->
local charges = 10000 <-- write on how many charges you should get -->

  if doPlayerRemoveMoney(cid, cost) == TRUE then
    doPlayerAddItem(cid, item id, charges)
doPlayerSendTextMessage,cid,22,"You bought a rune"

else
doPlayerSendTextMessage(cid,22,"Not Enough Money"
 end
 return TRUE
end

<-- Let's make a reward by clicking a switch -->

Code:
function onUse(cid, item, frompos, item2, topos)

if doPlayerAddItem(cid, 2150, 1) == TRUE then 
 doPlayerSendTextMessage(cid,22,"You earned a reward"
 end
 return TRUE
end

<-- Let's make a EXP tile -- >

Code:
function onStepIn(cid, item, position, fromPosition)

if doPlayerAddExp(cid, 22) TRUE then <-- You can change the EXP amount -->
 doPlayerSendTextMessage(cid,22,"You walked on a tile, 22 exp earned") 
 doSendMagicEffect(getPlayerPosition(cid), 31)
 end
 return TRUE
end
 
Last edited:
<-- Let's make a EXP tile -- >

Code:
function onStepIn(cid, item, position, fromPosition) if doPlayerAddExp(cid, 22) TRUE then <-- You can change the EXP amount --> doPlayerSendTextMessage(cid,22,"You walked on a tile, 22 exp earned") doSendMagicEffect(getPlayerPosition(cid), 31) end return TRUE end


Does not work for my 0.3.7.

It explain me some Errors like "Unenspectet symbol near "=".
 
Change
if doPlayerAddExp(cid, 22) TRUE then <-- You can change the EXP amount -->
to
if doPlayerAddExp(cid, 22) == TRUE then <-- You can change the EXP amount -->
He forgot the double "=="
 
Change
if doPlayerAddExp(cid, 22) TRUE then <-- You can change the EXP amount -->
to
if doPlayerAddExp(cid, 22) == TRUE then <-- You can change the EXP amount -->
He forgot the double "=="

Code:
true =  if(doPlayerAddExp(cid, 22)) then
false = if(not doPlayerAddExp(cid, 22)) then
...

And is it only me who noticed the pr0 tabbing?
Code:
  function
if then
          do that
                  end
   return true
end

Code:
function onSay(cid, words, param)
local itemId = 2160
local cost = 10000 -- enter the number of gps the rune should cost
local charges = 100 -- write on how many charges you should get
    if(doPlayerRemoveMoney(cid, cost)) then
        doPlayerAddItem(cid, itemId, charges)
        doPlayerSendTextMessage,cid,22,"You bought a rune"
    else
        doPlayerSendTextMessage(cid,22,"Not Enough Money"
    end
return true
end

Code:
function onUse(cid, item, frompos, item2, topos)
    if(doPlayerAddItem(cid, 2150, 1)) then
        doPlayerSendTextMessage(cid, 22, "You earned a reward"
    end
return true
end

Code:
function onStepIn(cid, item, position, fromPosition)
local exp = 22, -- You can change the EXP amount
    if(doPlayerAddExp(cid, exp)) then
        doPlayerSendTextMessage(cid, 22, "You walked on a tile, ".. exp .." exp earned")
        doSendMagicEffect(getPlayerPosition(cid), 31)
    end
return true
end
 
Last edited:
Back
Top