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

Lua GuildMaster for TFS 0.3.6

filipus

Member
Joined
Dec 31, 2010
Messages
229
Reaction score
12
So, I've been wondering if anyone knows any "easy" way to create a GuildMaster NPC in 0.3.6
I know there are the talkaction things (even if I only have !create and !join, no idea why the rest isn't there haha), but I wanted an NPC.

I've picked up one from a 8.0 version but it seems 0.3.6 doesn't have LuaFunctions to create a guild (I have setPlayerGuildID/setPlayerGuildRank/etc.. but these don't seem to work that well).

My question is, is there any Guildmaster NPC already made? If not, does anyone know a way to do one without having to create new functions? I've tried to create one but since I'm new to all this it's kind of hard for me to code it. (not many examples to "copy" from)

Here's the one I've been working on, I copied from a old one so it obviously doesn't work (I've been changing things step by step): http://pastebin.com/a0AtJtxX <-- too big to post on the topic.


@Limos You are the programming genius, help mee! haha
 
Last edited:
You could try to write out this line in the beginning of the function (source):
Code:
std::cout << " -- testing -- " << std::endl;

And then call it in LUA, and see if the script gets there, seems very odd indeed.
 
You could try to write out this line in the beginning of the function (source):
Code:
std::cout << " -- testing -- " << std::endl;

And then call it in LUA, and see if the script gets there, seems very odd indeed.

I did broadcasts on the NPC but forgot about doing them in the function itself. Good idea Ignazio!
 
Code:
  In static member function `static int32_t LuaScriptInterface::luaDoPlayerCreateGuild(lua_State*)':

6918 F:\OtserverOdD\COISASRANDOM\cryingdamson 0.3.6 (8.60) V8.2 Source\LETSTRY\luascript.cpp `creature' was not declared in this scope

6926 F:\OtserverOdD\COISASRANDOM\cryingdamson 0.3.6 (8.60) V8.2 Source\LETSTRY\luascript.cpp `variantToString' was not declared in this scope

This is totally weird, it wasn't happening the last time I compiled. What am I suppose to include so it recognizes creature? And variantToString also doesn't exist... wutt.

Am I suppose to define it as a pointer or something? Creature* creature

@Limos help! ):



edit**

//variantToString(var)
lua_register(m_luaState, "variantToString", LuaScriptInterface::luaVariantToString);


But the code itself is not written anywhere. Should it be?
Should I just to pop() ?
 
Last edited:
Try this, you have to define "creature", fetch it from the lua and as I previously mentioned, go from last to first when fething lua variables:

Code:
int32_t LuaScriptInterface::luaDoPlayerCreateGuild(lua_State* L)
{
std::string param_ = popString(L);
Creature* creature = env->getCreatureByUID(popNumber(L));
Player* player = creature->getPlayer();

if(player->getGuildId())
{
player->sendCancel("You are already in a guild.");
lua_pushboolean(L, true);
}

trimString(param_);
if(!isValidName(param_))
{
player->sendCancel("That guild name contains illegal characters, please choose another name.");
return true;
}

const uint32_t minLength = g_config.getNumber(ConfigManager::MIN_GUILDNAME);
const uint32_t maxLength = g_config.getNumber(ConfigManager::MAX_GUILDNAME);
if(param_.length() < minLength)
{
player->sendCancel("That guild name is too short, please select a longer name.");
return true;
}

if(param_.length() > maxLength)
{
player->sendCancel("That guild name is too long, please select a shorter name.");
return true;
}

uint32_t guildId;
if(IOGuild::getInstance()->getGuildId(guildId, param_))
{
player->sendCancel("There is already a guild with that name.");
return true;
}

const uint32_t levelToFormGuild = g_config.getNumber(ConfigManager::LEVEL_TO_FORM_GUILD);
if(player->getLevel() < levelToFormGuild)
{
char buffer[70 + levelToFormGuild];
sprintf(buffer, "You have to be at least Level %d to form a guild.", levelToFormGuild);
player->sendCancel(buffer);
return true;
}

const int32_t premiumDays = g_config.getNumber(ConfigManager::GUILD_PREMIUM_DAYS);
if(player->getPremiumDays() < premiumDays)
{
char buffer[70 + premiumDays];
sprintf(buffer, "You need to have at least %d premium days to form a guild.", premiumDays);
player->sendCancel(buffer);
return true;
}

player->setGuildName(param_);
IOGuild::getInstance()->createGuild(player);

char buffer[50 + maxLength];
sprintf(buffer, "You have formed guild \"%s\"!", param_.c_str());
player->sendTextMessage(MSG_INFO_DESCR, buffer);
return true;
}

Might work now (doPlayerCreateGuild(cid, "name"))

Try it

Ignazio
 
Back
Top