Slave Ots
LUA Newbie™
hi otlanders
this script was in there http://otland.net/f82/giving-xx-premium-points-first-xx-loggers-your-server-183336/
but i made this post for just adding the account storage, so that each account get premium points one time or more[configured]
here we go
account storage: credits for teckman
1- run this query
2-in data / lib / 050-function.lua add
3- now goto data / creaturescript / create new file 'free_points'
4-goto creaturescripts.xml
add
5-last step goto login.lua and add
rep++ me if you likes it
king regards
Slave OTs
this script was in there http://otland.net/f82/giving-xx-premium-points-first-xx-loggers-your-server-183336/
but i made this post for just adding the account storage, so that each account get premium points one time or more[configured]
here we go
account storage: credits for teckman
1- run this query
PHP:
CREATE TABLE IF NOT EXISTS `accounts_storage` (
`id` int(11) NOT NULL DEFAULT '0',
`key` int(10) NOT NULL DEFAULT '0',
`value` varchar(255) NOT NULL DEFAULT '0',
UNIQUE KEY `id_key` (`id`,`key`),
KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
2-in data / lib / 050-function.lua add
Code:
function setAcccountStorageValue(cid, key, value)
local result = db.getResult("SELECT `key` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');")
if result:getDataInt("key") == nil then
return db.executeQuery("INSERT INTO `accounts_storage` (`id`, `key`, `value`) VALUES (" .. getPlayerAccountId(cid) .. ", " .. key .. ", " .. value .. ")"), result:free()
else
return db.executeQuery("UPDATE `accounts_storage` SET `value` = " .. value .. " WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');"), result:free()
end
end
function getAccountStorageValue(cid, key)
local value = db.getResult("SELECT `value` FROM `accounts_storage` WHERE (`id` = '" .. getPlayerAccountId(cid) .. "' and `key` = '" .. key .. "');")
return value:getDataInt("value"), value:free()
end
3- now goto data / creaturescript / create new file 'free_points'
Code:
function onLogin(cid)
local free_points = 10 -- amount of points to add
local storage_1 = 15253 --put any empty storage for counting the ten times
local storage_2 = 15251 --empty storage for players
local rewardsplayer = 10 -- it now give for first 10 players - edit it however you want
local tries_acc = 1 -- this to how many times it add points for charcters per one account
local pos = getPlayerPosition(cid)
local function doPlayerAddPremiumPoints(cid, points)
return db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points`+"..points.." WHERE `id` = "..getPlayerAccountId(cid)..";")
end
if isPlayer(cid) and getGlobalStorageValue(storage_1) < (rewardsplayer - 1) then
if getCreatureStorage(cid, storage_2) < 0 then
if getAccountStorageValue(cid, storage_2) < tries_acc then
doPlayerAddPremiumPoints(cid, free_points)
doPlayerSendTextMessage(cid, 19, 'you have been rewarded with ' .. free_points .. ' premium points. for being one of the first records here')
doCreatureSetStorage(cid, storage_2, 1)
setAccountStorageValue(cid, storage_2, getAccountStorageValue(cid, storage_2) == -1 and 1 or getAccountStorageValue(cid, storage_2) + 1)
setGlobalStorageValue((storage_1), getGlobalStorageValue(storage_1) +1)
end
end
end
return true
end
4-goto creaturescripts.xml
add
PHP:
<event type="login" name="free_points" event="script" value="free_points.lua"/>
5-last step goto login.lua and add
Code:
registerCreatureEvent(cid, "free_points")
rep++ me if you likes it
king regards
Slave OTs