Knight God
Member
- Joined
- Oct 19, 2008
- Messages
- 1,180
- Reaction score
- 21
Scripts Onlook for Mix.
Frags OnLook
Military Ranks OnLook:
Quest OnLook
Please grouping these scripts all in a mod if is possible :S
Frags OnLook
PHP:
--Script By Theax ""
function getPlayerFrags(cid)
local time = os.time()
local times = {today = (time - 86400), week = (time - (7 * 86400))}
local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
if(result:getID() ~= -1) then
repeat
local content = {date = result:getDataInt("date")}
if(content.date > times.today) then
table.insert(contents.day, content)
elseif(content.date > times.week) then
table.insert(contents.week, content)
else
table.insert(contents.month, content)
end
until not result:next()
result:free()
end
local size = {
day = table.maxn(contents.day),
week = table.maxn(contents.week),
month = table.maxn(contents.month)
}
return size.day + size.week + size.month
end
function onLogin(cid)
registerCreatureEvent(cid,'FragsOnLook')
return true
end
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) and thing.uid ~= cid then
doPlayerSetSpecialDescription(thing.uid,' [Frags: '..getPlayerFrags(thing.uid)..']')
return true
elseif thing.uid == cid then
doPlayerSetSpecialDescription(cid,' [Frags: '..getPlayerFrags(cid)..']')
local string = 'You see yourself.'
if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
string = string..' You are '.. getPlayerGroupName(cid) ..'.'
elseif getPlayerVocation(cid) ~= 0 then
string = string..' You are '.. getPlayerVocationName(cid) ..'.'
else
string = string..' You have no vocation.'
end
string = string..getPlayerSpecialDescription(cid)..''
if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then
string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.'
end
if getPlayerGuildId(cid) > 0 then
string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
end
if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
string = string..'Health: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
string = string..'IP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
end
if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
string = string..'Position: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
return false
end
return true
end
Military Ranks OnLook:
PHP:
<?xml version = "1.0" encoding = "UTF-8"?>
<mod name = "Military Ranks" version = "1.0" author = "Teckman" enabled = "yes">
<config name = "ranks"><![CDATA[
titles = {
[5] = "Private First Class",
[10] = "Specialist",
[15] = "Corporal",
[20] = "Sergeant",
[25] = "Staff Sergeant",
[30] = "Sergeant First Class",
[35] = "Master Sergeant",
[40] = "First Sergeant",
[45] = "Sergeant Major",
[50] = "Command Sergeant Major",
[55] = "Sergeant Major of the Army",
[60] = "Second Lieutenant",
[65] = "First Lieutenant",
[70] = "Captain",
[75] = "Major",
[80] = "Lieutenant Colonel",
[90] = "Colonel",
[100] = "Brigadier General",
[110] = "Major General",
[120] = "Lieutenant General",
[140] = "General",
[170] = "General of the Army"
}
fragsStorage = 600
]]></config>
<event type = "look" name = "ranksLook" event = "script"><![CDATA[
domodlib("ranks")
function onLook(cid, thing, position, lookDistance)
if(isPlayer(thing.uid)) then
local rank = {rank = "Private", frags = 0}
for k, v in pairs(titles) do
if(math.max(0, getPlayerStorageValue(thing.uid, fragsStorage)) > k - 1) then
if(k - 1 > rank.frags) then
rank.rank, rank.frags = v, k - 1
end
end
end
doPlayerSetSpecialDescription(thing.uid, "\n Military rank: " .. rank.rank)
end
return true
end
]]></event>
<event type = "kill" name = "ranksKill" event = "script"><![CDATA[
domodlib("ranks")
function onKill(cid, target)
if(isPlayer(target)) then
setPlayerStorageValue(cid, fragsStorage, math.max(0, getPlayerStorageValue(cid, fragsStorage) + 1))
if(titles[getPlayerStorageValue(cid, fragsStorage)]) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You advanced to military rank: " .. titles[getPlayerStorageValue(cid, fragsStorage)] .. ". Congratulations " .. titles[getPlayerStorageValue(cid, fragsStorage)] .. "!")
end
end
return true
end
]]></event>
<event type = "login" name = "ranksLogin" event = "script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "ranksKill")
registerCreatureEvent(cid, "ranksLook")
return true
end
]]></event>
</mod>
Quest OnLook
PHP:
function onLook(cid, thing, position, lookDistance)
local quests = {1026, 1027, 10519, 11235, 12901, 12902, 12903, 12904, 14000, 14001, 14002, 14003, 14004, 14005, 14006, 14007, 14008, 20001, 20002, 2128, 2146, 2147, 2149, 2150, 2160, 2165, 2173, 2190, 2197, 2343, 2392, 2393, 2407, 2414, 2425, 2430, 2434, 2469, 2476, 2477, 2496, 2498, 2505, 2528, 2538, 2542, 2646, 3972, 42361, 42362, 42363, 42364, 42365, 42371, 42372, 42373, 42374, 42375, 42381, 42382, 42383, 42384, 42385, 5001, 5002, 5005, 5006, 5010, 5011, 5012, 5013, 5015, 5016, 5019, 5021, 5022, 5023, 5029, 5031, 5033, 5034, 5035, 5036, 5037, 5038, 5039, 5040, 5041, 5042, 5043, 5044, 5045, 5046, 5047, 5048, 5049, 5050, 5051, 5053, 5054, 5058, 5059, 5060, 5064, 5065, 5073, 5074, 5080, 5084, 5089, 5093, 5550, 5551, 5552, 5553, 5554, 5555, 5556, 5557, 5558, 5559, 5560, 5561, 5562, 5563, 5564, 5710, 58267, 58268, 58269, 5924, 5945, 5957, 6107, 6529, 7004, 11236, 7416, 7417, 7511, 7512, 7513, 7514, 7515, 7516, 7517, 7809, 8857, 8884, 8889, 8907, 8909, 9996, 9997, 2433, 2152, 9019, 40001, 8865, 9179, 40003, 12568, 40005, 40007, 7343, 10518, 10519, 10520, 2503, 11073, 11074, 10001, 10002, 10003, 10004, 10005, 10007, 20006, 20005, 10006, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10017, 10018, 10019, 10020, 10021, 10022, 10023, 10024, 10025, 10026, 10027, 10028, 10029, 10030, 10031, 10032, 10033, 10034, 10035, 10036, 10037, 10039, 10039, 10040, 10041, 10042, 10043, 10044, 10045, 7773, 8024, 8025, 8026, 8027, 8013, 8014, 8015, 1000, 1037, 8300, 1100, 2000, 2420, 8039, 8036, 8037, 8038, 8040, 8041, 8042, 8043, 8055, 8056, 8057, 8016, 8017, 8018, 8024, 8025, 8026, 8027, 8028, 8029, 8030, 8031, 8032, 8033, 8034, 8035, 7775, 7899, 8999, 2486, 2491, 50002, 50003, 2001, 2002, 12363}
local completed = {}
if isPlayer(thing.uid) then
for i = 1, #quests do
if getPlayerStorageValue(thing.uid, quests[i]) > 0 then
table.insert(completed, 1)
end
end
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nshe" or ".\nhe") .. " is completed ".. #completed .. "/" .. #quests .. " quests")
doPlayerSendTextMessage(cid, 27, getPlayerName(thing.uid) .. " is completed " .. #completed .. "/" .. #quests .. " quests.")
end
return true
end
Please grouping these scripts all in a mod if is possible :S