• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Can't attack monster

Black123

New Member
Joined
Nov 17, 2011
Messages
32
Reaction score
0
Hello, i've this script and it should work that when i have sotrage 8000,2 i can attack monster and he can atatck me too. But now i can't attack monster and he cannot me :/

Code:
local monster = 'Wolf' -- name
local stor = 8000 -- storage

function onCombat(cid, target)
    if (isPlayer(cid)) then
        if (isMonster(target) and (getCreatureName(target) == monster and (getPlayerStorageValue(cid, stor) != 2))) then 
        return false 
        end
    elseif (isMonster(cid)) then
        if (isPlayer(target) and (getPlayerStorageValue(target, stor) != 2) and doCreatureSetNoMove(cid, false)) then 
        return false 
        end       
    end  
    return true
end

function onKill(cid, target)
    if isMonster(target) and getCreatureName(target) == monster and getPlayerStorageValue(cid, stor) == 2 then
        setPlayerStorageValue(cid, stor, 3)
    end
   
    return true
end
 
Thanks guys :) Now it works again like few years ago :)



Edit:
If i will set ~= 5 then players with storage 5 will be able to kill them, true?
 
well as it works right now only players whit the storage you set will be able to attack it so when you kill the monster one time you can not attack it again

Edit: if you use >= instead of ~=
example
getplayerstorage(cid, stor) >= 5
then players whit 5 or higher will be able to kill monsters
getplayerstorage(cid, stor) ~= 5
then only players whit 5 will be able to kill monsters
 
Yeah that how it should work, could you help to add array? Beacause i want to add more monster and other storage, i am not so good at LUA. I know that it's the easiest language, but i didnt code in it 5 years :/
 
Back
Top