Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== Hercules Plugin ======================================
- //= BUILDIN(getguildid)
- //===== By ===================================================
- //= Wolfie of BlackoutRO (http://blackout-ro.net)
- //===== Version ==============================================
- //= 1.0 - December 7, 2017
- //===== Description ==========================================
- //= Gives your server the 'getguildid' script command.
- // Usage:
- // .@Guild$ = "My Guild";
- // .@GID = getguild(.@Guild$);
- // mesf("The GID of %s is %d.", .@Guild$, .@GID);
- //
- // This example will give a message box saying,
- // 'The GID of My Guild is X.' (where x = the actual GID)
- //============================================================
- #include "common/hercules.h" /* Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces) */
- #include "map/guild.h"
- #include "map/script.h"
- #include "common/HPMDataCheck.h" /* should always be the last Hercules file included! (if you don't make it last, it'll intentionally break compile time) */
- HPExport struct hplugin_info pinfo = {
- "BUILDIN(getguildid)", // Plugin name
- SERVER_TYPE_MAP,// Which server types this plugin works with?
- "1.0", // Plugin version
- HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
- };
- /*==========================================
- * getguildid("<Guild Name>")
- * Returns the Guild ID from the provided
- * guild name.
- * Will return -1 if the guild does not
- * exist.
- *=========================================*/
- BUILDIN(getguildid)
- {
- struct guild *g = NULL;
- char guild_name[NAME_LENGTH];
- sprintf(guild_name, "%s", script_getstr(st, 2));
- if ((g = guild->searchname(guild_name)) == NULL) {
- script_pushint(st, -1);
- return true;
- }
- script_pushint(st, g->guild_id);
- return true;
- }
- /* run when server starts */
- HPExport void plugin_init (void)
- {
- // Atcommands only make sense on the map server
- if (SERVER_TYPE == SERVER_TYPE_MAP) {
- addScriptCommand("getguildid", "s", getguildid);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement