Arkam
Forum friend
- Joined
- Dec 20, 2008
- Messages
- 1,980
- Reaction score
- 180
Na w?asne potrzeby napisa?em takiego skrypta, kt?ry rozdaje okre?lon? liczb? pkt premium wszystkim ludziom kt?rzy byli kiedy? zalogowane [mozna ustawi? kiedy ostatnio], dodatkowo s? jakie? tam filtry ?eby dzieci nie zak?ada?y xxx kont aby dosta? free pp czyli:
1. Sprawdzanie ip postaci z kt?rych zak?ada?o si? konto
2. Sprawdza emaile [brak dubli x kont z tym samym mailem]
3. Blacklista maili
Nie optymalny ci??ko konfigurowalny ale wrzucam bo mo?e komu? si? przyda xd
[lua]
function pyGetSecondSrvPlayersAccountIDs()
local tmpTable = {}
local allResoult = db.getResult("select a.id from accounts a left join players p on p.account_id = a.id where p.world_id = 1 and p.lastlogin > 0") --World id mozna sobie zmienic na jaki sie tam ma jak tylko 1 srv to pewnie 0
if allResoult:getID() ~= -1 then
repeat
table.insert(tmpTable, allResoult:getDataInt("id"))
until not(allResoult:next())
allResoult:free()
end
return tmpTable;
end
function pyFirstStep()
local tmptable = {};
tmpTable = pyGetSecondSrvPlayersAccountIDs();
if not tmpTable then
return false
end
local tmp = {};
for i = 1, table.getn(tmpTable) do
if(not isInArray(tmp, tmpTable)) then
table.insert(tmp, tmpTable)
end
end
print("Accounts on start:")
print(table.getn(tmp))
return tmp;
end
function pyFirstQuery(account_id)
local tmpQuery = db.getResult("SELECT create_ip FROM accounts WHERE id = "..account_id..";");
local res = tmpQuery:getDataInt("create_ip");
tmpQuery:free();
return res;
end
function pySortAccountsIpAddresses(accIDsTable)
local tmpTable = {
accountID = {},
accountIP = {}
};
for i = 1, #accIDsTable do
local obiekt = pyFirstQuery(accIDsTable);
tmpTable.accountID = accIDsTable;
tmpTable.accountIP = obiekt;
end
if(table.getn(tmpTable.accountID) ~= table.getn(tmpTable.accountIP)) then
print("FATAL ERROR")
return false
end
local tmpSorted = {}; --Store ips
local goNextIDs = {}; --Store good accounts ids
for i = 1, table.getn(tmpTable.accountIP) do
if(not isInArray(tmpSorted, tmpTable.accountIP)) then
table.insert(tmpSorted, tmpTable.accountIP);
table.insert(goNextIDs, tmpTable.accountID);
end
end
print("Cleaning by IP - Done")
-- print(table.getn(accIDsTable));
print(table.getn(goNextIDs));
return goNextIDs;
end
function pySecondQuery(account_id)
local tmpQuery = db.getResult("SELECT email FROM accounts WHERE id = "..account_id..";");
local res = tmpQuery:getDataString("email");
tmpQuery:free();
return res;
end
function pyGetPremiumPointsQuery(account_id)
local tmpQuery = db.getResult("SELECT premium_points FROM accounts WHERE id = "..account_id..";");
local res = tmpQuery:getDataInt("premium_points");
tmpQuery:free();
return res;
end
function pyaddPremiumPointsQuery(account_id, addpoints)
local pkty = pyGetPremiumPointsQuery(account_id);
print(account_id)
print(pkty)
pkty = pkty + addpoints;
db.executeQuery("UPDATE accounts SET premium_points = "..pkty.." WHERE id = "..account_id..";");
end
function pyThirdStep(accIDsTable, ilepkt) --check mails
local tmpTable = {
accountID = {},
accountMail= {}
};
for i = 1, #accIDsTable do
local obiekt = pySecondQuery(accIDsTable);
tmpTable.accountID = accIDsTable;
tmpTable.accountMail = obiekt;
end
if(table.getn(tmpTable.accountID) ~= table.getn(tmpTable.accountMail)) then
print("FATAL ERROR")
return false
end
local tmpSorted = {}; --Store emails
local blacklist_emails = {"asd@wp.pl","cxz@wp.pl","xcvb@wp.pl"}
for i = 1, table.getn(tmpTable.accountMail) do
if(not isInArray(tmpSorted, tmpTable.accountMail)) then
if(not isInArray(blacklist_emails, tmpTable.accountMail)) then
table.insert(tmpSorted, tmpTable.accountMail);
pyaddPremiumPointsQuery(tmpTable.accountID, ilepkt)
end
end
end
end
[/lua]
Przyk?adowe u?ycie:
[lua]pyThirdStep(pySortAccountsIpAddresses(pyFirstStep()),6)[/lua]
//1x uzywalem funkcjuuuuffff z baza wiec pewnie cos nie potrzebnie jebnalem ale wazne ze dziala
1. Sprawdzanie ip postaci z kt?rych zak?ada?o si? konto
2. Sprawdza emaile [brak dubli x kont z tym samym mailem]
3. Blacklista maili
Nie optymalny ci??ko konfigurowalny ale wrzucam bo mo?e komu? si? przyda xd
[lua]
function pyGetSecondSrvPlayersAccountIDs()
local tmpTable = {}
local allResoult = db.getResult("select a.id from accounts a left join players p on p.account_id = a.id where p.world_id = 1 and p.lastlogin > 0") --World id mozna sobie zmienic na jaki sie tam ma jak tylko 1 srv to pewnie 0
if allResoult:getID() ~= -1 then
repeat
table.insert(tmpTable, allResoult:getDataInt("id"))
until not(allResoult:next())
allResoult:free()
end
return tmpTable;
end
function pyFirstStep()
local tmptable = {};
tmpTable = pyGetSecondSrvPlayersAccountIDs();
if not tmpTable then
return false
end
local tmp = {};
for i = 1, table.getn(tmpTable) do
if(not isInArray(tmp, tmpTable)) then
table.insert(tmp, tmpTable)
end
end
print("Accounts on start:")
print(table.getn(tmp))
return tmp;
end
function pyFirstQuery(account_id)
local tmpQuery = db.getResult("SELECT create_ip FROM accounts WHERE id = "..account_id..";");
local res = tmpQuery:getDataInt("create_ip");
tmpQuery:free();
return res;
end
function pySortAccountsIpAddresses(accIDsTable)
local tmpTable = {
accountID = {},
accountIP = {}
};
for i = 1, #accIDsTable do
local obiekt = pyFirstQuery(accIDsTable);
tmpTable.accountID = accIDsTable;
tmpTable.accountIP = obiekt;
end
if(table.getn(tmpTable.accountID) ~= table.getn(tmpTable.accountIP)) then
print("FATAL ERROR")
return false
end
local tmpSorted = {}; --Store ips
local goNextIDs = {}; --Store good accounts ids
for i = 1, table.getn(tmpTable.accountIP) do
if(not isInArray(tmpSorted, tmpTable.accountIP)) then
table.insert(tmpSorted, tmpTable.accountIP);
table.insert(goNextIDs, tmpTable.accountID);
end
end
print("Cleaning by IP - Done")
-- print(table.getn(accIDsTable));
print(table.getn(goNextIDs));
return goNextIDs;
end
function pySecondQuery(account_id)
local tmpQuery = db.getResult("SELECT email FROM accounts WHERE id = "..account_id..";");
local res = tmpQuery:getDataString("email");
tmpQuery:free();
return res;
end
function pyGetPremiumPointsQuery(account_id)
local tmpQuery = db.getResult("SELECT premium_points FROM accounts WHERE id = "..account_id..";");
local res = tmpQuery:getDataInt("premium_points");
tmpQuery:free();
return res;
end
function pyaddPremiumPointsQuery(account_id, addpoints)
local pkty = pyGetPremiumPointsQuery(account_id);
print(account_id)
print(pkty)
pkty = pkty + addpoints;
db.executeQuery("UPDATE accounts SET premium_points = "..pkty.." WHERE id = "..account_id..";");
end
function pyThirdStep(accIDsTable, ilepkt) --check mails
local tmpTable = {
accountID = {},
accountMail= {}
};
for i = 1, #accIDsTable do
local obiekt = pySecondQuery(accIDsTable);
tmpTable.accountID = accIDsTable;
tmpTable.accountMail = obiekt;
end
if(table.getn(tmpTable.accountID) ~= table.getn(tmpTable.accountMail)) then
print("FATAL ERROR")
return false
end
local tmpSorted = {}; --Store emails
local blacklist_emails = {"asd@wp.pl","cxz@wp.pl","xcvb@wp.pl"}
for i = 1, table.getn(tmpTable.accountMail) do
if(not isInArray(tmpSorted, tmpTable.accountMail)) then
if(not isInArray(blacklist_emails, tmpTable.accountMail)) then
table.insert(tmpSorted, tmpTable.accountMail);
pyaddPremiumPointsQuery(tmpTable.accountID, ilepkt)
end
end
end
end
[/lua]
Przyk?adowe u?ycie:
[lua]pyThirdStep(pySortAccountsIpAddresses(pyFirstStep()),6)[/lua]
//1x uzywalem funkcjuuuuffff z baza wiec pewnie cos nie potrzebnie jebnalem ale wazne ze dziala