Jump to content
  • 0

how to add random map in this script thank you


Enoch

Question


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.02
  • Content Count:  67
  • Reputation:   0
  • Joined:  10/21/19
  • Last Seen:  

//===== rAthena Script ======================================= 
//= Find the gm event (hide and seek)
//===== By: ==================================================
//= Mastagoon
//===== Description: =========================================
//= The npc (GM sprite) will teleport to a random location on
//= the map, and will open a waiting room. The first player to
//= join that waiting room will win the round.
//===== Current Version: =====================================
//= 1.0
//= 1.0.1 Fixed a typo that prevented automatic event start (credit to AinsLord)
//===== Featuers: ============================================
//= Can set the number of rounds, map, item&zeny rewards.
//= the event can start manually or automatically.
//= There is another version of this script compatiable with 
//= Stolao's event manager. You can DM me if you want that file.
//============================================================
freya,209,214,5    script    GM Pritong Kandule#findgm    871,{
    if(.status < 2) {
        mes "["+.npcName+"]";
        mes "When the event begins, i will teleport to a random location on this map.";
        mes "And you need to find me to win!";
        close;
    }
    end;

OnInit:
    //SETTINGS
    .rounds = 10; // for how many rounds should the event last?
    .map$ = "freya"; // the event where the gm will hide    .itemReward = 1;  
    setarray .rewards[0],6242,1;   // [itemId, itemAmount, {....}]
    .zenyReward = 0;
    .zenyAmount = 1000;
    .debugMode = 0;
    .npcName$ = "GM Pritong Kandule";
    .countdown = 3; // the time between event announcements and when the event actually starts.
    .automatic = 1;    // automatic event or does it need a gm to run it manually?
    .runEvery = 1;    // (ignore if manual) run the event ever X hours 
    .offset = 1;    // (ignore if manual) sometimes, you might have another event/announcement at the same time as the event announcement. you can set an offset (announce X minutes after event time.)
    // Do not edit the code below.
    if(.countdown < 0) .countdown = 1;
    if(.rounds < 1) .rounds = 1;
    if(.winnersPerRound < 1) .winnersPerRound = 1;
    for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i+2) {
        if(getitemname(.rewards[.@i]) == "null") {
            debugmes "[Find GM]: Invalid item id provided "+.rewards[.@i]+" removing item from the rewards list..";
            deletearray .rewards[.@i],2;
            .@i -= 2;
        }
    }
    .status = 0;
    bindatcmd("eventstart", strnpcinfo(3)+"::OnEventAnnounce",60,99);
    strnpcinfo(3);
    end;

OnMinute00:
    if(.status || !.automatic || gettime(DT_HOUR) % .runEvery != 0 || agitcheck() || agitcheck2() || agitcheck3()) end;
    sleep .offset * 1000 * 60;

OnEventAnnounce:
    .status = 1;
    for(.@i = .countdown; .@i > 0; .@i--) {
        announce "[Find "+.npcName$+"] : The event will begin in "+callfunc("F_InsertPlural",.@i,"minute")+"!",bc_all|bc_blue;
        sleep .debugMode ? 5000 : 60000;
    }
    announce "[Find "+.npcName$+"] : The event has now begun!",bc_all|bc_blue;

OnEventStart:
    sleep 2000;
    npctalk "I will now teleport to a random location";
    sleep 2000;
    npctalk "You must find me to win the event!";
    sleep 2000;
    npctalk "This event will last for "+callfunc("F_InsertPlural",.rounds,"round");
    sleep 2000;
    npctalk "Goodluck!";
    donpcevent strnpcinfo(3)+"::OnRoundStart";
    .status = 2;
    .round = 1;
    end;

OnRoundStart:
    initnpctimer;
    do {
        .@x = rand(0,450);
        .@y = rand(0,450);
    } while (!checkcell(.map$,.@x,.@y,cell_chkpass));
    unitwarp getnpcid(0),.map$,.@x,.@y;
    debugmes "[Event]: npc is at: "+.@x+" & "+.@y;
    announce "[Find "+.npcName$+"] :"+.npcName$+" is hiding in a random place in "+.map$+", Find him now!",bc_all|bc_blue;
    delwaitingroom;
    waitingroom "Here!", 2, strnpcinfo(3)+"::OnRoundEnd",1;
    .status = 2;
    end;

OnRoundEnd:
    if(.status != 2) end;
    .status = 1; 
    //#TODO the winner should be already attached here no?
    getwaitingroomusers strnpcinfo(3);
    for(.@i = 0; .@i < getarraysize(.@waitingroom_users); .@i++) {
        if(.@waitingroom_users[.@i] > 0) {
            .@winner = .@waitingroom_users[.@i];
        }
    }
    if(!attachrid(.@winner)) {
        .status = 2;
        end;
    }
    specialeffect2 EF_SPHERE;
    announce .npcName$+": I've been found by "+strcharinfo(0)+"!",bc_all|bc_blue;
    if(.itemReward) {
        for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i +2) {
            getitem .rewards[.@i],.rewards[.@i+1];
        }
    }
    if(.zenyReward) {
        Zeny += .zenyAmount;
        dispbottom "You've gained "+.zenyAmount+" zeny for winning a round in the event.";
    }
    sleep 1000;
    if(.round >= .rounds) {
        donpcevent strnpcinfo(3)+"::OnEventEnd";
        end;
    }
    .round++;
    donpcevent strnpcinfo(3)+"::OnRoundStart";
    end;

OnEventEnd:
    .status = 0;
    announce "[Find "+.npcName$+"]: The event is over! thank you for participating.",bc_all|bc_blue;
    unitwarp getnpcid(0),.map$,209,214;
    delwaitingroom;
    sleep 5000;
    end;

OnTimer1800000:
    if(.status) {
        stopnpctimer;
        donpcevent strnpcinfo(3)+"::OnEventEnd";
    }
    end;
}

 

Edited by Mael
Use a codebox
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  171
  • Reputation:   68
  • Joined:  10/25/20
  • Last Seen:  

//===== rAthena Script ======================================= 
//= Find the gm event (hide and seek)
//===== By: ==================================================
//= Mastagoon
//===== Description: =========================================
//= The npc (GM sprite) will teleport to a random location on
//= the map, and will open a waiting room. The first player to
//= join that waiting room will win the round.
//===== Current Version: =====================================
//= 1.0
//= 1.0.1 Fixed a typo that prevented automatic event start (credit to AinsLord)
//===== Featuers: ============================================
//= Can set the number of rounds, map, item&zeny rewards.
//= the event can start manually or automatically.
//= There is another version of this script compatiable with 
//= Stolao's event manager. You can DM me if you want that file.
//============================================================
freya,209,214,5    script    GM Pritong Kandule#findgm    871,{
    if(.status < 2) {
        mes "["+.npcName+"]";
        mes "When the event begins, i will teleport to a random location on this map.";
        mes "And you need to find me to win!";
        close;
    }
    end;

OnInit:
    //SETTINGS
    .rounds = 10; // for how many rounds should the event last?
    setarray .map$,"freya","prontera","payon"; // the event where the gm will hide
    .itemReward = 1;  
    setarray .rewards[0],6242,1;   // [itemId, itemAmount, {....}]
    .zenyReward = 0;
    .zenyAmount = 1000;
    .debugMode = 0;
    .npcName$ = "GM Pritong Kandule";
    .countdown = 3; // the time between event announcements and when the event actually starts.
    .automatic = 1;    // automatic event or does it need a gm to run it manually?
    .runEvery = 1;    // (ignore if manual) run the event ever X hours 
    .offset = 1;    // (ignore if manual) sometimes, you might have another event/announcement at the same time as the event announcement. you can set an offset (announce X minutes after event time.)
    // Do not edit the code below.
    if(.countdown < 0) .countdown = 1;
    if(.rounds < 1) .rounds = 1;
    if(.winnersPerRound < 1) .winnersPerRound = 1;
    for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i+2) {
        if(getitemname(.rewards[.@i]) == "null") {
            debugmes "[Find GM]: Invalid item id provided "+.rewards[.@i]+" removing item from the rewards list..";
            deletearray .rewards[.@i],2;
            .@i -= 2;
        }
    }
    .status = 0;
    bindatcmd("eventstart", strnpcinfo(3)+"::OnEventAnnounce",60,99);
    strnpcinfo(3);
    end;

OnMinute00:
    if(.status || !.automatic || gettime(DT_HOUR) % .runEvery != 0 || agitcheck() || agitcheck2() || agitcheck3()) end;
    sleep .offset * 1000 * 60;
	.rand_map$ = .map$[rand(getarraysize(.map$))];										   

OnEventAnnounce:
    .status = 1;
	.rand_map$ = .map$[rand(getarraysize(.map$))];										   
    for(.@i = .countdown; .@i > 0; .@i--) {
        announce "[Find "+.npcName$+"] : The event will begin in "+callfunc("F_InsertPlural",.@i,"minute")+"!",bc_all|bc_blue;
        sleep .debugMode ? 5000 : 60000;
    }
    announce "[Find "+.npcName$+"] : The event has now begun!",bc_all|bc_blue;

OnEventStart:
    sleep 2000;
    npctalk "I will now teleport to a random location";
    sleep 2000;
    npctalk "You must find me to win the event!";
    sleep 2000;
    npctalk "This event will last for "+callfunc("F_InsertPlural",.rounds,"round");
    sleep 2000;
    npctalk "Goodluck!";
    donpcevent strnpcinfo(3)+"::OnRoundStart";
    .status = 2;
    .round = 1;
    end;

OnRoundStart:
    initnpctimer;
    do {
        .@x = rand(0,450);
        .@y = rand(0,450);
	} while (!checkcell(.rand_map$,.@x,.@y,cell_chkpass));
	unitwarp getnpcid(0),.rand_map$,.@x,.@y;
    debugmes "[Event]: npc is at: "+.@x+" & "+.@y;
   announce "[Find "+.npcName$+"] :"+.npcName$+" is hiding in a random place in "+.rand_map$+", Find him now!",bc_all|bc_blue;
    delwaitingroom;
    waitingroom "Here!", 2, strnpcinfo(3)+"::OnRoundEnd",1;
    .status = 2;
    end;

OnRoundEnd:
    if(.status != 2) end;
    .status = 1; 
    //#TODO the winner should be already attached here no?
    getwaitingroomusers strnpcinfo(3);
    for(.@i = 0; .@i < getarraysize(.@waitingroom_users); .@i++) {
        if(.@waitingroom_users[.@i] > 0) {
            .@winner = .@waitingroom_users[.@i];
        }
    }
    if(!attachrid(.@winner)) {
        .status = 2;
        end;
    }
    specialeffect2 EF_SPHERE;
    announce .npcName$+": I've been found by "+strcharinfo(0)+"!",bc_all|bc_blue;
    if(.itemReward) {
        for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i +2) {
            getitem .rewards[.@i],.rewards[.@i+1];
        }
    }
    if(.zenyReward) {
        Zeny += .zenyAmount;
        dispbottom "You've gained "+.zenyAmount+" zeny for winning a round in the event.";
    }
    sleep 1000;
    if(.round >= .rounds) {
        donpcevent strnpcinfo(3)+"::OnEventEnd";
        end;
    }
    .round++;
    donpcevent strnpcinfo(3)+"::OnRoundStart";
    end;

OnEventEnd:
    .status = 0;
    announce "[Find "+.npcName$+"]: The event is over! thank you for participating.",bc_all|bc_blue;
    unitwarp getnpcid(0),.rand_map$,195,58;
    delwaitingroom;
    sleep 5000;
    end;

OnTimer1800000:
    if(.status) {
        stopnpctimer;
        donpcevent strnpcinfo(3)+"::OnEventEnd";
    }
    end;
}

 

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  61
  • Topics Per Day:  0.02
  • Content Count:  911
  • Reputation:   166
  • Joined:  11/27/14
  • Last Seen:  

25 minutes ago, cook1e said:
//===== rAthena Script ======================================= 
//= Find the gm event (hide and seek)
//===== By: ==================================================
//= Mastagoon
//===== Description: =========================================
//= The npc (GM sprite) will teleport to a random location on
//= the map, and will open a waiting room. The first player to
//= join that waiting room will win the round.
//===== Current Version: =====================================
//= 1.0
//= 1.0.1 Fixed a typo that prevented automatic event start (credit to AinsLord)
//===== Featuers: ============================================
//= Can set the number of rounds, map, item&zeny rewards.
//= the event can start manually or automatically.
//= There is another version of this script compatiable with 
//= Stolao's event manager. You can DM me if you want that file.
//============================================================
freya,209,214,5    script    GM Pritong Kandule#findgm    871,{
    if(.status < 2) {
        mes "["+.npcName+"]";
        mes "When the event begins, i will teleport to a random location on this map.";
        mes "And you need to find me to win!";
        close;
    }
    end;

OnInit:
    //SETTINGS
    .rounds = 10; // for how many rounds should the event last?
    setarray .map$,"freya","prontera","payon"; // the event where the gm will hide
    .itemReward = 1;  
    setarray .rewards[0],6242,1;   // [itemId, itemAmount, {....}]
    .zenyReward = 0;
    .zenyAmount = 1000;
    .debugMode = 0;
    .npcName$ = "GM Pritong Kandule";
    .countdown = 3; // the time between event announcements and when the event actually starts.
    .automatic = 1;    // automatic event or does it need a gm to run it manually?
    .runEvery = 1;    // (ignore if manual) run the event ever X hours 
    .offset = 1;    // (ignore if manual) sometimes, you might have another event/announcement at the same time as the event announcement. you can set an offset (announce X minutes after event time.)
    // Do not edit the code below.
    if(.countdown < 0) .countdown = 1;
    if(.rounds < 1) .rounds = 1;
    if(.winnersPerRound < 1) .winnersPerRound = 1;
    for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i+2) {
        if(getitemname(.rewards[.@i]) == "null") {
            debugmes "[Find GM]: Invalid item id provided "+.rewards[.@i]+" removing item from the rewards list..";
            deletearray .rewards[.@i],2;
            .@i -= 2;
        }
    }
    .status = 0;
    bindatcmd("eventstart", strnpcinfo(3)+"::OnEventAnnounce",60,99);
    strnpcinfo(3);
    end;

OnMinute00:
    if(.status || !.automatic || gettime(DT_HOUR) % .runEvery != 0 || agitcheck() || agitcheck2() || agitcheck3()) end;
    sleep .offset * 1000 * 60;
	.rand_map$ = .map$[rand(getarraysize(.map$))];										   

OnEventAnnounce:
    .status = 1;
	.rand_map$ = .map$[rand(getarraysize(.map$))];										   
    for(.@i = .countdown; .@i > 0; .@i--) {
        announce "[Find "+.npcName$+"] : The event will begin in "+callfunc("F_InsertPlural",.@i,"minute")+"!",bc_all|bc_blue;
        sleep .debugMode ? 5000 : 60000;
    }
    announce "[Find "+.npcName$+"] : The event has now begun!",bc_all|bc_blue;

OnEventStart:
    sleep 2000;
    npctalk "I will now teleport to a random location";
    sleep 2000;
    npctalk "You must find me to win the event!";
    sleep 2000;
    npctalk "This event will last for "+callfunc("F_InsertPlural",.rounds,"round");
    sleep 2000;
    npctalk "Goodluck!";
    donpcevent strnpcinfo(3)+"::OnRoundStart";
    .status = 2;
    .round = 1;
    end;

OnRoundStart:
    initnpctimer;
    do {
        .@x = rand(0,450);
        .@y = rand(0,450);
	} while (!checkcell(.rand_map$,.@x,.@y,cell_chkpass));
	unitwarp getnpcid(0),.rand_map$,.@x,.@y;
    debugmes "[Event]: npc is at: "+.@x+" & "+.@y;
   announce "[Find "+.npcName$+"] :"+.npcName$+" is hiding in a random place in "+.rand_map$+", Find him now!",bc_all|bc_blue;
    delwaitingroom;
    waitingroom "Here!", 2, strnpcinfo(3)+"::OnRoundEnd",1;
    .status = 2;
    end;

OnRoundEnd:
    if(.status != 2) end;
    .status = 1; 
    //#TODO the winner should be already attached here no?
    getwaitingroomusers strnpcinfo(3);
    for(.@i = 0; .@i < getarraysize(.@waitingroom_users); .@i++) {
        if(.@waitingroom_users[.@i] > 0) {
            .@winner = .@waitingroom_users[.@i];
        }
    }
    if(!attachrid(.@winner)) {
        .status = 2;
        end;
    }
    specialeffect2 EF_SPHERE;
    announce .npcName$+": I've been found by "+strcharinfo(0)+"!",bc_all|bc_blue;
    if(.itemReward) {
        for(.@i = 0; .@i < getarraysize(.rewards); .@i = .@i +2) {
            getitem .rewards[.@i],.rewards[.@i+1];
        }
    }
    if(.zenyReward) {
        Zeny += .zenyAmount;
        dispbottom "You've gained "+.zenyAmount+" zeny for winning a round in the event.";
    }
    sleep 1000;
    if(.round >= .rounds) {
        donpcevent strnpcinfo(3)+"::OnEventEnd";
        end;
    }
    .round++;
    donpcevent strnpcinfo(3)+"::OnRoundStart";
    end;

OnEventEnd:
    .status = 0;
    announce "[Find "+.npcName$+"]: The event is over! thank you for participating.",bc_all|bc_blue;
    unitwarp getnpcid(0),.rand_map$,195,58;
    delwaitingroom;
    sleep 5000;
    end;

OnTimer1800000:
    if(.status) {
        stopnpctimer;
        donpcevent strnpcinfo(3)+"::OnEventEnd";
    }
    end;
}

 

 

 setarray .map$,"freya","prontera","payon"; // the event where the gm will hide

Add your desire map

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