• 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 How to set +1 frag? If kill monster?

warriorfrog

Active Member
Joined
Jul 29, 2015
Messages
334
Reaction score
35
I want if player kill monster name: Princess, give +1 frag to he

For exemple:
Code:
12:48 Warning! The murder of Princess was not justified.
 
Via creaturescripts with a monster points system, if you want to set a frag then, just copy the query at the playerkill and that's all.
 
function onKill(cid, target, damage, flags)
if getCreatureName(target):lower() == "princess" then
l = db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `date`, `level`) VALUES (" .. getPlayerGUID(pid) .. ", " .. os.time() .. ", " .. getPlayerLevel(pid) .. ");")
j = db.executeQuery("INSERT INTO `killers` ('death_id', 'final_hit', 'unjustified') VALUES (" .. l .. ", 1, 1);")
db.executeQuery("INSERT INTO `player_killers` (`kill_id`, `player_id`) VALUES (" .. j .. ", " .. getPlayerLevel(cid) .. ");")
return true
end

not tested
 
Try this: Pastebin - Frags

You simply register your script in CreatureEvents, and then call the functions.

Good luck.

where i can put a if
if monster die = "Demon" for exemple...

and what tag i put on creaturescripts.xml?

Code:
Add functions:

function doCreatureAddFrag(cid, frag)
        return db.executeQuery("UPDATE `players` SET `frags` = `frags` + " .. frag.. " WHERE `name` = '" .. getCreatureName(cid))
end

function getPlayerFrags(cid)
        local k = db.getResult("SELECT `frags` FROM `players` WHERE `name` = '" .. getCreatureName(cid))
        t = k:getDataInt("frags")
        k:free()
        return t
end

Sql:

ALTER TABLE players ADD frags varchar(255) NOT NULL
 
This will add +1 frag for each kill monster (not tested):
Code:
function onKill(cid, target, damage, flags)
   if getCreatureName(target):lower() == "monster name" then
     doCreatureAddFrag(cid, 1)
   end
   return true
end

Reward for xx killed monsters (not tested):
Code:
function onKill(cid, target, damage, flags)
   local storage = 1234 -- storage for monster
   local monsterKills = 100 -- monsters to kill for reward
   if getCreatureName(target):lower() == "monster name" then
     if getPlayerStorageValue(cid, storage) < monsterKills then
       setPlayerStorageValue(cid, storage, (getPlayerStorageValue(cid, storage) + 1))
     end
     if getPlayerStorageValue(cid, storage) == monsterKills then
       doPlayerAddItem(cid, 2160, 1)
     end
   end
   return true
end
 
This will add +1 frag for each kill monster (not tested):
Code:
function onKill(cid, target, damage, flags)
   if getCreatureName(target):lower() == "monster name" then
     doCreatureAddFrag(cid, 1)
   end
   return true
end

Reward for xx killed monsters (not tested):
Code:
function onKill(cid, target, damage, flags)
   local storage = 1234 -- storage for monster
   local monsterKills = 100 -- monsters to kill for reward
   if getCreatureName(target):lower() == "monster name" then
     if getPlayerStorageValue(cid, storage) < monsterKills then
       setPlayerStorageValue(cid, storage, (getPlayerStorageValue(cid, storage) + 1))
     end
     if getPlayerStorageValue(cid, storage) == monsterKills then
       doPlayerAddItem(cid, 2160, 1)
     end
   end
   return true
end

I try
Code:
function onKill(cid, target, damage, flags)
if getCreatureName(target):lower() == "dragon" then
doCreatureAddFrag(cid, 1)
end
return true
end

Now dragon, dont die, when end he life, close him name and dont change to corpse :X
 
Do you have any errors..?
you might not have doCreatureAddFrag(cid, 1) in your functions....
because that script should work... or try different OnKill parameters
 
Do you have any errors..?
you might not have doCreatureAddFrag(cid, 1) in your functions....
because that script should work... or try different OnKill parameters

2jpn3qT.png
 
yea you dont have the function "doCreatureAddFrag" lol. That's what "Attempt to call global means" it cant find the "Global" function doCreatureAddFrag in your files. Find whatever function you have in your distro to add a frag to someone... then replace the function... Look in global.lua or functions.lua or in /lib also could be in your docs... then your golden :D
 
it's a good idea to make "bots"?
say me experientes otland members ;)

i think i need it too, to make players "bots"
what u think guys?
 
Back
Top