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

Solved Simple script and i fail xD

LuisPro

World War <3
Joined
May 10, 2009
Messages
425
Solutions
1
Reaction score
53
i try edit aol script for simple change weapon script but i think i fail so hard xD
Code:
function onCreatureSay(cid, type, msg)
     msg = string.lower(msg)

     if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
       selfSay('Hello ' .. creatureGetName(cid) .. '! I change sword for axe or club.')
       focus = cid
       talk_start = os.clock()

     elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
       selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

     elseif focus == cid then
     talk_start = os.clock()

     if msgcontains(msg, 'axe') then
         doRemoveItem(cid,2400,1)
       doPlayerAddItem(cid,2431,1)
     elseif msgcontains(msg, 'club') then
         doRemoveItem(cid,2400,1)
       doPlayerAddItem(cid,2421,1)

     elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
       selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
       focus = 0
       talk_start = 0
     end
     end
end
halp plax :D
 
Last edited:
Code:
focus = 0
talk_start = 0
talk_state = 0

function onThingMove(creature, thing, oldpos, oldstackpos)
end


function onCreatureAppear(creature)
end


function onCreatureDisappear(cid, pos)
    if focus == cid then
        selfSay('Good bye then.')
        focus = 0
        talk_start = 0
    end
end


function onCreatureTurn(creature)
end

function msgcontains(txt, str)
     return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

local items = {
    ['aol'] = { itemid = 2173, amount = 1, price = 10000 },
    ['scarf'] = { itemid = 2661, amount = 1, price = 10000 },
    ['stonecutter axe'] = { itemid = 2431, amount = 1, price = 0 },
    ['magic sword'] = { itemid = 2400, amount = 1, price = 0 },
    ['thunder hammer'] = { itemid = 2421, amount = 1, price = 0 }
}

function playerHasItem(cid, item, amount)
    local count = (amount == nil and 1 or amount)
    if getPlayerItemCount(cid, item) >= count then
        doRemoveItem(cid, item, count)
        return true
    end
    return false
end

function npcGiveItem(cid, item, amount)
    return doPlayerAddItem(cid, item, amount == nil and 1 or amount)
end

function onCreatureSay(cid, type, msg)
     msg = string.lower(msg)
      
    if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
        selfSay('Hello ' .. creatureGetName(cid) .. '! I change sword for axe or club.')
        focus = cid
        talk_start = os.clock()
    elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
        selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
    elseif focus == cid then
        talk_start = os.clock()
        if msgcontains(msg, 'axe') and playerHasItem(cid, items['magic sword'].itemid) then
            npcGiveItem(cid, items['stonecutter axe'].itemid)
        elseif msgcontains(msg, 'club') and playerHasItem(cid, items['magic sword'].itemid) then
            npcGiveItem(cid, items['thunder hammer'].itemid)
        elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
            selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
            focus = 0
            talk_start = 0
        end
    end
end

function onCreatureChangeOutfit(creature)
end

function onThink()
     if (os.clock() - talk_start) > 30 then
       if focus > 0 then
         selfSay('Next Please...')
       end
     focus = 0
     end
   if focus ~= 0 then
     if getDistanceToCreature(focus) > 5 then
       selfSay('Good bye then.')
       focus = 0
     end
   end
end
 
Last edited:
yooo bruh :) u also fail :D but thank you for trying :p
nothing happend when say 'axe' or 'club' to npc
(btw. 7.6)
(btw. aol and scarf stuff is not needed in script)

halp plss :D
 
Last edited:
Code:
function onCreatureSay(cid, type, msg)
     msg = string.lower(msg)

     if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
       selfSay('Hello ' .. creatureGetName(cid) .. '! I change sword for axe or club.')
       focus = cid
       talk_start = os.clock()

     elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
       selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

     elseif focus == cid then
     talk_start = os.clock()

     if msgcontains(msg, 'axe') then
         doPlayerRemoveItem(cid,2400)
       doPlayerAddItem(cid,2431,1)
     elseif msgcontains(msg, 'club') then
         doRemoveItem(cid,2400)
       doPlayerAddItem(cid,2421,1)

     elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
       selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
       focus = 0
       talk_start = 0
     end
     end
end

seems half way is done xD npc take item from me but not give new.
and how to use "if" to get something like this: only if player have item "2400" then give him 2431 or 2421

halp plss :D @Limos <3
 
yooo bruh :) u also fail :D but thank you for trying :p
nothing happend when say 'axe' or 'club' to npc
(btw. 7.6)
(btw. aol and scarf stuff is not needed in script)

halp plss :D
fail?
whats is this fail you speak of?
fail does not exist in my vocabulary...
no errors?
 
yooo bruh :) u also fail :D but thank you for trying :p
nothing happend when say 'axe' or 'club' to npc
(btw. 7.6)
(btw. aol and scarf stuff is not needed in script)

halp plss :D


Codex NG is known to have his scripts running fine :)

You either gave him wrong information on what's your needs or whats the LUA Version you're using!
 
fail?
whats is this fail you speak of?
fail does not exist in my vocabulary...
no errors?
here you go, sir:
KEUB4s0.png

:)
 
The server you're using does not support this function, heres the list of functions your server is supporting:
Code:
  //getPlayerFood(uid)
   lua_register(luaState, "getPlayerFood", ActionScript::luaActionGetPlayerFood);
   //getPlayerHealth(uid)   
   lua_register(luaState, "getPlayerHealth", ActionScript::luaActionGetPlayerHealth);
   //getPlayerMana(uid)
   lua_register(luaState, "getPlayerMana", ActionScript::luaActionGetPlayerMana);
   //getPlayerLevel(uid)
   lua_register(luaState, "getPlayerLevel", ActionScript::luaActionGetPlayerLevel);
   //getPlayerMagLevel(uid)
   lua_register(luaState, "getPlayerMagLevel", ActionScript::luaActionGetPlayerMagLevel);
   //getPlayerName(uid)   
   lua_register(luaState, "getPlayerName", ActionScript::luaActionGetPlayerName);
   //getPlayerAccess(uid)   
   lua_register(luaState, "getPlayerAccess", ActionScript::luaActionGetPlayerAccess);
   //getPlayerPosition(uid)
   lua_register(luaState, "getPlayerPosition", ActionScript::luaActionGetPlayerPosition);
   //getPlayerSkill(uid,skillid)
   lua_register(luaState, "getPlayerSkill", ActionScript::luaActionGetPlayerSkill);
   //getPlayerMasterPos(cid)
   lua_register(luaState, "getPlayerMasterPos", ActionScript::luaActionGetPlayerMasterPos);
   //getPlayerVocation(cid)
   lua_register(luaState, "getPlayerVocation", ActionScript::luaActionGetPlayerVocation);
   //getPlayerGuildId(cid)
   lua_register(luaState, "getPlayerGuildId", ActionScript::luaActionGetPlayerGuildId);
   //getPlayerItemCount(uid,itemid)
   //getPlayerItem(uid,itemid)
   
   
   //getPlayerStorageValue(uid,valueid)
   lua_register(luaState, "getPlayerStorageValue", ActionScript::luaActionGetPlayerStorageValue);
   //setPlayerStorageValue(uid,valueid, newvalue)
   lua_register(luaState, "setPlayerStorageValue", ActionScript::luaActionSetPlayerStorageValue);
   
   //getTilePzInfo(pos) 1 is pz. 0 no pz.
   lua_register(luaState, "getTilePzInfo", ActionScript::luaActionGetTilePzInfo);
   
   //getItemRWInfo(uid)
   lua_register(luaState, "getItemRWInfo", ActionScript::luaActionGetItemRWInfo);
   //getThingfromPos(pos)
   lua_register(luaState, "getThingfromPos", ActionScript::luaActionGetThingfromPos);
   //getThingPos(uid)
   
   //doRemoveItem(uid,n)
   lua_register(luaState, "doRemoveItem", ActionScript::luaActionDoRemoveItem);
   //doPlayerFeed(uid,food)
   lua_register(luaState, "doPlayerFeed", ActionScript::luaActionDoFeedPlayer);   
   //doPlayerSendCancel(uid,text)
   lua_register(luaState, "doPlayerSendCancel", ActionScript::luaActionDoSendCancel);
   //doTeleportThing(uid,newpos)
   lua_register(luaState, "doTeleportThing", ActionScript::luaActionDoTeleportThing);
   //doTransformItem(uid,toitemid)   
   lua_register(luaState, "doTransformItem", ActionScript::luaActionDoTransformItem);
   //doPlayerSay(uid,text,type)
   lua_register(luaState, "doPlayerSay", ActionScript::luaActionDoPlayerSay);
   //doSendMagicEffect(uid,position,type)
   lua_register(luaState, "doSendMagicEffect", ActionScript::luaActionDoSendMagicEffect);
   //doChangeTypeItem(uid,new_type)   
   lua_register(luaState, "doChangeTypeItem", ActionScript::luaActionDoChangeTypeItem);
   //doSetItemActionId(uid,actionid)
   lua_register(luaState, "doSetItemActionId", ActionScript::luaActionDoSetItemActionId);
   //doSetItemText(uid,text)
   lua_register(luaState, "doSetItemText", ActionScript::luaActionDoSetItemText);
   //doSetItemSpecialDescription(uid,desc)
   lua_register(luaState, "doSetItemSpecialDescription", ActionScript::luaActionDoSetItemSpecialDescription);
   //doSendAnimatedText(position,text,color)
   lua_register(luaState, "doSendAnimatedText", ActionScript::luaActionDoSendAnimatedText);
   //doPlayerAddSkillTry(uid,skillid,n)
   lua_register(luaState, "doPlayerAddSkillTry", ActionScript::luaActionDoPlayerAddSkillTry);
   //doPlayerAddHealth(uid,health)
   lua_register(luaState, "doPlayerAddHealth", ActionScript::luaActionDoPlayerAddHealth);
   //doPlayerAddMana(uid,mana)
   lua_register(luaState, "doPlayerAddMana", ActionScript::luaActionDoPlayerAddMana);
   //doPlayerAddItem(uid,itemid,count or type) . returns uid of the created item
   lua_register(luaState, "doPlayerAddItem", ActionScript::luaActionDoPlayerAddItem);
   //doPlayerSendTextMessage(uid,MessageClasses,message)
   lua_register(luaState, "doPlayerSendTextMessage", ActionScript::luaActionDoPlayerSendTextMessage);
   //doPlayerRemoveMoney(uid,money)
   lua_register(luaState, "doPlayerRemoveMoney", ActionScript::luaActionDoPlayerRemoveMoney);
   //doShowTextWindow(uid,maxlen,canWrite)   
   lua_register(luaState, "doShowTextWindow", ActionScript::luaActionDoShowTextWindow);   
   //doDecayItem(uid)
   lua_register(luaState, "doDecayItem", ActionScript::luaActionDoDecayItem);
   //doCreateItem(itemid,type or count,position) .only working on ground. returns uid of the created item
   lua_register(luaState, "doCreateItem", ActionScript::luaActionDoCreateItem);
   //doSummonCreature(name, position)
   lua_register(luaState, "doSummonCreature", ActionScript::luaActionDoSummonCreature);
   //doPlayerSetMasterPos(cid,pos)
   lua_register(luaState, "doPlayerSetMasterPos", ActionScript::luaActionDoPlayerSetMasterPos);
   //doPlayerSetVocation(cid,voc)
   lua_register(luaState, "doPlayerSetVocation", ActionScript::luaActionDoPlayerSetVocation);
   //doPlayerRemoveItem(cid,itemid,count)
   lua_register(luaState, "doPlayerRemoveItem", ActionScript::luaActionDoPlayerRemoveItem);
   
   //doMoveItem(uid,toPos)
   //doMovePlayer(cid,direction)
   
   //doPlayerAddCondition(....)
   
#ifdef YUR_ACT_EXT
   lua_register(luaState, "getItemName", ActionScript::luaActionGetItemName);
#endif //YUR_ACT_EXT
 
Back
Top