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

House only for vip players

Joined
Apr 15, 2014
Messages
75
Reaction score
18
I'm trying to make it so only vip players are able to buy houses.

I tryied to change the !buyhouse command into a script that calls another talkaction, like this:

talkactions.xml:

Code:
<talkaction words="!buyhouse" filter="word-spaced" event="script" value="buyhouse.lua"/>
<talkaction words="!huyblulx3" filter="word-spaced" event="function" value="houseBuy"/>

and in buyhouse.lua

Code:
function onSay(cid, words, param)
    if isVip(cid) then
        doCreatureExecuteTalkAction(cid, "!huyblulx3",true)
    else
        doPlayerSendCancel(cid,"Only vip player can buy houses.")
    end
    return true
end

It is working fine with my gamemaster but when players try to use the command simply nothing happens... does anyone have an idea?
 
You can't edit sources? Is not really hard checking vip there...
About your issue, it should be working. Did you tried triggering another function?
 
I'm trying to make it so only vip players are able to buy houses.

I tryied to change the !buyhouse command into a script that calls another talkaction, like this:

talkactions.xml:

Code:
<talkaction words="!buyhouse" filter="word-spaced" event="script" value="buyhouse.lua"/>
<talkaction words="!huyblulx3" filter="word-spaced" event="function" value="houseBuy"/>

and in buyhouse.lua

Code:
function onSay(cid, words, param)
    if isVip(cid) then
        doCreatureExecuteTalkAction(cid, "!huyblulx3",true)
    else
        doPlayerSendCancel(cid,"Only vip player can buy houses.")
    end
    return true
end

It is working fine with my gamemaster but when players try to use the command simply nothing happens... does anyone have an idea?

What TFS?
 
@Colors Yes I could edit the sources but I'm not familiar to C. My vip system uses the column vip_time on the accounts table, where I store the time in seconds with os.time()

@Techrlz I use the OTX modified version of TFS 0.4

This function in my sources:

Code:
int32_t LuaInterface::luaDoCreatureExecuteTalkAction(lua_State* L)
{
    //doCreatureExecuteTalkAction(cid, text[, ignoreAccess = false[, channelId = CHANNEL_DEFAULT]])
    uint32_t params = lua_gettop(L), channelId = CHANNEL_DEFAULT;
    if(params > 3)
        channelId = popNumber(L);

    bool ignoreAccess = false;
    if(params > 2)
        ignoreAccess = popBoolean(L);

    std::string text = popString(L);
    ScriptEnviroment* env = getEnv();
    if(Creature* creature = env->getCreatureByUID(popNumber(L)))
        lua_pushboolean(L, g_talkActions->onPlayerSay(creature, channelId, text, ignoreAccess));
    else
    {
        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
    }

    return 1;
}
 
Well.. There is another way you could do this.. although not the 'best way'.
Create 2 scripts.
First script is a movement tile.
Place this directly in front of the house.
Code:
onstep in
if vip == false then
give storage 
end
onstep out
if vip == false then
remove storage 
end
Second one is the talkaction to use !buyhouse.
If they have the storage given above, then return "
Only vip player can buy houses."

not a fantastic work-around.. but then you could make a non-vip house area as well.
-shrugs-
 
Doudble check that they are VIP? what happens when you
Code:
print(isVIP(cid))
 
Try this in source:
Code:
int32_t LuaInterface::luaDoCreatureExecuteTalkAction(lua_State* L)
{
   
//doCreatureExecuteTalkAction(cid, text[, ignoreAccess = false[, channelId = CHANNEL_DEFAULT]])
    uint32_t params = lua_gettop(L), channelId = CHANNEL_DEFAULT;
    if(params > 3)
        channelId = popNumber(L);

    std::string text = popString(L);
    ScriptEnviroment* env = getEnv();
    if(Creature* creature = env->getCreatureByUID(popNumber(L)))
        lua_pushboolean(L, g_talkActions->onPlayerSay(creature, channelId, text, true));
    else
    {
        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
    }

    return 1;
}
 
Last edited:
@beastn actually this function is a part of the vip system I made for my server, which is as simple as:

Code:
function isVip(cid)
    return getPlayerStorageValue(cid,vip_storage) == 1
end

And I tested it with 2 gamemasters, one being VIP and another being free and the script worked as it should. It only does not when players are trying to use...

@Techrlz Thank you, I will test it :)
 
Back
Top