Magic
3+3=3!
- Joined
- Aug 4, 2008
- Messages
- 1,338
- Reaction score
- 180
Witam !
Ot?? zainspirowany pewnym tematem postanowi?em stworzy? dla Was, spo?eczno?ci Tibia.net.pl system umo?liwiaj?cy bezpieczne przechowywanie przedmiot?w w depositach, bez obawy o utrat? ich podczas hacka. Skrypt ten napisa?em z okazji 1000 posta ;p
Skrypt mo?na pobra? z za??cznika, lub wrzuci? -
/mods/pins.xml:
oraz
/mods/scripts/pin.lua
Po instalacji, mo?na wygenerowa? sobie pin za pomoc? komendy /createpin random <- automatycznie losuje pin, lub /createpin 4_cyfry <- daje u?ytkownikowi pin jaki sobie wybra?. Nast?puj?co, u?ytkownik mo?e wklepa? pin ?eby mie? dost?p do depo za pomoc? komendy /pin pin_usera <- dzi?ki czemu b?dzie m?g? jednorazowo otworzy? skrzynke z depo. Gdy jednak b?dzie chcia? odej?? bez otwierania, wystarczy ?e wklepie /lock i depo jest zabezpieczone. Je?li uznamy, ?e nasz pin jest znany, mo?na go zmieni? - /changepin pin_obecny, pin_nowy - i pin jest zmieniany. Mam nadziej?, ?e skrypt Wam si? spodoba, za nied?ugo zostanie dodane szyfrowanie hase?.
Ot?? zainspirowany pewnym tematem postanowi?em stworzy? dla Was, spo?eczno?ci Tibia.net.pl system umo?liwiaj?cy bezpieczne przechowywanie przedmiot?w w depositach, bez obawy o utrat? ich podczas hacka. Skrypt ten napisa?em z okazji 1000 posta ;p
Version: 1.0 Beta
Autor skryptu: [USER]Magic[/USER]
Skan:
Nie zezwalam na publikowanie tego skryptu na ?adnych innych forach(wyj?tek stanowi kiedy ja sam je tam opublikuje.)
Instalacja skryptu jest banalnie prosta. Wrzucamy pliki do folderu /mods/, wchodzimy na naszego OTS'a Godem (access=6), oraz wklepujemy komend? /install-depo. Jak nam si? nie spodoba skrypt - no trudno, warto u?y? komendy /uninstall-depo do jej deinstalacji.Autor skryptu: [USER]Magic[/USER]
Skan:
Nie zezwalam na publikowanie tego skryptu na ?adnych innych forach(wyj?tek stanowi kiedy ja sam je tam opublikuje.)
Skrypt mo?na pobra? z za??cznika, lub wrzuci? -
/mods/pins.xml:
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="DEPO FOR PIN system by Magic of Tibia.net.pl" version="1.0" author="Magic(Hereos)" contact="magichereos@gmail.com" enabled="yes">
<talkaction words="/pin" event="script" value="pin.lua"/>
<talkaction words="/createpin" event="script" value="pin.lua"/>
<talkaction words="/changepin" event="script" value="pin.lua"/>
<talkaction words="/install-depo" access="6" event="script" value="pin.lua"/>
<talkaction words="/uninstall-depo" access="6" event="script" value="pin.lua"/>
<talkaction words="/lock" event="script" value="pin.lua"/>
<action fromid="2589" toid="2592" event="script" value="pin.lua"/>
</mod>
/mods/scripts/pin.lua
PHP:
--
-- SYSTEM CREATED BY MAGIC(hereos) of Tibia.net.pl
-- All rights reserved. Autor's e-mail: magichereos@gmail.com
-- If something doesn't work, you can report it to me.
-- TODO List:
-- security-pin(god can use one of password hashing - md5, sha1, plain(no-hash))
-- If you delete it, You'll break the law.
--
config =
{
try = 3, -- How much player can make mistake?
times = 30, -- How much player have to wait if he make x mistakes?(you can change it in "try") It's calculate by times*player tries ;)
storage = 1996, -- StorageID of Pins.
-- hash = md5, -- How to hash pin's?(md5/sha1/plain) -- IT's disabled for now.
}
titles ={424, 234} -- There you can edit depo-pin-check titles.
-- There code starts, don't edit it if you don't know how.
function onSay(cid, words, param, channel)
local param_num = tonumber(param)
if(words == "/pin") then
if(getPlayerStorageValue(cid, config.storage) ~= 1) then
if(param ~= nil) then
if(tonumber(param) == nil) then
doPlayerSendTextMessage(cid, 22, "You haven't type numbers.")
return true
end
if(param_num >= 1000 and param_num <= 9999) then
local pin_query = db.getResult("SELECT `pin`, `pin_try`, `blocked` FROM `players` WHERE `id` = ".. getPlayerGUID(cid))
if(pin_query:getDataInt("blocked") <= os.clock()) then
if(pin_query:getDataInt("blocked") ~= 0) then
doPlayerSendTextMessage(cid, 22, "Your PIN-Code is unblocked(no try, no block). You must type comand again.")
db.executeQuery("UPDATE `players` SET `pin_try` = '0', `blocked` = '0' WHERE `id` = " .. getPlayerGUID(cid))
return true
end
if(param_num == pin_query:getDataInt("pin")) then
setPlayerStorageValue(cid, config.storage, 3)
doPlayerSendTextMessage(cid, 22, "Depo is unlocked. If you want to block it, you must type /lock or open depo and move.")
else
if(pin_query:getDataInt("pin_try")+1 < config.try) then
db.executeQuery("UPDATE `players` SET `pin_try` = '".. pin_query:getDataInt("pin_try")+1 .."' WHERE `id` = " .. getPlayerGUID(cid))
doPlayerSendTextMessage(cid, 22, "Sorry, but your PIN Code is wrong. It's your ".. pin_query:getDataInt("pin_try")+1 .. "/" .. config.try .. "try. After it, your depo will be blocked.")
else
db.executeQuery("UPDATE `players` SET `pin_try` = '".. pin_query:getDataInt("pin_try")+1 .."', `blocked` = ".. os.clock()+config.times*pin_query:getDataInt("pin_try") .." WHERE `id` = " .. getPlayerGUID(cid))
doPlayerSendTextMessage(cid, 22, "Sorry, but your PIN Code is wrong. Your account is blocked becouse it was last try(".. pin_query:getDataInt("pin_try") .."/".. config.try ..")")
end
end
else
doPlayerSendTextMessage(cid, 22, "You've blocked your depo. Block will disapear in ".. pin_query:getDataInt("blocked")-os.clock() .. "secounds")
end
pin_query:free()
else
doPlayerSendTextMessage(cid, 22, "You didn't type 4 numbers.")
end
else
doPlayerSendTextMessage(cid, 22, "Sorry, but your PIN Code is empty.")
end
else
doPlayerSendTextMessage(cid, 22, "You have active PIN, so why are you typing it again?")
end
elseif(words == "/createpin") then
local pin_query = db.getResult("SELECT `pin`, `pin_try`, `blocked` FROM `players` WHERE `id` = ".. getPlayerGUID(cid))
if(pin_query:getDataInt("pin") == 0) then
if(param ~= '') then
if(param == "random") then
local randompin = math.random(1000, 9999)
local querycpin = db.executeQuery("UPDATE `players` SET `pin` = '".. randompin .."' WHERE `id` = " .. getPlayerGUID(cid))
if(querycpin) then
doPlayerSendTextMessage(cid, 22, "Your PIN-Code has been changed to: ".. randompin)
end
elseif(tonumber(param) == nil) then
doPlayerSendTextMessage(cid, 22, "You haven't type numbers or random.")
return true
elseif(param_num >= 1000 and param_num <= 9999) then
local querycpin = db.executeQuery("UPDATE `players` SET `pin` = '".. param_num .."' WHERE `id` = " .. getPlayerGUID(cid))
if(querycpin) then
doPlayerSendTextMessage(cid, 22, "Your PIN-Code has been changed to: ".. param)
end
else
doPlayerSendTextMessage(cid, 22, "So sorry, you have type wrong option. Good comend is /createpin 4 numbers or /createpin random")
end
pin_query:free()
else
doPlayerSendTextMessage(cid, 22, "You type empty pin.")
end
else
doPlayerSendTextMessage(cid, 22, "You've got your pin. If you want to change it, you must type /changepin your_pin, new_pin.")
end
elseif(words == "/changepin") then
if(param ~= '') then
paramse = string.explode(param, ",")
if(not paramse[1]) then
doPlayerSendTextMessage(cid, 22, "First code is wrong.")
return true
end
if(not paramse[2]) then
doPlayerSendTextMessage(cid, 22, "Second code is wrong.")
return true
end
if(tonumber(paramse[1]) == nil or tonumber(paramse[2]) == nil) then
doPlayerSendTextMessage(cid, 22, "You haven't type numbers.")
return true
end
paramse[1] = tonumber(paramse[1])
paramse[2] = tonumber(paramse[2])
if(paramse[1] >= 1000 and paramse[1] <= 9999 and paramse[2] >= 1000 and paramse[2] <= 9999) then
local pin_query = db.getResult("SELECT `pin`, `pin_try`, `blocked` FROM `players` WHERE `id` = ".. getPlayerGUID(cid))
if(pin_query:getDataInt("blocked") <= os.clock()) then
if(pin_query:getDataInt("blocked") ~= 0) then
doPlayerSendTextMessage(cid, 22, "Your PIN-Code is unblocked(no try, no block). You must type comand again.")
db.executeQuery("UPDATE `players` SET `pin_try` = '0', `blocked` = '0' WHERE `id` = " .. getPlayerGUID(cid))
return true
end
if(pin_query:getDataInt("pin") == paramse[1]) then
local querychpin = db.executeQuery("UPDATE `players` SET `pin` = '".. paramse[2] .."' WHERE `id` = " .. getPlayerGUID(cid))
if(querychpin) then
doPlayerSendTextMessage(cid, 22, "Your PIN-Code has been changed to: ".. paramse[2])
end
else
if(pin_query:getDataInt("pin_try")+1 < config.try) then
db.executeQuery("UPDATE `players` SET `pin_try` = '".. pin_query:getDataInt("pin_try")+1 .."' WHERE `id` = " .. getPlayerGUID(cid))
doPlayerSendTextMessage(cid, 22, "Sorry, but your PIN Code is wrong. It's your ".. pin_query:getDataInt("pin_try")+1 .. "/" .. config.try .. "try. After it, your depo will be blocked.")
else
db.executeQuery("UPDATE `players` SET `pin_try` = '".. pin_query:getDataInt("pin_try")+1 .."', `blocked` = '".. os.clock()+(config.times*pin_query:getDataInt("pin_try")) .."' WHERE `id` = " .. getPlayerGUID(cid))
doPlayerSendTextMessage(cid, 22, "Sorry, but your PIN Code is wrong. Your account is blocked becouse it was last try(".. pin_query:getDataInt("try") .."/".. config.try ..")")
end
end
else
doPlayerSendTextMessage(cid, 22, "You've blocked your depo. Block will disapear in ".. pin_query:getDataInt("blocked")-os.clock() .. "secounds")
end
pin_query:free()
else
doPlayerSendTextMessage(cid, 22, "PIN Code has to have 4 nubers.")
end
else
doPlayerSendTextMessage(cid, 22, "You haven't typed your pin or new pin. Good comend is /changepin your_pin, new_pin")
end
elseif(words == "/lock") then
doPlayerSendTextMessage(cid, 22, "Depo has been locked.")
setPlayerStorageValue(cid, config.storage, -2)
elseif(words == "/install-depo") then
local iquery = db.executeQuery("ALTER TABLE `players` ADD `pin` INT( 4 ) NULL AFTER `posz` , ADD `pin_try` INT( 8 ) NOT NULL DEFAULT '0' AFTER `pin` , ADD `blocked` BIGINT ( 20 ) NOT NULL DEFAULT '0' AFTER `pin_try`;")
print(iquery)
if(iquery) then
doPlayerSendTextMessage(cid, 22, "Depo for PIN has been installed !")
else
doPlayerSendTextMessage(cid, 22, "An error has incluted!")
end
elseif(words == "/uninstall-depo") then
local dquery = db.executeQuery("ALTER TABLE `players` DROP `pin` , DROP `pin_try` , DROP `blocked` ;")
if(dquery) then
doPlayerSendTextMessage(cid, 22, "Depo for PIN has been uninstalled !")
else
doPlayerSendTextMessage(cid, 22, "An error has incluted!")
end
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local pin_query = db.getResult("SELECT `pin`, `pin_try`, `blocked` FROM `players` WHERE `id` = ".. getPlayerGUID(cid))
if(getPlayerStorageValue(cid, config.storage) >= 2) then
setPlayerStorageValue(cid, config.storage, -2)
elseif(pin_query:getDataInt("pin") == 0) then
else
doPlayerSendTextMessage(cid, 22, "You haven't typed your pin by comend /pin \"pin(4 numbers) ! If you haven't got pin type /createpin \"your pin(4 numbers). If you want to have random pin, type /createpin \"random.")
return true
end
pin_query:free()
end