Jump to content
  • 0

Please help me how to edit Guild Vip System smoothly


bambang777

Question


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   0
  • Joined:  03/09/23
  • Last Seen:  

mall01,92,135,5	script	GVip Regist	612,{
if (gettimetick(2) < #gtimer)  {
	mes .NPC$;
	mes "Dear " +strcharinfo(2)+ ", you are still a vip guild. You cannot talk to me until you are not a vip guild";
	close;
}
mes .NPC$;
mes "Hello " +strcharinfo(2)+ ", What can i do for you?";
next;
if (select("- I want to be a vip:- Nothing") - 1) close;
mes .NPC$;
mes "Okay then, before you become a vip you need the following : ";
mes "- " +.Amount+ "x " +getitemname(.ID);
next;
mes .NPC$;
mes "So what do you want now?";
next;
if (select("Yes, i have those requirements:I'll think over it again") - 1) close;
mes .NPC$;
mes "Let me check your items to ensure that you have my requirements";
next;
if (countitem(.ID) < .Amount) {
	mes .NPC$;
	mes "Sorry " +strcharinfo(2)+ " seems like you doesn't meet my requirements.";
	close;
}
mes .NPC$;
mes "Alright then, i will register your guild as a vip, guild" +getcharid(2)+ "must be relog";
set .@timeConverter, .Days * 24 * 60 * 60;
query_sql "INSERT INTO `vip_guild` (`guild_id`, `time`) VALUES ('"+getcharid(2)+"', '"+.@timeConverter+"')";
delitem .ID, .Amount;
set #gtimer,gettimetick(2) + .@timeConverter;
close2;

OnPCLoginEvent:
	if (gettimetick(2) > #gtimer) {
		dispbottom "Your vip guild is already expired";
		query_sql "DELETE FROM `vip_guild` WHERE `guild_id` = '"+getcharid(2)+"'";
		end;
	}
	set .@timeInSeconds, #gtimer - gettimetick(2);
	set .@daysLeft, .@timeInSeconds/60/60/24;
	dispbottom "Hello " +strcharinfo(2)+ " your vip guild still have " +.@daysLeft+ " days";
	end;

OnInit:
	.NPC$ = "[ " +strnpcinfo(1)+ " ]";
	.Amount = 30;
	.ID = 51582;
	.Days = 30;
	query_sql "CREATE TABLE IF NOT EXISTS `vip_guild` (`guild_id` INT NOT NULL, `time` INT NOT NULL) ENGINE=MyISAM";
	end;	
}

This script has a bug, when guild members login at the same time it will be erased faster in SQL, how to edit the Vip Guild System run smoothly? I mean how can this VIP guild run out for 1 month? Please help me

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

Hello,

try this:

mall01, 92, 135, 5	script	Guild Vip Registrar	612,{
    if(getcharid(2) == 0) {
        mes .NPC$;
		mes "You need to be in a guild to use my services.";
		close;
    }

    query_sql("SELECT TIMESTAMPDIFF(SECOND, NOW(), expiration_time) FROM vip_guild WHERE `guild_id` = " + getcharid(2),	.@secondsUntilExpiration);
	if (.@secondsUntilExpiration > 0)  {
		mes .NPC$;
		mes "Dear " + strcharinfo(0) + ", your guild " + strcharinfo(2) + " has still vip status. So there is nothing i can really help you with.";
		close;
	}

	mes .NPC$;
	mes "Hello " + strcharinfo(0) + ", What can i do for you?";
	next;

	if (select("- I want to make my guild vip:- Nothing") - 1) close;
	
	mes .NPC$;
	mes "Okay, to make your guild vip you need the following: ";
	mes "- " + .Amount +  " x "  + getitemname(.ID);
	next;
	mes .NPC$;
	mes "So what do you want now?";
	next;

	if (select("Yes, i have those requirements:I'll think over it again") - 1) close;
	
	mes .NPC$;
	mes "Let me check your items to ensure that you meet the requirements.";
	next;

	if (countitem(.ID) < .Amount) {
		mes .NPC$;
		mes "Sorry " + strcharinfo(0) + ", it seems like you don't meet the requirements.";
		close;
	}

	mes .NPC$;
	mes "Alright then, i will register your guild as a vip guild.";
	query_sql "INSERT INTO `vip_guild` (`guild_id`, `expiration_time`) VALUES (" + getcharid(2) + ", DATE_ADD(NOW(), INTERVAL 1 MONTH))";
	delitem .ID, .Amount;
	close;

    OnPCLoginEvent:
        .@rowCount = query_sql("SELECT TIMESTAMPDIFF(DAY, NOW(), expiration_time), TIMESTAMPDIFF(SECOND, NOW(), expiration_time) FROM vip_guild WHERE `guild_id` = " + getcharid(2),
   		.@daysUntilExpiration,
		.@secondsUntilExpiration);

		if(.@rowCount == 0) end;

        if (.@secondsUntilExpiration <= 0) {
            dispbottom "Your guilds vip state has expired";
            query_sql("DELETE FROM `vip_guild` WHERE `guild_id` = " + getcharid(2));
            end;
        }

        dispbottom "Hello " +strcharinfo(0)+ ", your guilds vip state ends in " + callfunc("F_InsertPlural", .@daysUntilExpiration, "day") + ".";
    end;

    OnInit:
        .NPC$ = "[ " +strnpcinfo(1)+ " ]";
        .Amount = 30;
        .ID = 51582;

        query_sql("CREATE TABLE IF NOT EXISTS `vip_guild` (`guild_id` INT NOT NULL, `expiration_time` DATETIME NOT NULL, PRIMARY KEY (guild_id)) ENGINE=INNODB");
}

 

  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   0
  • Joined:  03/09/23
  • Last Seen:  

2 hours ago, Winterfox said:

Hello,

try this:

mall01, 92, 135, 5	script	Guild Vip Registrar	612,{
    if(getcharid(2) == 0) {
        mes .NPC$;
		mes "You need to be in a guild to use my services.";
		close;
    }

    query_sql("SELECT TIMESTAMPDIFF(SECOND, NOW(), expiration_time) FROM vip_guild WHERE `guild_id` = " + getcharid(2),	.@secondsUntilExpiration);
	if (.@secondsUntilExpiration > 0)  {
		mes .NPC$;
		mes "Dear " + strcharinfo(0) + ", your guild " + strcharinfo(2) + " has still vip status. So there is nothing i can really help you with.";
		close;
	}

	mes .NPC$;
	mes "Hello " + strcharinfo(0) + ", What can i do for you?";
	next;

	if (select("- I want to make my guild vip:- Nothing") - 1) close;
	
	mes .NPC$;
	mes "Okay, to make your guild vip you need the following: ";
	mes "- " + .Amount +  " x "  + getitemname(.ID);
	next;
	mes .NPC$;
	mes "So what do you want now?";
	next;

	if (select("Yes, i have those requirements:I'll think over it again") - 1) close;
	
	mes .NPC$;
	mes "Let me check your items to ensure that you meet the requirements.";
	next;

	if (countitem(.ID) < .Amount) {
		mes .NPC$;
		mes "Sorry " + strcharinfo(0) + ", it seems like you don't meet the requirements.";
		close;
	}

	mes .NPC$;
	mes "Alright then, i will register your guild as a vip guild.";
	query_sql "INSERT INTO `vip_guild` (`guild_id`, `expiration_time`) VALUES (" + getcharid(2) + ", DATE_ADD(NOW(), INTERVAL 1 MONTH))";
	delitem .ID, .Amount;
	close;

    OnPCLoginEvent:
        .@rowCount = query_sql("SELECT TIMESTAMPDIFF(DAY, NOW(), expiration_time), TIMESTAMPDIFF(SECOND, NOW(), expiration_time) FROM vip_guild WHERE `guild_id` = " + getcharid(2),
   		.@daysUntilExpiration,
		.@secondsUntilExpiration);

		if(.@rowCount == 0) end;

        if (.@secondsUntilExpiration <= 0) {
            dispbottom "Your guilds vip state has expired";
            query_sql("DELETE FROM `vip_guild` WHERE `guild_id` = " + getcharid(2));
            end;
        }

        dispbottom "Hello " +strcharinfo(0)+ ", your guilds vip state ends in " + callfunc("F_InsertPlural", .@daysUntilExpiration, "day") + ".";
    end;

    OnInit:
        .NPC$ = "[ " +strnpcinfo(1)+ " ]";
        .Amount = 30;
        .ID = 51582;

        query_sql("CREATE TABLE IF NOT EXISTS `vip_guild` (`guild_id` INT NOT NULL, `expiration_time` DATETIME NOT NULL, PRIMARY KEY (guild_id)) ENGINE=INNODB");
}

 

thanks, it's work. just a little change at "ENGINE". from "INNODB" to "InnoDB"

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...