HappyFeet
New Member
hey,
what are the changes for scripts from tfs 0.4 to 1.0?
please show me some example's
what are the changes for scripts from tfs 0.4 to 1.0?
please show me some example's
local player = Player(cid)
function onSay(cid, words, param)
if(param == "") then
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
return TRUE
end
local t = string.split(param, ",")
if(not t[2]) then
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
return TRUE
end
local sp_id = getPlayerGUIDByName(t[2])
if sp_id == nil then
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player doesn't exists.")
return TRUE
end
local resultId = db.storeQuery("SELECT `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(resultId ~= false) then
is = tonumber(result.getDataInt(resultId, "sp_id"))
result.free(resultId)
else
is = 0
end
prize = tonumber(t[1])
if(prize == nil or prize < 1) then
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Use: \"!hunt [prize],[nick]\" where prize is for example 1(k).")
return TRUE
end
if(prize >= 100000000000000000000) then
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Sorry, you typed too big number!")
return TRUE
end
if is ~= 0 then
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] This player has already hunted.")
return TRUE
end
if player:removeMoney(cid, prize*1000) == TRUE then
db.query("INSERT INTO `bounty_hunters` VALUES (NULL,"..getPlayerGUID(cid)..","..sp_id..",0," .. os.time() .. ","..prize..",0,0);")
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added!")
else
player:sendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] You haven't got enough money!")
end
return 1
end
local player = Player(cid)
function onKill(cid, target)
if isPlayer(target) == TRUE then
---- BOUNTY HUNTERS START -----
pid = cid
pid2 = getPlayerGUID(target)
local resultId = db.storeQuery("SELECT `bounty_hunters` WHERE `sp_id` = "..pid2.." AND `killed` = 0;")
if(resultId:getID() ~= -1) then
prize = tonumber(resultId:getDataInt("prize"))
bid = tonumber(resultId:getDataInt("id"))
resultId:free()
else
prize = 0
bid = 0
end
if (bid ~= 0 and prize ~= 0 and not(getTileInfo(getCreaturePosition(cid)).pvp)) then
db.query("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id` = "..bid..";")
player:addMoney(cid,prize*1000)
player:sendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
end
---- BOUNTY HUNTERS END -----
end
return TRUE
end
I dont get any errors in my console when im try to test it.. it is just not working..You can see functions in:
data/lib/101-compat
And remember on make reload or try using scripts
get error on console you see what lines.. and edit script