Jump to content
  • 0

Charity NPC - Help pls.


Mirmo_

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  14
  • Reputation:   2
  • Joined:  03/24/13
  • Last Seen:  

Hello everyone, I'm trying to make a Charity NPC. I'm beginner in scripting and Im using guides and forums just to see how it works.
But now i can't get it too work. I need your help pls.

The script is fully functional, no errors but i cannot add an event timer to activate the event (hidden npc)..

The way i want it to work is like :

  • Players can choose how much they would donate in ZENY. (5m, 10m, 15m or 25m)
  • If player, donated a money to the NPC it will do an announcement.
  • If the npc collects 75m it will activate/show the NPC Quests (quest npcs are hidden) for 2 days.
  • After 2 days, it will hide the quest npcs. So players need to donate 75m in total to activate again.

Heres the script i made:

//Charity NPC//
//Ryonin//

izlude,124,139,6    script    Lucy    101,{

        // Variables
        set .@n$, "[Lucy]";
        set ##donate5m, 5000000;
        set ##donate10m, 10000000;
        set ##donate15m, 15000000;
        set ##donate25m, 25000000;
        
        // Zeny Detector
        if (Zeny < ##donate5m)
            {
            mes .@n$;
            mes "Sorry, you dont have enough money to talk to me.";
            mes "You need to have atleast ^FF00005,000,000z^000000.";
            mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
            close;
            end;}        
        
        // Start
        mes .@n$;
        mes "Hello, Citizen of Ragnarok Offline.";
        mes "Can I help you with something?";
        next;
        switch(select("Yes, I would like to donate:No, Thank you")) {
        
        case 1:
            mes .@n$;
            mes "I was assigned by the ^DAA520 GM Team^000000 to collect the donation money.";
            mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
            next;
            mes .@n$;
            mes "You can only donate 1,000,000z or 5,000,000z.";
            next;
            mes .@n$;
            mes "If I collected a total amount of ^FF000075,000,000^000000z.";
            mes "I can activate this event:";
            mes "Event: ^8B008BComodo Hat Festival Quest^000000.";
            mes "Event Duration: ^006400[2 DAYS]^000000.";
            next;
            mes .@n$;
            mes "How much money you want to donate?";
            mes "Once you donate, I can't your money back.";
            next;
            switch(select("5,000,000z:10,000,000z:15,000,000z:25,000,000z")) {
                case 1:
                    mes .@n$;
                    set zeny, zeny - ##donate5m;
                    goto Donate5M;
                    close;
                    
                case 2:
                    mes    .@n$;
                    set zeny, zeny - ##donate10m;
                    goto Donate10M;
                    close;
                
                case 3:
                    mes .@n$;
                    set zeny, zeny - ##donate15m;
                    goto Donate15M;
                    close;
                
                case 4:
                    mes    .@n$;
                    set zeny, zeny - ##donate25m;
                    goto Donate25M;
                    close;
                    
                }
            close;
            end;
        case 2:
            mes .@n$;
            mes    "Okay then. See you later.";
            close;
            end;
        }
// Zeny Donation Selection

    Donate5M:
                set ##totaldonate, ##totaldonate + 5000000;
                mes "Thank you for donating 5,000,000z!";
                mes "We appreciate your generosity.";
                announce "[Charity Lucy: "+strcharinfo(0)+"] has donated [5,000,000z] to Charity! We appreciate your generosity.",0;
                next;
                mes .@n$;
                mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
                close;
                
    Donate10M:
                set ##totaldonate, ##totaldonate + 10000000;
                mes "Thank you for donating 10,000,000z!";
                mes "We appreciate your generosity.";
                announce "[Charity Lucy: "+strcharinfo(0)+"] has donated [10,000,000z] to Charity! We appreciate your generosity.",0;
                next;
                mes .@n$;
                mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
                close;
                
    Donate15M:
                set ##totaldonate, ##totaldonate + 15000000;
                mes "Thank you for donating 15,000,000z!";
                mes "We appreciate your generosity.";
                announce "Charity Lucy: ["+strcharinfo(0)+"] has donated [15,000,000z] to Charity! We appreciate your generosity.",0;
                next;
                mes .@n$;
                mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
                close;
                
    Donate25M:
                set ##totaldonate, ##totaldonate + 25000000;
                mes "Thank you for donating 25,000,000z!";
                mes "We appreciate your generosity.";
                announce "Charity Lucy: ["+strcharinfo(0)+"] has donated [25,000,000z] to Charity! We appreciate your generosity.",0;
                next;
                mes .@n$;
                mes "The total amount I collected is : ^0000CD["+##totaldonate+"]^000000 zeny.";
                close;
                
    Reset:
                set ##totaldonate, 0;
                announce "Charity Lucy: Charity Event for 2 Days has ended. Don't forget to donate to activate.",0;
                sleep 10000;
                announce "Charity Lucy: Thank you for your generosity.",0;
                close;
}

 

Edited by ar7shadow
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Like this? (untested)

//Charity NPC//
//Ryonin//

izlude,124,139,6    script    Lucy    101,{
function Display_Timer;	// define function

	if ($totaldonate >= 75000000)
		end;

	// Variables
	set .@n$, "[Lucy]";
	setarray .@donation_Zeny[0],
		5000000,
		10000000,
		15000000,
		25000000;
	
	// Zeny Detector
	if (Zeny < .@donation_Zeny[0]) {
		mes .@n$;
		mes "Sorry, you dont have enough money to talk to me.";
		mes "You need to have atleast ^FF00005,000,000z^000000.";
		mes "The total amount I collected is : ^0000CD[" + $totaldonate + "]^000000 Zeny.";		// '$' for permanent server variable
		close;		// don't need end after close
	}        
	// Start
	mes .@n$;
	mes "Hello, Citizen of Ragnarok Offline.";
	mes "Can I help you with something?";
	next;
	if (select("Yes, I would like to donate:No, Thank you") == 1) {
		mes .@n$;
		mes "Okay then. See you later.";
		close;
	}
	mes .@n$;
	mes "I was assigned by the ^DAA520 GM Team^000000 to collect the donation money.";
	mes "The total amount I collected is : ^0000CD[" + $totaldonate + "]^000000 Zeny.";
	next;
	mes .@n$;
	mes "You can only donate 1,000,000z or 5,000,000z.";// different from menu
	next;
	mes .@n$;
	mes "If I collected a total amount of ^FF000075,000,000^000000z.";
	mes "I can activate this event:";
	mes "Event: ^8B008BComodo Hat Festival Quest^000000.";
	mes "Event Duration: ^006400[2 DAYS]^000000.";
	next;
	mes .@n$;
	mes "How much money you want to donate?";
	mes "Once you donate, I can't your money back.";
	next;
	.@size = getarraysize( .@donation_Zeny );
	for ( .@i = 0; .@i < .@size; .@i++ )
		.@menu$ += callfunc( "F_InsertComma", .@donation_Zeny[.@i] ) + ":";		// dynamical menu
	.@s = select(.@menu$) - 1;

	if ($totaldonate >= 75000000) {		// already on
		mes .@n$;
		mes "The total amount I collected is : ^0000CD[" + $totaldonate + "]^000000 Zeny.";
		close;
	}
	if (Zeny < .@donation_Zeny[.@s]) {	// re-check player zeny amount
		mes .@n$;
		mes "Sorry, you dont have enough money to talk to me.";
		mes "You need to have atleast ^FF00005,000,000z^000000.";
		mes "The total amount I collected is : ^0000CD[" + $totaldonate + "]^000000 Zeny.";
		close;
	}     
	set Zeny, Zeny - .@donation_Zeny[.@s];
	set $totaldonate, $totaldonate + .@donation_Zeny[.@s];
	mes .@n$;
	mes "Thank you for donating " + callfunc( "F_InsertComma", .@donation_Zeny[.@s] ) + "z!";
	mes "We appreciate your generosity.";
	announce "[Charity Lucy: "+strcharinfo(0)+"] has donated [" + callfunc( "F_InsertComma", .@donation_Zeny[.@s] ) + "z] to Charity! We appreciate your generosity.",0;
	if ($totaldonate >= 75000000) {
		$donation_timer = gettimetick(2) + 86400;	// 86400 seconds = 2 days
		donpcevent strnpcinfo(3) + "::OnInit";
	}
	next;
	mes .@n$;
	mes "The total amount I collected is : ^0000CD[" + $totaldonate + "]^000000 Zeny.";
	close;

function Display_Timer {
	.@time = getarg(0);
	.@hour = .@time / 3600;
	.@mins = ( .@time % 3600 ) / 60;
	.@secs = .@time % 60;
	.@string$ = (.@hour ? .@hour + " hour" : "");
	.@string$ += (.@string$ != "" ? " " : "") + (.@mins ? .@mins + " min" + (.@mins > 1 ? "s" : "" ) : "");
	.@string$ += (.@string$ != "" ? " " : "") + (.@secs + " sec") + (.@secs > 1 ? "s" : "" );
	return .@string$;
}

OnInit:
	if ($totaldonate < 75000000)
		end;
	.@time_left = $donation_timer - gettimetick(2);
	if (.@time_left <= 0)
		$totaldonate = 0;
	else {
		// unhide npc
		while (.@time_left > 0) {
			waitingroom Display_Timer( .@time_left ),0;
			sleep 1000;
			delwaitingroom;
			.@time_left--;
		}
		// hidenpc
		set $totaldonate, 0;
		$donation_timer = 0;
		announce "Charity Lucy: Charity Event for 2 Days has ended. Don't forget to donate to activate.",0;
		sleep 10000;
		announce "Charity Lucy: Thank you for your generosity.",0;
	}
	end;
}

 

EDIT : oh well I wasn't supposed to post the whole script in support section >.<

Edited by Capuche
  • Upvote 3
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  56
  • Reputation:   6
  • Joined:  03/21/17
  • Last Seen:  

Use donpcevent or enablenpc to trigger and disable npc to hide ? you can also use if(##totaldonate==75000000) and put timer for 2 days till it will be disable ?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  14
  • Reputation:   2
  • Joined:  03/24/13
  • Last Seen:  

@Capuche
Thank you so much, it works perfectly! 

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