Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function script setCoordinate {
- .@npc_id = getnpcid(0);
- .@map$ = getvariableofnpc( .map$,"Sample#main");
- if( getarg(0) == 0 ){
- do{
- .@x = rand( 50,200 );
- .@y = rand( 50,180 );
- }while( !checkcell( .@map$,.@x,.@y,cell_chkpass ) );
- }else{
- .@x = 50;
- .@y = 50;
- }
- unitwarp .@npc_id,.@map$,.@x,.@y;
- return;
- }
- - script Sample#main -1,{
- OnInit:
- // event map
- .map$ = "xmas_fild01";
- // event duration
- .event_minute = 1;
- // mapflags
- setarray .@mapflag[0],0,1,2,3,9,13,22,33,34,42,45;
- .@mf_size = getarraysize( .@mapflag );
- for( .@i = 0; .@i < .@mf_size; .@i++ )
- setmapflag .map$,.@mapflag[.@i];
- // remove all players from the map
- mapwarp .map$,"prontera",155,181;
- end;
- OnPCLoadMapEvent:
- if( strcharinfo(3) == .map$ ){
- if( .status && getcharid(2) ){
- @collected_points = 0;
- .@guild_size = getarraysize( .guild_list );
- for( .@i = 0; .@i <= .@guild_size; .@i++ )
- if( .@i == .@guild_size ){
- .guild_list[.@i] = getcharid(2);
- break;
- }else if( .guild_list[.@i] == getcharid(2) ){
- break;
- }
- @guild_index = .@i;
- }else{
- mes "You cant enter this map if the event is not started / you are guildless";
- close2;
- warp "SavePoint",0,0;
- }
- }
- end;
- OnWhisperGlobal:
- OnMinute00:
- // start event if not started yet
- if( !.status ){
- // remove all player
- mapwarp .map$,"prontera",155,181;
- // clear data
- deletearray .winner;
- deletearray .guild_list;
- deletearray .guild_score;
- // event start
- .status = 1;
- announce "event start",0;
- donpcevent "::OnEventStart";
- sleep2 ( .event_minute * 60000 );
- // event end
- .status = 0;
- announce "event end",0;
- donpcevent "::OnEventEnd";
- // Check for highest score guild with minimum of 1 point
- for( .@i = 0; .@i < getarraysize( .guild_list ); .@i++ )
- if( .guild_score[.@i] && .guild_score[.@i] >= .winner[1] ){
- .winner[0] = .guild_list[.@i];
- .winner[1] = .guild_score[.@i];
- }
- // announce winner guild
- if( getarraysize( .winner ) == 2 ){
- announce "Guild "+getguildname( .winner[0] )+" win the game with "+.winner[1]+" scores.",0;
- }
- }
- end;
- // update points when clicked
- OnCollectPoint:
- if( .status && getcharid(2) && @collected_points ){
- .guild_score[ @guild_index ] += @collected_points;
- @collected_points = 0;
- announce "Guild "+getguildname( .guild_list[ @guild_index ] )+" scored "+.guild_score[ @guild_index ]+" points already.",0;
- }
- end;
- }
- xmas_fild01,73,73,4 script Point Collector 757,{
- doevent "Sample#main::OnCollectPoint";
- }
- prontera,1,1,1 script item#0 723,{
- if( getvariableofnpc( .status,"Sample#main") && getcharid(2) ){
- progressbar "ffffff",1;
- // generate points
- .@point = rand( 1,4 );
- @collected_points += .@point;
- mes "this item have ^0055ff"+.@point+" points^000000.";
- mes " ";
- mes "total points : ^ff0000"+@collected_points+" points^000000";
- // hide npc and re-coordinate the npc
- hideonnpc strnpcinfo(0);
- close2;
- setCoordinate( 0,getnpcid(0) );
- sleep ( ( 10 + .@point * 20 ) * 100 );
- hideoffnpc strnpcinfo(0);
- }
- end;
- OnEventStart:
- setCoordinate( 0,getnpcid(0) );
- hideoffnpc strnpcinfo(0);
- end;
- OnEventEnd:
- setCoordinate( 1,getnpcid(0) );
- hideonnpc strnpcinfo(0);
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment