Jump to content
  • 0
Bringer

VIP Script

Question

ERROR : 14194300_1032571996859283_202107036_n.pn

//eAthena Version 2
prontera,150,150,5	script	VIP system	56,{
function statusvip;
function expirevip;
function mainmenu;
function showlist;
function deletevip;
function addvip;

	mes .npc_Name$;
	query_sql "SELECT `account_type` FROM login WHERE `account_id` = "+ getcharid(3), [email protected]_Type$;
	while( [email protected] < 3 && !compare([email protected]_Type$,.type_name$[[email protected]]) ) set [email protected], [email protected] +1;
	if( [email protected] == 3 )
		mes "Hello "+ strcharinfo(0) +" you have an normal account. Get an "+ getitemname( .item_premium_b ) +", "+ getitemname( .item_premium_s ) +", "+ getitemname( .item_premium_g ) +" to get a premium account.";
	else {
		set [email protected]_Date$, statusvip( .type_name$[[email protected]], [email protected] +1, 1 );
		mes "Hello "+ strcharinfo(0) +" you have an "+ .type_name$[[email protected]] +" and it will expire in "+ [email protected]_Date$;
	}
	goto L_player;

OnWhisperGlobal:
	if ( getgmlevel() < 99 ) end;
L_main:
	mes .npc_Name$;
	mes "Welcome, "+ strcharinfo(0) +"!";
	mes "What can I do for you today?";
L_player:
	next;
	set [email protected], select( ( getgmlevel() < 99 ? "" : "VIP bronze Menu" ), ( getgmlevel() < 99 ? "" : "VIP silver Menu" ), ( getgmlevel() < 99 ? "" : "VIP gold Menu" ),
			( ( countitem( .item_premium_b ) || countitem( .item_premium_s ) || countitem( .item_premium_g ) ) && .up_npc ? "Upgrade my account" : "" ), "Quit" ) -1;
	if ( [email protected] == 4 ) close;
	else if( [email protected] == 3 ) {
		setarray [email protected]$, "b", "s", "g";
		set [email protected], (prompt("Bronze:Silver:Gold")-1);
		callfunc "VIP_upgrade", 7, getd(".item_premium_"[email protected]$[[email protected]]), [email protected];
	}
	set [email protected]$, "[VIP "+ .type_name$[[email protected]] +"]";

	next;
	mes .npc_Name$;
	mes [email protected]$;
	// if( getgmlevel() < 99 ) {
		// set [email protected]_s, select( "List Accounts", "Cancel" );
		// if( [email protected]_s == 2 ) close;
		// mainmenu( [email protected]_s +2, [email protected] );
	// }
	next;
	set [email protected]_s, select( "Add/Extend Account", "Delete Account", "List Accounts", "Back" );
	if ( [email protected]_s == 4 || mainmenu( [email protected]_s, [email protected], [email protected]$ ) ) goto L_main;

// Setting
// -------
OnInit:
	set .npc_Name$,"[VIP System v4.0]";

	set .bronze_AccLvl, 1;		// VIP bronze Account Level
	set .silver_AccLvl, 2;		// 	   silver
	set .gold_AccLvl, 3;		// 	   gold

	set .bronze_ExpRate, 25;	// VIP bronze Exp Boost in % ( 1 = 1% )
	set .silver_ExpRate, 50;	// 	   silver
	set .gold_ExpRate, 100;		//	   gold

	set .bronze_ItemRate, 0;	// VIP bronze Item Drop Boost in % ( 1 = 1% )
	set .silver_ItemRate, 5;	//	 silver
	set .gold_ItemRate, 10;		//	 gold

	set .item_premium_b, 501; // ID item to upgrade your account to bronze
	set .item_premium_s, 502; // ID item to upgrade your account to silver
	set .item_premium_g, 503; // ID item to upgrade your account to gold
	set .fcp, 0;			// fcp for gold vip ? (0 : no) / (1 : yes)
	set .up_npc, 1;				// player can upgrade to npc if items required 0 : no
	setarray .type_name$, "bronze", "silver", "gold" ;
	end;

// On login
// --------
OnPCLoginEvent:
	query_sql "SELECT `account_type` FROM login WHERE `account_id` = "+ getcharid(3), [email protected]_Type$;
	while( [email protected] < 3 && !compare([email protected]_Type$,.type_name$[[email protected]]) ) set [email protected], [email protected] +1;
	if( [email protected] == 3 ) end;
	sc_end sc_expboost;	
	sc_end sc_itemboost;
	set [email protected]_Date$, statusvip( .type_name$[[email protected]], [email protected], 0 );
	dispbottom "----------------------------------------------------------------------";
	dispbottom "Account type:		 "+ [email protected]_Type$;
	dispbottom "Expiration date: "+ [email protected]_Date$;
	dispbottom "----------------------------------------------------------------------";
	end;

// Check the VIP status ; bonus VIP
// --------------------------------
function statusvip {
	query_sql "SELECT `status` FROM `vip_"+ getarg(0) +"` WHERE `account_id` = "+ getcharid(3), [email protected]_Status$ ;
	query_sql "SELECT DATE_FORMAT(`end_date`, '%Y%m%d') FROM `vip_"+ getarg(0) +"` WHERE `account_id` = "+ getcharid(3), [email protected]_Date$ ;
	query_sql "SELECT CURDATE() + 0;", [email protected]_Date$ ;
	if( getarg(2) ) return [email protected]_Date$;
	if ( atoi([email protected]_Date$) >= atoi([email protected]_Date$) )
		expirevip( "vip_"+ getarg(0), getcharid(3) );
	else {
		set [email protected], 3600 * 60 * 1000;
		set [email protected]_Rate, getd( "."+ getarg(0) +"_ItemRate" );
		set [email protected]_rate, getd( "."+ getarg(0) +"_ExpRate" );
		if( [email protected]_rate )
			sc_start sc_expboost, [email protected], [email protected]_rate;
		if( [email protected]_Rate )
			sc_start sc_itemboost, [email protected], [email protected]_Rate;
		if( getarg(1) == 2 && .fcp ) {
			sc_start SC_CP_WEAPON, [email protected], 5;
			sc_start SC_CP_SHIELD, [email protected], 5;
			sc_start SC_CP_ARMOR, [email protected], 5;
			sc_start SC_CP_HELM, [email protected], 5;
		}
	}
	return [email protected]_Date$;
}

// VIP expire : updates tables
// ---------------------------
function expirevip {
	set [email protected]_Name$, getarg(0);
	set [email protected]_Id, getarg(1);
	query_sql "UPDATE `login` SET `level` = 0, `account_type` = 'NORMAL' WHERE account_id = "+ [email protected]_Id;
	query_sql "DELETE FROM "+ [email protected]_Name$ +" WHERE account_id = "+ [email protected]_Id;
	query_sql "ALTER TABLE "+ [email protected]_Name$ +" AUTO_INCREMENT = 1";
	sc_end SC_CP_WEAPON;
	sc_end SC_CP_SHIELD;
	sc_end SC_CP_ARMOR;
	sc_end SC_CP_HELM;
	dispbottom "Your VIP expire.";
	end;
}

function mainmenu {
	switch( getarg(0) ) {
		case 1: addvip( getarg(1), getarg(2) ); break;
		case 2: deletevip( getarg(1), getarg(2) ); break;
		case 3: showlist( getarg(1) );
	}
	return 1;
}

function addvip {
	set [email protected], getarg(0);
	set [email protected]$, getarg(1);

	mes .npc_Name$;
	mes [email protected]$;
	mes "Type the Account Name";
	mes "you wish to add.";
	input [email protected]_Name$;
	next;

	mes .npc_Name$;
	mes [email protected]$;
	query_sql "SELECT `account_id` FROM login WHERE `userid` = '"+ escape_sql( [email protected]_Name$ )+"'", [email protected]_Id ;
	mes "Identifying account: "+ [email protected]_Name$ +".";
	sleep2 500;
	if ( [email protected]_Id ) {
		mes "ERROR: Couldn't find account.";
		mes "Verify if you dind't make a typo.";
		close;
	}

	mes .npc_Name$;
	mes [email protected]$;
	mes "Type the number of days you";
	mes "wish to add to the account's VIP";
	mes "status.";
	next;

	while( input( [email protected], 1, 999 ) != 0 ) {
		mes .npc_Name$;
		mes [email protected]$;
		mes "Put a number between 1 and 999.";
		next;
	}
	mes .npc_Name$;
	mes [email protected]$;
	query_sql "SELECT `account_id` FROM vip_"+ .type_name$[[email protected]] +" WHERE `account_id` = "+ [email protected]_Id, [email protected]_accid;
	if ( [email protected]_accid == [email protected]_Id ) {
		mes "Account ID: "+ [email protected]_accid +".";
		sleep2 500;
		query_sql "UPDATE vip_"+ .type_name$[[email protected]] +" SET end_date = DATE_ADD(end_date, INTERVAL "+ [email protected] +" DAY), `status` = 'ACTIVE' WHERE account_id = "+.[email protected]_accid;
		query_sql "UPDATE login SET `account_type` = '"+ .type_name$[[email protected]] +"' WHERE account_id = "+ [email protected]_accid;
		mes "Account "+ [email protected]_Id +" added successfully!";
	}
	else {
		mes "Account ID: "+ [email protected]_Id +".";
		sleep2 500;
		query_sql "INSERT INTO vip_"+ .type_name$[[email protected]] +" (`account_id`,`account_name`,`start_date`,`end_date`,`status`) VALUES ("[email protected]_Id+",'"+ escape_sql( [email protected]_Name$ ) +"',CURDATE(),CURDATE(),'ACTIVE')";
		sleep2 100;
		query_sql "UPDATE vip_"+ .type_name$[[email protected]] +" SET end_date = DATE_ADD(start_date, INTERVAL "+ [email protected] +" DAY) WHERE account_id = "[email protected]_Id;
		query_sql "UPDATE `login` SET `level` = "+ getd( "."+ .type_name$[[email protected]] +"_AccLvl" ) +", `account_type` = '"+ .type_name$[[email protected]] +"' WHERE `account_id` = "[email protected]_Id;
		mes "Account "+ [email protected]_Id +" added successfully!";
	}
	close;
}

function deletevip {
	set [email protected], getarg(0);
	set [email protected]$, getarg(1);
	set [email protected], query_sql( "SELECT account_name,`account_id`  FROM vip_"+ .type_name$[[email protected]] +" LIMIT 127", [email protected]$, [email protected]_id );
		mes .npc_Name$;
		mes [email protected]$;
	if ( [email protected] == 0 )
		mes "There are currently no VIP "+ .type_name$[[email protected]] +" accounts.";
	else {
		mes "Select the account you wish ";
		mes "to remove from VIP system.";
		
		set [email protected]$, "1. "+ [email protected]$;
		for ( set [email protected], 1; [email protected] < [email protected]; set [email protected], [email protected] + 1 )
			set [email protected]$, [email protected]$ +":"+ ( [email protected] +1 ) +". "+ [email protected]$[[email protected]];
		set [email protected]$, [email protected]$ +":Cancel";
		next;

		mes .npc_Name$;
		mes [email protected]$;
		set [email protected]_del, select( [email protected]$ ) -1;
		if ( [email protected]_del == [email protected] ) {
			next;
			return;
		}
		mes "Are you sure you want to remove the account ";
		mes [email protected]$[ [email protected]_del ] +" ?";
		if ( select( "Yes", "No" ) -1 ) {
			next;
			return;
		}
		query_sql "UPDATE `login` SET `level` = 0, `account_type` = 'NORMAL' WHERE `account_id` = '"+ [email protected]_id +"'";
		query_sql "DELETE FROM vip_"+ .type_name$[[email protected]] +" WHERE account_id = "+ [email protected]_id;
		query_sql "ALTER TABLE vip_"+ .type_name$[[email protected]] +" AUTO_INCREMENT = 1";
		mes "VIP "+ .type_name$[[email protected]] +" account successfully deleted!.";
	}
	close;
}

function showlist {
	set [email protected], getarg(0);
	mes .npc_Name$;
	mes "VIP "+ .type_name$[[email protected]] +" accounts list:";
	set [email protected], query_sql( "SELECT account_name FROM vip_"+ .type_name$[[email protected]] +" LIMIT 127", [email protected]$ );
	if( [email protected] == 0 ) {
		mes "The list is empty.";
		close;
	}
	for ( set [email protected], 0; [email protected] < [email protected]; set [email protected], [email protected] + 1 )
		mes ( [email protected] +1 )+". "+ [email protected]$[ [email protected] ];
	close;
}
}

// Upgrade via itemscript
// ----------------------
/*
callfunc( "VIP_upgrade", 7, 12703, 0 );
getarg(2) :
	0 = up to bronze
	1 = up to silver
	2 = up to gold
*/
function	script	VIP_upgrade	{
	if( select( "^777777~ Upgrade my account", "~ Not today^000000" ) -1 ) close;
	set [email protected]_id, getcharid(3) ;
	setarray [email protected]_name$, "bronze", "silver", "gold" ;
	set [email protected]_AccLvl, 1;		// VIP bronze Account Level
	set [email protected]_AccLvl, 2;		// 	   silver
	set [email protected]_AccLvl, 3;		// 	   gold

	query_sql "SELECT `userid`, `account_type` FROM `login` WHERE `account_id` = '"+ [email protected]_id +"'", [email protected]_id$, [email protected]_type$;
	while( [email protected] < 3 && !compare([email protected]_Type$,[email protected]_name$[[email protected]]) ) set [email protected], [email protected] +1;
	
	dispbottom ""[email protected]+">="+getarg(2);

	if ( [email protected] == 2 || ( [email protected] >= getarg(2) && [email protected] != 3 ) ) {
		dispbottom "Your can't upgrade your account.";
		close;
	}
	
	if(!countitem(getarg(1))) {
		message strcharinfo(0), "You don't have any "+getarg(1)+"(s).";
		close;
	}
	
	else if( [email protected] != 3 ) {
		query_sql "DELETE FROM vip_"+ [email protected]_name$[[email protected]] +" WHERE account_id = '"+ [email protected]_id +"'";
		query_sql "ALTER TABLE vip_"+ [email protected]_name$[[email protected]] +" AUTO_INCREMENT = 1";
	}
	query_sql "INSERT INTO vip_"+ [email protected]_name$[ getarg(2) ] +" (`account_id`,`account_name`,`start_date`,`end_date`,`status`) VALUES ("+ [email protected]_id +",'"+ escape_sql( [email protected]_id$ ) +"', CURDATE(), ( DATE_ADD(CURDATE(), INTERVAL "+ getarg(0) +" DAY) ), 'ACTIVE') ";
	query_sql "UPDATE `login` SET `level` = "+ getd( "[email protected]"+ [email protected]_name$[ getarg(2) ] +"_AccLvl" ) +", `account_type` = '"+ [email protected]_name$[getarg(2)] +"' WHERE `account_id` = '"+ [email protected]_id +"'";
	query_sql "SELECT DATE_FORMAT(`end_date`, '%Y %M %d') FROM vip_"+ [email protected]_name$[ getarg(2) ] +" WHERE `account_id` = '"+ [email protected]_id +"'", [email protected]_Date$;
	message strcharinfo(0), "Account updated. Expiration : "+ [email protected]_Date$;
	delitem getarg(1), 1;
	message strcharinfo(0), "You must relog.";
	close2;
	sleep2 4000;
	if( playerattached() )
		atcommand "@kick "+ strcharinfo(0);
	end;
}

// 12703,Holy_Egg_2,Holy Egg,11,0,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc( "VIP_upgrade", 7, 12703, 0 ); /* 7 days, item ID to delete */ },{},{}
// 12703,Holy_Egg_2,Holy Egg,11,0,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc( "VIP_upgrade", 7, 12703, 1 ); /* 7 days, item ID to delete */ },{},{}
// 12703,Holy_Egg_2,Holy Egg,11,0,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc( "VIP_upgrade", 7, 12703, 2 ); /* 7 days, item ID to delete */ },{},{}
CREATE TABLE IF NOT EXISTS `vip_bronze` (
  `account_id` int(11) unsigned NOT NULL default '0',
  `account_name` varchar(255) NOT NULL default 'NULL',
  `start_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `end_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `status` varchar(255) NOT NULL DEFAULT 'NULL',
  PRIMARY KEY  (`account_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `vip_silver` (
  `account_id` int(11) unsigned NOT NULL default '0',
  `account_name` varchar(255) NOT NULL default 'NULL',
  `start_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `end_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `status` varchar(255) NOT NULL DEFAULT 'NULL',
  PRIMARY KEY  (`account_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `vip_gold` (
  `account_id` int(11) unsigned NOT NULL default '0',
  `account_name` varchar(255) NOT NULL default 'NULL',
  `start_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `end_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `status` varchar(255) NOT NULL DEFAULT 'NULL',
  PRIMARY KEY  (`account_id`)
) ENGINE=MyISAM;

ALTER table `login` add column account_type varchar(255) NOT NULL default 'NULL' after `birthdate`, add index (account_type);

UPDATE `login` SET `account_type` = 'NULL';
TRUNCATE `vip_bronze`;
TRUNCATE `vip_gold`;
TRUNCATE `vip_silver`;
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

if you are using notepad++ (recommended) probabbly you are using any kind of unparsable characterset for the rathena reading scripts, so, install it and open your script and follow this instructions:

 

Sin_t_tulo.jpg

 

 I hope it helps you

Link to comment
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.   Paste as plain text instead

  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.



×
×
  • Create New...

Important Information

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