Jump to content
  • 0
ThyroDree

@security additional message

Question

I have this working security script, but I want to make like it will dispbottom the player he has security ON or OFF instead of forcing player to setup security once he/she logged in to the game..

On this script, you have choices as GM to force player to setup security to their account which it will always pop up a npc window for setting up security

 

I just want that even i don't force the player to setup their @security. They will know by getting dispbottom that their Security is ON or OFF. also this makes the player knows that the server has security features.

For me, npc pop up for force setup security is a very annoying.

heres the script i used.

/*
	By Dastgir/Hercules
	Use Plugin too along with this script(Found in https://github.com/dastgir/HPM-Plugins)
*/
-	script	Security	FAKE_NPC,{
OnInit:
	bindatcmd("security",strnpcinfo(0)+"::OnSecurity",0,99);
	/* Config */
	.max_attempt = 5;	//3 Times Wrong Attempt = Ban.
	.ban_hour = 2;		//Hours to ban
	.allowed = 1|2|4|8|64|128|512|1024|2048|4096;		//Allowed Settings..
	end;
	
OnPCLoginEvent:
	if ($security){
		if (!#security){
			callsub OnPlayerMenu;
		}
	}
	close;

OnSecurity:
	if (getgmlevel()){
		mes "[^FFA500 Security System ^000000]";
		mes "Hello GM, How may I help you?";
		callsub OnGMMenu;
		end;
	}
	
OnPlayerMenu:
	// Don't Change Order.
	setarray .@restrictions$,"Can't Drop Item",			//	1
				"Can't receive Trade Requests",			//	2
				"Can't send Trade Request",				//	4
				"Can't open Guild Storage",				//	8
				"Can't take item from guild storage",	//	16
				"Can't add item to guild storage",		//	32
				"Can't sell items",						//	64
				"Can't use Vending",					//	128
				"Can't delete items by any means",		//	256
				"Can't buy items",						//	512
				"Can't Send Guild Invite",				//	1024
				"Can't Receive Guild Invite",			//	2048
				"Can't Leave the guild";				//	4096
	while (1){
		mes "[^FFA500 Security System ^000000]";
		mes "Security Status: "+ ((#security>0)?"^00FF00On^000000":"^FF0000Off^000000");
		mes "Status: ";
		for (.@i = 0; .@i < getarraysize(.@restrictions$); .@i++){
			.@bit = (1<<.@i);
			if (.allowed&.@bit)
				mes .@restrictions$[.@i] + " - "+ ((#secure_opt&.@bit)?"^00FF00On^000000":"^FF0000Off^000000");
		}
		switch(select("Info",((#security>0)?"Dea":"A")+"ctivate the Security","Settings","Close")){
			case 4:
				close;
			case 3:
				next;
				mes "[^FFA500 Security System ^000000]";
				if (!#security){
					mes "^FF0000You don't have security enabled^000000";
					next;
					break;
				}
				mes "Enter your ^FF0000OLD^000000 Security Code";
				mes "^FF0000- Wrong Code more than "+ .max_attempt +" times can result into ban.^000000";
				mes "Chances Left: "+ (.max_attempt-security_maxtry);
				input .@security;
				next;
				mes "[^FFA500 Security System ^000000]";
				if (#secure_code != .@security){
					mes "Wrong Code...";
					security_maxtry++;
					if (security_maxtry >= .max_attempt){
						atcommand "@ban +"+.ban_hour+"h \""+strcharinfo(0)+"\"";	//Ban the Player for 1 hour.
						security_maxtry = 0;		//Reset After tha Ban
						end;
					}
					close;
				}
				next;
				security_maxtry = 0;
				mes "[^FFA500 Security System ^000000]";
				mes "Choose Restrictions to Enable/Disable";
				.@menu$ = "^00FF00Enable All^000000:^FF0000Disable All^000000:";
				.@opt = 0;
				for (.@i = 0; .@i < getarraysize(.@restrictions$); .@i++){
					.@bit = (1<<.@i);
					if (.allowed&.@bit){
						.@index[.@opt] = .@i;
						.@opt++;
						.@content$ = .@restrictions$[.@i] + " - "+ ((#secure_opt&.@bit)?"^00FF00On^000000":"^FF0000Off^000000");
						.@menu$ = .@menu$ + "" + .@content$ +":";
						mes .@content$;
					}
				}
				.@t_menu = select(.@menu$)-1;
				next;
				if (.@t_menu == 1){
					mes "[^FFA500 Security System ^000000]";
					if (!#secure_opt){
						mes "You already have all Settings disabled.";
						next;
						break;
					}
					mes "Are you Sure you want to disable all?";
					if (select("Yes:No..") == 2){
						next;
						mes "[^FFA500 Security System ^000000]";
						mes "As you wish..";
						next;
						break;
					}
					next;
					mes "[^FFA500 Security System ^000000]";
					mes "All Settings Disabled";
					#secure_opt = 0;
					next;
					break;
				} else if (.@t_menu == 0){
					mes "[^FFA500 Security System ^000000]";
					if (#secure_opt >= .allowed){
						mes "You already have all Settings enabled.";
						next;
						break;
					}
					mes "Are you Sure you want to enable all?";
					if (select("Yes:No..") == 2){
						next;
						mes "[^FFA500 Security System ^000000]";
						mes "As you wish..";
						next;
						break;
					}
					next;
					mes "[^FFA500 Security System ^000000]";
					mes "All Settings Enabled";
					#secure_opt = .allowed;
					next;
					break;
				}
				.@t_menu -= 2;
				.@menu = .@index[.@t_menu];
				mes "[^FFA500 Security System ^000000]";
				mes .@restrictions$[.@menu];
				mes "Are you sure you want to "+ ((#secure_opt&(1<<.@menu))?"Disable":"Enable") +" this?";
				if (select("Yes:No..") == 2){
					next;
					mes "[^FFA500 Security System ^000000]";
					mes "As you wish..";
					next;
					break;
				}
				next;
				mes "[^FFA500 Security System ^000000]";
				mes "Setting "+ ((#secure_opt&(1<<.@menu))?"Disabled":"Enabled");
				if (#secure_opt&(1<<.@menu))
					#secure_opt -= 1<<.@menu;
				else
					#secure_opt += 1<<.@menu;
				next;
				break;
			case 2:
				next;
				mes "[^FFA500 Security System ^000000]";
				if (#security){
					mes "Enter your ^FF0000OLD^000000 Security Code";
					mes "^FF0000- Wrong Code more than "+ .max_attempt +" times can result into ban.^000000";
					mes "Chances Left: "+ (.max_attempt-security_maxtry);
					input .@security;
					next;
					mes "[^FFA500 Security System ^000000]";
					if (#secure_code != .@security){
						mes "Wrong Code...";
						security_maxtry++;
						if (security_maxtry >= .max_attempt){
							atcommand "@ban +"+.ban_hour+"h \""+strcharinfo(0)+"\"";	//Ban the Player for 1 hour.
							security_maxtry = 0;		//Reset After tha Ban
							end;
						}
						close;
					}
					mes "Security Deactivated.";
					#security = 0;
					security_maxtry = 0;
					close;
				}
				mes "Insert your ^00FF00NEW^000000 Security Code";
				mes "^FF0000- Must be 4-8 Digits^000000";
				mes "^FF0000- Only numerics are allowed(0-9)^000000";
				mes "^FF0000- Don't use 0 in beginning of security code^000000";
				input .@security;
				next;
				mes "[^FFA500 Security System ^000000]";
				if (.@security < 1000 || .@security > 99999999){
					mes "Security code must be of 4-8 digits.";
					next;
					break;
				}
				mes "^00FF00 Re-insert the Security Code ^000000";
				input .@secu2;
				next;
				mes "[^FFA500 Security System ^000000]";
				if (.@secu2 != .@security){
					mes "Security Code Mismatch..";
					next;
					break;
				}
				mes "Security Code Set";
				#secure_code = .@security;
				#security = 1;
				next;
				break;
			case 1:
				next;
				mes "[^FFA500 Security System ^000000]";
				mes "Security Code can be of 4-8 Digits.";
				mes "When Security Code is enabled, you can do following settings as a security step:";
				for (.@i = 0; .@i < getarraysize(.@restrictions$); .@i++){
					.@bit = (1<<.@i);
					if (.allowed&.@bit)
						mes "^FF0000- "+ .@restrictions$[.@i] +"^000000";
				}
				next;
				break;
		}
	}
	end;
	
OnGMMenu:
	switch(select("Player Menu: Settings")){
		case 1:
			next;
			callsub OnPlayerMenu;
			end;
		case 2:
			next;
			mes "[^FFA500 Security System ^000000]";
			mes "Force Player to set @security?";
			mes "Status: "+  (($security>0)?"^00FF00On^000000":"^FF0000Off^000000");
			.@menu = select((($security>0)?"^00FF00Disable^000000":"^FF0000Enable^000000"),"Cancel");
			if (.@menu == 2)
				close;
			next;
			mes "[^FFA500 Security System ^000000]";
			if ($security)
				$security = 0;
			else
				$security = 1;
			mes "Force Security Setting Set.";
			close;
	}
	end;
}

Thank you!

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Heres what I found similar, it seems like its added inside the plugin https://rathena.org/board/topic/101064-security-login-message/

 

and this is the plugin of @security of herc

//===== Hercules Plugin ======================================
//= Security
//===== By: ==================================================
//= by Dastgir/Hercules
//===== Current Version: =====================================
//= 1.0
//===== Description: =========================================
//= Prohibits actions depending upon security level.
//===== Changelog: ===========================================
//= v1.0 - Initial Conversion
//===== Additional Comments: =================================
//= Use NPC too along with this plugin
//===== Repo Link: ===========================================
//= https://github.com/dastgir/HPM-Plugins
//============================================================

#include "common/hercules.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#include "common/HPMi.h"
#include "common/nullpo.h"
#include "common/memmgr.h"
#include "common/mmo.h"

#include "map/atcommand.h"
#include "map/battle.h"
#include "map/clif.h"
#include "map/guild.h"
#include "map/map.h"
#include "map/mob.h"
#include "map/npc.h"
#include "map/pc.h"
#include "map/storage.h"
#include "map/trade.h"
#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"


HPExport struct hplugin_info pinfo = {
	"Security",		// 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)
};
const char* secure = "#security";
const char* secure_opt = "#secure_opt";

#define is_secure(x) pc_readaccountreg(x, script->add_str(secure))
#define security_opt(x) pc_readaccountreg(x, script->add_str(secure_opt))

enum S_Options {	//Security Options
	S_CANT_DROP = 0x0001,				// Cannot Drop Items
	S_CANT_TRADE_R = 0x0002,			// Cannot Receive Trade Request
	S_CANT_TRADE_S = 0x0004,			// Cannot Send Trade Request
	S_CANT_OPEN_GS = 0x0008,			// Cannot Open gStorage
	S_CANT_TAKE_GS = 0x0010,			// Cannot take Item from gStorage
	S_CANT_ADD_GS = 0x0020,				// Cannot add Item to gStorage
	S_CANT_SELL = 0x0040,				// Cannot Sell item
	S_CANT_VEND = 0x0080,				// Cannot Vend
	S_CANT_DELETE = 0x0100,				// Cannot Delete Items(By Drop/delitem function)
	S_CANT_BUY = 0x0200,				// Cannot Buy Items
	S_CANT_SEND_GINVITE = 0x0400,		// Cannot Send Guild Invite
	S_CANT_RECEIVE_GINVITE = 0x0800,	// Cannot Receive Guild Invite
	S_CANT_LEAVE_GUILD = 0x1000,		// Cannot Leave Guild
};

int pc_cant_drop(struct map_session_data **sd, int *n, int *amount) {	// Can't Drop Items
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd)&S_CANT_DROP || security_opt(*sd)&S_CANT_DELETE){
			clif->message((*sd)->fd, "Security is on. You cannot drop item.");
			hookStop();
			return 0;
		}
	}
	return 1;	
}

void cant_trade(struct map_session_data **sd, struct map_session_data **target_sd){	// Can't receive/send Trade Requests
	if (*sd == NULL || *target_sd == NULL)
		return;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_TRADE_S) {	//Cannot Send
			clif->message((*sd)->fd, "Security is on. You cannot initiate Trade.");
			hookStop();
			return;
		}
	}
	if (is_secure(*target_sd) > 0) {	// Cannot Receive
		if (security_opt(*target_sd) & S_CANT_TRADE_R) {
			clif->message((*sd)->fd, "Target Player Security is on, Player cannot receive Trade Requests.");
			hookStop();
			return;
		}
	}
	return;
}

int gstorage_cant_open(struct map_session_data **sd){
	if (sd==NULL)
		return 2;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_OPEN_GS) {
			clif->message((*sd)->fd, "Security is on. You cannot open gStorage.");
			hookStop();
			return 1;
		}
	}
	return 0;
}

int gstorage_cant_add(struct map_session_data **sd, struct guild_storage **stor, struct item **item_data, int *amount) {
	if (*sd == NULL)
		return 1;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_ADD_GS) {
			clif->message((*sd)->fd, "Security is on. You cannot add item to gStorage.");
			hookStop();
			return 1;
		}
	}
	return 0;
}

int gstorage_cant_take(struct map_session_data **sd, int *index, int *amount) {
	if (*sd == NULL)
		return 0;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_TAKE_GS) {
			clif->message((*sd)->fd, "Security is on. You cannot take item from gStorage.");
			hookStop();
			return 0;
		}
	}
	return 1;
}

int pc_restrict_items(struct map_session_data **sd, int *n, int *amount, int *type, short *reason, e_log_pick_type *log_type){
	if (*sd == NULL)
		return 1;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_DELETE) {
			clif->message((*sd)->fd, "Security is on. You cannot delete item.");
			hookStop();
			return 1;
		}
	}
	return 0;
}

int npc_cant_sell(struct map_session_data **sd, struct itemlist **item_list)
{
	if (*sd == NULL)
		return 1;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_SELL) {
			clif->message((*sd)->fd, "Security is on. You cannot sell item.");
			hookStop();
			return 1;
		}
	}
	return 0;
}

int npc_cant_buy(struct map_session_data **sd, struct itemlist **item_list) {
	if (*sd == NULL)
		return 1;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_BUY) {
			clif->message((*sd)->fd, "Security is on. You cannot buy item.");
			hookStop();
			return 1;
		}
	}
	return 0;
}

void open_vending(struct map_session_data **sd, int *num){
	if (*sd == NULL)
		return;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_VEND) {
			clif->message((*sd)->fd, "Security is on. You cannot vend.");
			(*sd)->state.prevend = (*sd)->state.workinprogress = 0;
			hookStop();
			return;
		}
	}
	return;
}

int guild_invite_permission(struct map_session_data **sd, struct map_session_data **tsd) {
	if (*sd == NULL || *tsd == NULL)
		return 0;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_SEND_GINVITE) {
			clif->message((*sd)->fd, "Security is on. You cannot send Guild Invite.");
			hookStop();
			return 0;
		}
	}
	
	if (is_secure(*tsd) > 0) {
		if (security_opt(*tsd) & S_CANT_RECEIVE_GINVITE) {
			clif->message((*sd)->fd, "Target Player Security is on, Player cannot receive Guild Invites.");
			hookStop();
			return 0;
		}
	}
	return 0;
}

int guild_leave_permission(struct map_session_data **sd, int *guild_id, int *account_id, int *char_id, const char **mes) {
	if (*sd == NULL)
		return 0;
	if (is_secure(*sd) > 0) {
		if (security_opt(*sd) & S_CANT_LEAVE_GUILD) {
			clif->message((*sd)->fd, "Security is on. You cannot leave Guild.");
			hookStop();
			return 0;
		}
	}
	return 0;
}

/* Server Startup */
HPExport void plugin_init(void)
{
	addHookPre(pc, dropitem, pc_cant_drop);
	addHookPre(trade, request, cant_trade);
	addHookPre(gstorage, open, gstorage_cant_open);
	addHookPre(gstorage, additem, gstorage_cant_add);
	addHookPre(gstorage, get, gstorage_cant_take);
	addHookPre(gstorage, gettocart, gstorage_cant_take);
	addHookPre(pc, delitem, pc_restrict_items);
	addHookPre(npc, selllist, npc_cant_sell);
	addHookPre(npc, buylist, npc_cant_buy);
	addHookPre(clif, openvendingreq, open_vending);
	addHookPre(guild, invite, guild_invite_permission);
	addHookPre(guild, leave, guild_leave_permission);
}

HPExport void server_online(void)
{
	ShowInfo("'%s' Plugin by Dastgir/Hercules. Version '%s'\n", pinfo.name, pinfo.version);
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.