Action VIP System [0.3.5]

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
This script has been updated and fixed by JDB.
Although it was first edited by Trekes & Kaorus.
And was originally created by Empty.

The Forgotten Server 0.3.4 & 0.3.5
For More Information: http://otland.net/f82/vip-system-19426/

data/actions/actions.xml
PHP:
<action itemid="5807" script="other/vip.lua"/>
<action itemid="5806" script="other/vip.lua"/>
<action itemid="5805" script="other/vip.lua"/>
<action itemid="5785" script="other/vip.lua"/>
data/actions/scripts/other/vip.lua
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg =
{
    [5807] = {amount = (getPlayerStorageValue(cid)+30), days = 30}, -- Bronze Goblet
    [5806] = {amount = (getPlayerStorageValue(cid)+90), days = 60}, -- Silver Goblet
    [5805] = {amount = (getPlayerStorageValue(cid)+180), days = 180}, -- Golden Goblet
    [5785] = {amount = (getPlayerStorageValue(cid)+360), days = 360} -- Medal of Honor
}

local status = 10000
local storage = getPlayerStorageValue(cid, status)
    if (storage == -1) then
        doSendAnimatedText(getCreaturePosition(cid), "+".. cfg[item.itemid].days .." Days", TEXTCOLOR_LIGHTBLUE)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You are now a VIP Member for ".. cfg[item.itemid].days .." days.")
        setPlayerStorageValue(cid, status, cfg[item.itemid].amount)
        doRemoveItem(item.uid)
    else
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are already a VIP member.")
    end
    return true
end
data/globalevents/globalevents.xml
PHP:
<globalevent name="checkVip" interval="86400000" script="removeVipDays.lua"/>
<globalevent name="removeVip" interval="36000000" script="removeVip.lua"/>
data/globalevents/scripts/removeVipDays.lua
Lua:
local storage = 10000
function onThink(cid, item, fromPosition, toPosition)
    for _, name in ipairs(getOnlinePlayers()) do
	local player = getPlayerByName(name)
	if getPlayerStorageValue(player, storage) > 1 then
	    setPlayerStorageValue(player, storage, getPlayerStorageValue(player) - 1)
	end
    end
end
data/globalevents/scripts/removeVip.lua
Lua:
local storage = 10000
function onThink(cid, item, fromPosition, toPosition)
    for _, name in ipairs(getOnlinePlayers()) do
	local player = getPlayerByName(name)
	if getPlayerStorageValue(player, storage) == 1 then
	    setPlayerStorageValue(player, storage, 0)
	end
    end
end
NOTICE:
System has not been tested thoroughly.
If there are problem's, please report them here.
 
Last edited:

Saj

Remember my name
Joined
Feb 26, 2008
Messages
2,127
Best answers
0
Reaction score
5
Great! thanks!
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
Will not work, (getPlayerStorageValue(cid, vip) is outta parameters, and it can't get 'cid' value.
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
That is what was used in the older version and it worked.

How can I change it now?
 

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
Location
Canada
You also dont need Ends on elseif xd

Code:
-- Updated by JDB & Original Idea by Trekes --
-- Config --
local days = 
{ 
    [1] = {vipTime = (getPlayerStorageValue(cid, vipStatus)+ 30), vipItem = 5807 }, -- Bronze Goblet
    [2] = {vipTime = (getPlayerStorageValue(cid, vipStatus)+ 60), vipItem = 5806 }, -- Silver Goblet
    [3] = {vipTime = (getPlayerStorageValue(cid, vipStatus)+ 90), vipItem = 5805 } -- Golden Goblet
}
local vipStatus = 1234
--End Config --
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, vipStatus) == FALSE then
        if (item.itemid == days[1].vipItem) then
            doSendAnimatedText(getCreaturePosition(cid), "VIP", TEXTCOLOR_RED)
            doCreatureSay(cid, "CONGRATULATIONS! You are now a VIP for 30 days.", TALKTYPE_ORANGE_1)
            doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
            setPlayerStorageValue(cid, vipStatus, days[1].vipTime)
            doRemoveItem(item.uid, 1)
        elseif (item.itemid == days[2].vipItem) then
            doSendAnimatedText(getCreaturePosition(cid), "VIP", TEXTCOLOR_RED)
            doCreatureSay(cid, "CONGRATULATIONS! You are now a VIP for 60 days.", TALKTYPE_ORANGE_1)
            doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
            setPlayerStorageValue(cid, vipStatus, days[2].vipTime)
            doRemoveItem(item.uid, 1)
        elseif (item.itemid == days[3].vipItem) then
            doSendAnimatedText(getCreaturePosition(cid), "VIP", TEXTCOLOR_RED)
            doCreatureSay(cid, "CONGRATULATIONS! You are now a VIP for 90 days.", TALKTYPE_ORANGE_1)
            doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
            setPlayerStorageValue(cid, vipStatus, days[3].vipTime)
            doRemoveItem(item.uid, 1)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are already a VIP Member.")
    end
    return TRUE
end
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@Up,
Okay changed.

@Topic,
I was looking at Trekes thread and people said it worked.
I don't know if the storage thing will be a problem or not.
 

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,264
Best answers
0
Reaction score
54
Location
Venezuela
Chojrak is wrong, as I see it will work fine.. Its an action so it will return cid value, if it would be a globalevent it woulden't work.

PD: Do not forget to add in global events what Trekes says.
Trekes said:
OK, then go to globalevents/scripts and create 2 lua files

1.- removevipdays.lua
Code:
-- Credits StreamSide and Empty
function onThink(cid, item, fromPosition, toPosition)

	for _, name in ipairs(getOnlinePlayers()) do
		local player = getPlayerByName(name)
		if getPlayerStorageValue(player,11551) > 1 then
			setPlayerStorageValue(player,11551,getPlayerStorageValue(player) - 1)
		end
	end
end
2.- removevip.lua
Code:
-- Credits StreamSide and Empty
function onThink(cid, item, fromPosition, toPosition)

	for _, name in ipairs(getOnlinePlayers()) do
		local player = getPlayerByName(name)
		if getPlayerStorageValue(player,11551) == 1 then
			setPlayerStorageValue(player,11551,0)
		end
	end
end
And in globalevents.xml add this:
Code:
    <!-- VipSystem (Credits StreamSide and Empty) --!>
    <globalevent name="checkvip" interval="86400000" script="removevipdays.lua"/>
    <globalevent name="removevip" interval="36000000" script="removevip.lua"/>
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
@Up,
Some of those functions might be outdated,
but it should all be somewhat correct.
 

Jhon Herbert

I'm a Brazilian :P
Joined
Jan 28, 2009
Messages
5
Best answers
0
Reaction score
0
Location
Brazil
Error - My forgotten server is 0.3.4 and 0.3.5

PHP:
[11/08/2009 00:08:32] data/actions/scripts/VIP.lua:5: attempt to perform arithmetic on a boolean value
[11/08/2009 00:08:32] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/VIP.lua)
[11/08/2009 00:08:32] data/actions/scripts/VIP.lua:36: 'end' expected (to close 'function' at line 11) near '<eof>'
 
Last edited:

Wodian

Lorensia Developer.
Joined
Jun 2, 2007
Messages
204
Best answers
0
Reaction score
7
Location
The Netherlands
Thank you JDB.. Does it also works for 0.3.5?

Atleast im gonna test it ;) .. Ill let you hear :D

Wodian,,
 

GMBear

chaos revived Owner
Joined
Jan 28, 2008
Messages
575
Best answers
0
Reaction score
2
Location
New york
I reloaded actions and it still dont work 0.0 with silver goblet it just opens it so i can type
[11/08/2009 02:32:43] Lua Script Error: [Action Interface]
[11/08/2009 02:32:43] data/actions/scripts/Custom/vip.lua

[11/08/2009 02:32:43] luaGetPlayerStorageValue(). Player not found

[11/08/2009 02:32:43] Lua Script Error: [Action Interface]
[11/08/2009 02:32:43] data/actions/scripts/Custom/vip.lua

[11/08/2009 02:32:43] data/actions/scripts/Custom/vip.lua:5: attempt to perform arithmetic on a boolean value
[11/08/2009 02:32:43] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom/vip.lua)
please fix
 
Last edited:
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
You can try it now, I changed some things.
 

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
This script was originally created by Trekes.
All I did was make it more configurable and updated it.
... :eek: It was made by me, he just made some examples... >.<
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
I just got it from his thread, didn't know you made it.
Sorry :wub:
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Credit added to first post :thumbup:
 

GMBear

chaos revived Owner
Joined
Jan 28, 2008
Messages
575
Best answers
0
Reaction score
2
Location
New york
[11/08/2009 10:34:07] Admin Bear has logged in.
[11/08/2009 10:34:13] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom/vip.lua)
[11/08/2009 10:34:13] data/actions/scripts/Custom/vip.lua:27: 'end' expected (to close 'function' at line 11) near 'elseif'
[11/08/2009 10:34:13] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom/vip.lua)
[11/08/2009 10:34:13] data/actions/scripts/Custom/vip.lua:27: 'end' expected (to close 'function' at line 11) near 'elseif'
[11/08/2009 10:34:13] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom/vip.lua)
[11/08/2009 10:34:13] data/actions/scripts/Custom/vip.lua:27: 'end' expected (to close 'function' at line 11) near 'elseif'
[11/08/2009 10:34:13] Reloaded actions.
IDk whats wrong 0.0
 
OP
JDB

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Try it now.
 

GMBear

chaos revived Owner
Joined
Jan 28, 2008
Messages
575
Best answers
0
Reaction score
2
Location
New york
[11/08/2009 10:40:42] Lua Script Error: [Action Interface]
[11/08/2009 10:40:42] data/actions/scripts/Custom/vip.lua

[11/08/2009 10:40:42] luaGetPlayerStorageValue(). Player not found

[11/08/2009 10:40:42] Lua Script Error: [Action Interface]
[11/08/2009 10:40:42] data/actions/scripts/Custom/vip.lua

[11/08/2009 10:40:42] data/actions/scripts/Custom/vip.lua:5: attempt to perform arithmetic on a boolean value
[11/08/2009 10:40:42] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom/vip.lua)
[11/08/2009 10:40:42] data/actions/scripts/Custom/vip.lua:27: 'end' expected (to close 'function' at line 11) near 'elseif'

[11/08/2009 10:40:42] Lua Script Error: [Action Interface]
[11/08/2009 10:40:43] data/actions/scripts/Custom/vip.lua

[11/08/2009 10:40:43] luaGetPlayerStorageValue(). Player not found

[11/08/2009 10:40:43] Lua Script Error: [Action Interface]
[11/08/2009 10:40:43] data/actions/scripts/Custom/vip.lua

[11/08/2009 10:40:43] data/actions/scripts/Custom/vip.lua:5: attempt to perform arithmetic on a boolean value
[11/08/2009 10:40:43] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom/vip.lua)
[11/08/2009 10:40:43] data/actions/scripts/Custom/vip.lua:27: 'end' expected (to close 'function' at line 11) near 'elseif'

[11/08/2009 10:40:43] Lua Script Error: [Action Interface]
[11/08/2009 10:40:43] data/actions/scripts/Custom/vip.lua

[11/08/2009 10:40:43] luaGetPlayerStorageValue(). Player not found

[11/08/2009 10:40:43] Lua Script Error: [Action Interface]
[11/08/2009 10:40:43] data/actions/scripts/Custom/vip.lua

[11/08/2009 10:40:43] data/actions/scripts/Custom/vip.lua:5: attempt to perform arithmetic on a boolean value
[11/08/2009 10:40:43] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Custom/vip.lua)
[11/08/2009 10:40:44] data/actions/scripts/Custom/vip.lua:27: 'end' expected (to close 'function' at line 11) near 'elseif'
[11/08/2009 10:40:44] Reloaded actions.
new error
 

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
JDB, looks nice, how you steal my vip door script ^_^.
 
Status
Not open for further replies.
Top