What's new

-Tibia 8.60 System zaprosze?

buchaLL

bez spiny, luźno
Joined
Aug 2, 2011
Messages
1,013
Reaction score
68
Age
27
Autor: Vodkart
Opis: System oferuje nagrody takie jak: przedmioty, dni premium, punkty premium oraz addony. Oczywi?cie wszystko mo?na skonfigurowa? wed?ug w?asnych upodoba?.

Punkty w systemie:
levels_win = {
[ 50 ] = 5 ,
[ 80 ] = 6 ,
[ 100 ] = 8 ,
[ 150 ] = 10 ,
[ 180 ] = 15
}

Dzia?a to na takiej zasadzie, ?e gdy zaproszony przez nas gracz wbije poziom 50, otrzymujemy za niego 5 pkt. Po uzbieraniu konkretnej liczby punkt?w otrzymujemy nagrody.
Uwaga: Ilo?? zaproszonych graczy jest nieograniczona.

Nagrody:
rewards = {[10] = {items = {{2160,1},{2173,1}}, p_days = 10, p_points = 10 , out = {128,136}}}

10 - ilo?? punkt?w jak? trzeba zebra? by otrzyma? nagrody.
items = {{2160,1},{2173,1}} - itemy jakie otrzymujemy, w tym przypadku (2160 - cc, 2173 - aol).
p_days = 10 - ilo?? dni pacc
p_points = 10 - ilo?? punkt?w premium
out = {128,136} - full addon, w tym przypadku full Citizen 128(female), 136(male), gdy ustawimy na out = {0,0} otrzymujemy wszystkie addony
- lookType addon?w mo?emy sprawdzi? w pliku outfits.xml

Instalacja:
data \ creaturescripts \ scripts \ InviteFriends.lua

[LUA]function onLogin(cid)
registerCreatureEvent(cid, "FriendsPoints")
if getPlayerStorageValue(cid, _invite_friends.storages[1]) < 0 then
setPlayerStorageValue(cid, _invite_friends.storages[1], 0)
setPlayerStorageValue(cid, _invite_friends.storages[4], 0)
end
if getInvitePoints(cid) > 0 then
getRewardsFriend(getCreatureName(cid), getPlayerGUID(cid))
end
return true
end
function onAdvance(cid, skill, oldLevel, newLevel)
if (skill == SKILL__LEVEL) then
if hasInviteFriend(cid) and getPlayerStorageValue(cid, _invite_friends.storages[3]) < newLevel and _invite_friends.levels_win[newLevel] then
local f_name, points = getNameFriend(cid), _invite_friends.levels_win[newLevel]
local f_pid = getPlayerGUIDByName(f_name)
setPlayerStorageValue(cid, _invite_friends.storages[3], newLevel)
addInvitePoints(f_name, points)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[System zaproszen] Osiagnales "..newLevel.." poziom, gracz "..f_name.." otrzymal "..points.." punktow!")
if isPlayer(getPlayerByNameWildcard(f_name)) then
getRewardsFriend(f_name, f_pid)
end
end
end
return true
end[/LUA]


creaturescript.xml
[LUA]<event type="login" name="FriendsLogin" event="script" value="InviteFriends.lua"/>
<event type="advance" name="FriendsPoints" event="script" value="InviteFriends.lua"/>[/LUA]


data \ talkactions \ scripts \ InviteFriends.lua

[LUA]function onSay(cid, words, param, channel)
local param = param:lower()
if param == "" or not param then
doPlayerSendCancel(cid, "Musisz podac nazwe gracza.") return true
elseif param == "points" then
doPlayerPopupFYI(cid,"[System zaproszen]\n\nPosiadasz "..getInvitePoints(cid).." punktow.") return true
elseif hasInviteFriend(cid) then
doPlayerSendCancel(cid, "Juz wybrales gracza "..getNameFriend(cid).." jako osobe ktora Cie zaprosila.") return true
elseif not getPlayerGUIDByName(param) then
doPlayerSendCancel(cid, "Niestety, ale gracz ".. param .." nie istnieje.") return true
elseif getPlayerLevel(cid) > _invite_friends.level_max or db.getResult("SELECT `level` FROM `players` WHERE `id` = "..getPlayerGUIDByName(param)):getDataInt("level") < _invite_friends.level_need then
doPlayerSendCancel(cid, (getPlayerLevel(cid) > _invite_friends.level_max and "Twoj poziom nie moze byc wyzszy niz ".._invite_friends.level_max.." by uzyc tego polecenia." or "Niestety, ale gracz "..param.." musi byc conajmniej na poziomie ".._invite_friends.level_need.." do wybrania go.")) return true
elseif getCreatureName(cid):lower() == param then
doPlayerSendCancel(cid, "Niestety, nie mo?na zaprosi? samego siebie.") return true
end
doInviteFriend(cid, getPlayerGUIDByName(param))
doPlayerSendTextMessage(cid, 25, "Zostales zaproszony przez gracza "..param..".")
doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
return true
end[/LUA]


talkactions.xml
[LUA]<talkaction words="/invited;!invited" event="script" value="InviteFriends.lua"/>[/LUA]


data \ lib \ InviteFriends.lua

[LUA]_invite_friends = {
storages = {202301, 202302, 202303, 202304},
level_max = 20, -- poziom gracza nie mo?e przekroczy? podanego, aby u?y? komendy przez kogo zosta? zaproszony
level_need = 30, -- poziom gracza kt?ry nas zaprosi? musi by? wi?kszy ni? podany
levels_win = {
[50] = 5,
[80] = 6,
[100] = 8,
[150] = 10,
[180] = 15
},
rewards = {
[10] = {items = {{2160,1},{2173,1}}, p_days = 10, p_points = 10 , out = {128,136}},
[25] = {items = {{2160,2},{2173,1}}, p_days = 0, p_points = 0 , out = {0,0}},
[50] = {items = {{2160,3},{2173,1}}, p_days = 0, p_points = 0 , out = {0,0}},
[100] = {items = {{2160,4},{2173,1}}, p_days = 0, p_points = 0 , out = {0,0}},
[200] = {items = {{2160,5},{2173,1}}, p_days = 0, p_points = 0 , out = {0,0}},
[250] = {items = {{2160,6},{2173,1}}, p_days = 0, p_points = 0 , out = {0,0}},
[500] = {items = {{2160,7},{2173,1}}, p_days = 0, p_points = 0 , out = {0,0}}
}
}
function getInvitePoints(cid)
return getPlayerStorageValue(cid, _invite_friends.storages[1]) < 0 and 0 or getPlayerStorageValue(cid, _invite_friends.storages[1])
end
function hasInviteFriend(cid)
return getPlayerStorageValue(cid, _invite_friends.storages[2]) > 0 and true or false
end
function doInviteFriend(cid, GUID)
return setPlayerStorageValue(cid, _invite_friends.storages[2], GUID)
end
function getNameFriend(cid)
return getPlayerNameByGUID(getPlayerStorageValue(cid, _invite_friends.storages[2]))
end
function addInvitePoints(name, amount)
local pid, Guid = getPlayerByNameWildcard(name), getPlayerGUIDByName(name)
if not pid then
local getFriendPoints = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = ".. Guid .." AND `key` = ".._invite_friends.storages[1])
if (getFriendPoints:getID() ~= -1) then
db.executeQuery("UPDATE `player_storage` SET `value` = ".. (getFriendPoints:getDataInt("value")+amount) .." WHERE `player_id` = ".. Guid .." AND `key` = ".._invite_friends.storages[1])
end
else
setPlayerStorageValue(getPlayerByName(name), _invite_friends.storages[1], getInvitePoints(getPlayerByName(name))+amount)
end
return true
end
function getRewardsFriend(name, pid)
local acc = getAccountIdByName(name)
if isPlayer(getPlayerByNameWildcard(name)) then
local target = getPlayerByNameWildcard(name)
local FriendPoints, CheckPoints = getInvitePoints(target), getPlayerStorageValue(target, _invite_friends.storages[4])
for vod, ka in pairs(_invite_friends.rewards) do
local str = ""
if FriendPoints >= vod and CheckPoints < vod then
str = str.."--> System zaproszen <--\n\nOtrzymujesz: \n"..getItemsFromList(ka.items)..".\n\n"
if ka.p_days > 0 then
doPlayerAddPremiumDays(target, ka.p_days)
str = str.."Premium Days: "..ka.p_days.." "
end
if ka.p_points > 0 then
db.executeQuery('UPDATE accounts SET premium_points=premium_points+' .. ka.p_points ..' WHERE id=' .. acc)
str = str.."\nPremium Points: "..ka.p_points.." "
end
if ka.out[1] > 0 then
doPlayerAddOutfit(getPlayerByNameWildcard(name), getPlayerSex(getPlayerByNameWildcard(name)) == 0 and ka.out[1] or ka.out[2], 3)
str = str.."\nNowy addon."
end
setPlayerStorageValue(target, _invite_friends.storages[4], FriendPoints)
MandarItensProDp(name, ka.items, str)
doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_ORANGE,"[System zaproszen] Otrzymales nagrody za zaproszone przez siebie osoby.")
end
end
end
return true
end
function MandarItensProDp(name, items, texto)
local backpack = doPlayerAddItem(getPlayerByNameWildcard(name), 1999, 1) -- backpackID
for _, i_i in ipairs(items) do
local item, amount = i_i[1],i_i[2]
if isItemStackable(item) or amount == 1 then
doAddContainerItem(backpack, item, amount)
else
for i = 1, amount do
doAddContainerItem(backpack, item, 1)
end
end
end
local carta = doAddContainerItem(backpack, 1952)
doItemSetAttribute(carta, "writer", "[System zaproszen]")
doItemSetAttribute(carta, "text", texto)
return true
end
-- function adicional --
function getItemsFromList(items) -- by vodka
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[2] .. ' ' .. getItemNameById(items[1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end[/LUA]
 
Top