• 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!

Free premmy on start !

Mefiu

New Member
Joined
Mar 2, 2008
Messages
221
Reaction score
0
Hello,
How i can make free 5 days of premium only on start ?

Thanks in advance,
Mefiu.
 
Creaturescript>Login:

Code:
				function onLogin(cid)
 local config =
{
   days = 5
   premiumStor = 321321
}
 local FALSE = -1
 local TRUE = 1
	if getPlayerStorageValue(cid, config.premiumStor) == FALSE then
	   doPlayerAddPremiumDays(cid, days)
	   setPlayerStorageValue(cid, config.premiumStor, TRUE)
 end
 return TRUE
end
 
@Aarthec
I don't think so because u can see
Code:
if getPlayerStorageValue(cid, config.premiumStor) == FALSE then
so only players without storagevalue 321321 will get premmy. If he loggs again, he won't grant the condition.

But i only suppose.

I'm going to try it now :)
 
That's not what I said, I said if he makes a new character on the same account, and yes, the storage value sets so that character can only do it once.
 
Yeah when i make another character on the same account it adds another 5 days of premium ;//

I saw on many ot servs that players have few days of premium for free.

Can some1 help ?
 
Changed bombas script, should work if you add the function.
PHP:
function onLogin(cid)
 local config =
{
   days = 5
   premiumStor = 321321
}
 local FALSE = -1
 local TRUE = 1
	if getAccountStorageValue(cid, config.premiumStor) == FALSE then
	   doPlayerAddPremiumDays(cid, days)
	   setAccountStorageValue(cid, config.premiumStor, TRUE)
 end
 return TRUE
end
 
Formated (and fixed); D
Code:
local config =
{
	days = 5,
	storage = 321321
}

function onLogin(cid)
	if(getAccountStorageValue(cid, config.storage) == -1) then
		doPlayerAddPremiumDays(cid, config.days)
		setAccountStorageValue(cid, config.storage, 1)
	end
	return TRUE
end
 
If you are using Unnamed account by Gesior, you can set how many days of premium should have the brand new created accounts.
Another option would be to set free premium on config.lua and after 5 days turn that off.
 
\data\creaturescripts\scripts\free_premium.LUA:
Code:
function onLogin(cid)
 local config =
{
   days = 5
   premiumStor = 321321
}
 local FALSE = -1
 local TRUE = 1
    if getAccountStorageValue(cid, config.premiumStor) == FALSE then
       doPlayerAddPremiumDays(cid, config.days)
       setAccountStorageValue(cid, config.premiumStor, TRUE)
 end
 return TRUE
end

\data\creaturescripts\creaturescripts.XML:
Code:
	<event type="login" name="FreePremium" script="free_premium.lua"/>

\data\lib\function.LUA:
Code:
 function getAccountStorageValue(accid, key)
  local value = db.getResult("SELECT `value` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key .. " LIMIT 1;")
   if(value:getID() ~= -1) then
    return value:getDataInt("value")
   else
    return -1
   end
   value:free()
 end
 
 
 function setAccountStorageValue(accid, key, value)
  local getvalue = db.getResult("SELECT `value` FROM `account_storage` WHERE `account_id` = " .. accid .. " and `key` = " .. key .. " LIMIT 1;")
   if(getvalue:getID() ~= -1) then
   db.executeQuery("UPDATE `account_storage` SET `value` = " .. accid .. " WHERE `key`=" .. key .. " LIMIT 1');")
   getvalue:free()
   return 1
   else
   db.executeQuery("INSERT INTO `account_storage` (`account_id`, `key`, `value`) VALUES (" .. accid .. ", " .. key .. ", '"..value.."');")
   return 1
   end
 end

...and to database:
Code:
CREATE TABLE `account_storage` (
  `account_id` int(11) NOT NULL default '0',
  `key` int(10) unsigned NOT NULL default '0',
  `value` varchar(255) NOT NULL default '0',
  UNIQUE KEY `account_id_2` (`account_id`,`key`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
Back
Top