• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action New players get XX ammount of premium days

Sonical

Inactive
Joined
Jan 11, 2010
Messages
1,238
Solutions
1
Reaction score
85
Location
:-:----:-:
Version 1.
With this version you can get prem days only 1 time per account.
Another version below this!

In database run this command
PHP:
ALTER TABLE `accounts` ADD `premused` INT( 11 ) NOT NULL DEFAULT '0'
Go to the data/lib/ and open functions.lua and add
Code:
function getPlayerPremUsed(cid)
    local Info = db.getResult("SELECT `premused` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local days= Info:getDataInt("premused")
        Info:free()
        return days
    end
     return LUA_ERROR
end
In creaturescripts.xml add
Code:
	<event type="login" name="Premmy" event="script" value="Premmylogg.lua"/>
In login.lua add
LUA:
	registerCreatureEvent(cid, "Premmy")
Premmylogg.lua
LUA:
local config ={
	days = 2 --Edit how many days
}
function onLogin(cid)
if getPlayerPremUsed(cid) == 0 then
	db.executeQuery("UPDATE `accounts` SET `premdays` = `premdays` + ".. config.days .." WHERE id = " .. getPlayerAccountId(cid) .. ";")
	db.executeQuery("UPDATE `accounts` SET `premused` = 1 WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
return TRUE
end
It worked, I tested it already :D
Tested with 0.4




Version 2.
With this you can get 2 premium with one character. 1 char = 2 days, 2 char = 4 days etc.
Same login.lua and creaturescripts.xml as above, don't add that new column into your database! It isn't necessary with this script!
But edit
Premmylogg.lua
LUA:
local config ={
	days = 2 --Edit how many days
}
function onLogin(cid)
queststatus = getPlayerStorageValue(cid,1147)

if queststatus == -1 then
	db.executeQuery("UPDATE `accounts` SET `premdays` = `premdays` + ".. config.days .." WHERE id = " .. getPlayerAccountId(cid) .. ";")
        setPlayerStorageValue(cid,1147,1)
end
return TRUE
end
Tested with 0.4

REP++ Please :thumbup:
 
Last edited:
Where did you test it?im using tfs 0.36pl1 and its not working :/
 
LUA:
local config ={
	days = 2 --Edit how many days
}
function onLogin(cid)
queststatus = getPlayerStorageValue(cid,1147)

if queststatus == -1 then
	db.executeQuery("UPDATE `accounts` SET `premdays` = `premdays` + ".. config.days .." WHERE id = " .. getPlayerAccountId(cid) .. ";")
        setPlayerStorageValue(cid,1147,1)
end
return TRUE
end

LUA:
local config ={
	days = 2
}

function onLogin(cid)

	if getAccountStorageValue(cid, 1147) == -1 then
		doPlayerAddPremiumDays(cid, config.days)
		setAccountStorageValue(cid, 1147, 1)
	end
	return true
end

You can use this code aswell but you need 2 functions from here:
http://otland.net/f163/account-storage-93908/#post952668
 
Back
Top