Jump to content
  • 0
Sign in to follow this  
MikZ

WOE reward time

Question

Good day!

May I request please.
whats the equivalent of addrid to hercules and how to add to this script. thank you!

function	script	getcharid2	{
	.@size = query_sql("select char_id, party_id, guild_id, account_id, clan_id from `char` where name = '"+getarg(1)+"'",.@charid,.@pid,.@gid,.@aid,.@cid);
	if(.@size < 0) return 0;
	if(getarg(0)==0) return .@charid;
	else if(getarg(0)==1) return .@pid;
	else if(getarg(0)==2) return .@gid;
	else if(getarg(0)==3) return .@aid;
	else if(getarg(0)==4) return .@cid;
	return 0;
}

-	script	woerewards	-1,{ 

function	AddPlayer	{ //player name , npc name
	for (.@i = 0 ; .@i < getvariableofnpc(.player_amount,getarg(1)) ; .@i += 3)
		if (getvariableofnpc(.players$[.@i],getarg(1)) == getarg(0)) return;
	setarray getvariableofnpc(.players$[getvariableofnpc(.player_amount,getarg(1))],getarg(1)) , getarg(0) , strcharinfo(3) , "0";
	set getvariableofnpc(.player_amount,getarg(1)) , getvariableofnpc(.player_amount,getarg(1)) + 3;
	return;
}

OnInit:
	setarray .maps$ ,"schg_cas03", "prtg_cas01"; //maps where the system is active
    .points_per_minute = 1; //number of points earned for each minute you spend in the castle
    for (.@i = 0 ; .@i < getarraysize(.maps$) ; .@i++)
        if (!getmapflag(.maps$[.@i],mf_loadevent)) setmapflag .maps$[.@i],mf_loadevent;

    .s_idle_time = 180; // time before player is considered idle (in seconds)
    .rewardId = 909;    // ID of the reward item
    .announce = 0;  // Announce kills (0 = no announcement, 1 = map announcement, 2 = global announcement)
    .color_defenders$ = "0xffff00"; // Announcement color when a defending player kills an attacking player
    .color_attackers$ = "0x99ccff"; // Announcement color when an attacking player kills a member of the castle's owner
    .kill_reward = 1;   // Amount of points earned for every kill, set to 0 to disable it
    setarray .class_modifier[0],4063,3,4076,2;  // Modifier for certain classes [Id, Modifier, Id, Modifier....]
	if(agitcheck() || agitcheck2()) initnpctimer;
	end;

OnAgitStart:
	.@sql$ = "DELETE from `char_reg_num` WHERE `key` = 'woepoints' OR `key` = 'woedeaths' OR `key` = 'woekills' OR `key` = 'woedamage' OR `key` = 'woeempbreak'";
	query_sql(.@sql$);
	addrid(0);
	woepoints = 0;
	detachrid();
	initnpctimer;
	end;

OnPCLoadMapEvent:
	if(!agitcheck() || !getcharid(2)) end;
	for (.@i = 0 ; .@i < getarraysize(.maps$) ; .@i++) {
		if (.maps$[.@i] == strcharinfo(3)) {
			if(!woepoints) {
				dispbottom "You've entered a WoE castle map, you will gain rewards for each minute you spend in this castle.";
			}
			AddPlayer(strcharinfo(0),strnpcinfo(0));
		}
	}
	end;

OnTimer10000: //will check every ten seconds if player is still on the map
	freeloop (1);
	for (.@i = 0 ; .@i < .player_amount ; .@i += 3) {
		if (!attachrid(getcharid2(3,.players$[.@i]))) { deletearray .players$[.@i],3 ; .player_amount -= 3; }
		else if(strcharinfo(3) != .players$[.@i+1]) { deletearray .players$[.@i],3 ; .player_amount -= 3; }
	}
	for (.@i = 0 ; .@i < .player_amount ; .@i += 3) {
		if(checkidle() < .s_idle_time) {    // no points for idle players
            setarray .players$[.@i+2] , ""+(atoi(.players$[.@i+2]) + 1)+"";
            if (atoi(.players$[.@i+2]) >= 6) {
                if(attachrid(getcharid2(3,.players$[.@i]))) {
                    woepoints += .points_per_minute;
                    dispbottom "You've spent one minute in WoE and gained a WoE point."
                    dispbottom "Total points earned: "+woepoints;
                    setarray .players$[.@i+2] , "0";
                }
            }
        }
	}
	initnpctimer;
	freeloop(0);
	end;

OnPCKillEvent:
	if(!agitcheck() || !getcharid(2) || !.kill_reward) end;
	if(inarray(.maps$,strcharinfo(3)) == -1) end;
	dispbottom "You've recieved "+.kill_reward+" Points for killing "+rid2name(killedrid);
	woepoints += .kill_reward;
    .@color$ = getcharid(2) == getcastledata(strcharinfo(3),CD_GUILD_ID) ? .color_defenders$ :  .color_attackers$;
    if(.announce == 1) 
        announce "[WoE]: "+strcharinfo(0)+" Has Killed "+rid2name(killedrid),bc_all,.@color$;
    if(.announce == 2)
        mapannounce strcharinfo(3),"[WoE]: "+strcharinfo(0)+" Has Killed "+rid2name(killedrid),bc_map,.@color$;
	end;
	
OnPCDieEvent:
	if(!agitcheck() || !getcharid(2)) end;
	if(inarray(.maps$,strcharinfo(3)) == -1) end;
	dispbottom "You've been killed by "+rid2name(killerrid);
	end;

OnPCLogoutEvent:
	if(!agitcheck() && !agitcheck2()) 
		woepoints = 0;
	end;

OnAgitEnd:
	stopnpctimer;
	//participation rewards.
	.@sql$ = "SELECT `char_id`, `value` FROM `char_reg_num` WHERE `key` = 'woepoints'";
	query_sql(.@sql$,.@ids, .@points);
	for(.@i = 0; .@i < getarraysize(.@ids); .@i++) {
        .@modifier = inarray(.class_modifier, Class) > -1 ? .class_modifier[inarray(.class_modifier, Class)+1] : 1;
		.@charid = .@ids[.@i];
		.@sender$ = "[WoE Rewards]";
		.@title$ = "Rewards";
		.@body$ = "You've recieved a reward for participating in war of emperium.\nTotal Participation Time:";
		setarray .@itemarray[0],.coinid;
		setarray .@itemamtarray[0], .@points[.@i] * .@modifier;
		mail .@charid,.@sender$,.@title$,.@body$,.@zeny,.@itemarray,.@itemamtarray;
	}
	end;

}

 

Edited by MikZ

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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