Jump to content

Scofield

Members
  • Posts

    272
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by Scofield

  1. complete controller script

    - script WoEInfoBase -1,{
     
    OnStartMenu:
    if(.init == 0)
    donpcevent strnpcinfo(3)+"::OnInit";
     
    OnStartMenu2:
    mes "The " + ((.state)?"^00DD00current":"^DD0000next") + "^000000 WoE session is: ";
    mes " ";
    mes "Day: ^0000DD" + .daysOfWeek$[.woe_day[.woe_index]];
    mes "^000000Start time: ^00DD00" + .woe_0_str$[.woe_index];
    mes "^000000End time: ^DD0000" + .woe_1_str$[.woe_index];
    mes "^000000Region:";
     
    set .@state_strs$, ".woe_state_str_" + .woe_state[.woe_index] + "$";
    for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
    set .@output$, getd(.@state_strs$ + "[" + .@i + "]");
    if(.@output$ != "")
    mes "^000000- ^0000DD" + .@output$;
    }
    next;
     
    if(getgmlevel() >= .gm_access)
    select(
    "Warp to Castle Grounds",
    "View Castle Owners",
    "View all WoE times", 
    ((!.state)?"Start next WoE":"End current WoE"),
    ((.state)?"":"Skip next WoE session")
    );
    else
    select(
    "Warp to Castle Grounds",
    "View Castle Owners",
    "View all WoE times");
     
    switch(@menu) {
    case 1: //warp
    mes "Which region would you like to warp to?";
    next;
    select(.region_warp$[.woe_state[.woe_index]]);
    if(@menu < 1 || @menu > .num_regions)
    close;
     
    close2;
    warp .region_maps$[@menu - 1], .region_x[@menu - 1], .region_y[@menu - 1];
    end;
    case 2: //view 
    set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
    for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
    set .@k, 0;
    set .@castles$, ".castles_" + .regions$[.@i] + "$";
    set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
    while(.@castle_check && .@k < .num_castles[.@i]) {
    if(.@castle_check & (1 << .@k)) {
    set .@map$, getd(.@castles$+"["+.@k+"]");
    if (GetCastleData(.@map$,1)) {
    dispbottom "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently held by the [" + GetGuildName(GetCastleData(.@map$,1)) + "] guild.";
    } else {
    dispbottom "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently unoccupied.";
    }
    set .@castle_check, .@castle_check - (1 << .@k);
    }
    set .@k, .@k + 1; 
    }
    }
    break;
    case 3: //woe times
    for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1) { 
    dispbottom "- " + .daysOfWeek$[.woe_day[.@i]] + " " + .woe_0_str$[.@i] + "-" + .woe_1_str$[.@i];
    set .@woe_state_str_array$, ".woe_state_str_" + .woe_state[.@i] + "$";
    for(set .@k, 0; .@k < .num_regions; set .@k, .@k + 1) {
    set .@output$, getd(.@woe_state_str_array$ + "[" + .@k + "]");
    if(.@output$ != "")
    dispbottom "        " + .@output$;
    }
    }
    break;
    case 4: //start next;
    if(getgmlevel() <.gm_access) close;
     
    mes "^FF0000Are you sure you want to " + ((!.state)?"start the next WoE session?":"end the current WoE session?");
    next;
    if(select("Yes:No") == 2) break;
     
    set .remainTime, 0; //might not work sometimes...you have like a 500ms window out of 505ms i guess..
    sleep2 .timer_refresh_rate; //wait abit so the menu doesn't screw up (how long it takes for the timer to update)
    break;
    case 5: //skip next;
    if(getgmlevel() <.gm_access || .state) close;
     
    mes "^FF0000Are you sure you want to skip the next WoE session^000000";
    next;
    if(select("Yes:No") == 2) break;
    if(.state) { //you really can't do this with woe active
    next;
    mes "Sorry, in the time you took making your decision, WoE started";
    mes "Please either manually end it first or wait";
    break; 
    }
    set .woe_index, (.woe_index + 1) % .num_woes;
    donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
    sleep2 .timer_refresh_rate;
    break;
    default: close; 
    }
    goto OnStartMenu2;
     
    OnInit:
     
    //-----------------------------------------------------------------------------------------//
    //CONFIG START                                                                             //
    //-----------------------------------------------------------------------------------------//
     
    set .gm_access, 60;
     
    //WoE timings needs to be ordered ascendingly unless you want to do weird 
    //stuff like skip a region every other week or so...
    //Also times can't overlap. Uses second of day(gettimetick(1)) for timing
    // eg 1am -> 3600, 2:30pm -> 52200, midnight -> 86400 (anything past that doesn't work)
    //Note: woe_0 is start times, woe_1 is end times. Ignore how it's called but
    //  don't change it either since it's dynamically used
    //  Also..woe has to end on the same day it starts (it's easier that way..)
    setarray .woe_day[0], 0,    3,    6;
    setarray .woe_0[0], 68400,68400,68400;
    setarray .woe_1[0], 72000,72000,72000;
    setarray .woe_state[0], 0,    1,    2;
     
    //WoE state settings. Every WoE session can be defined as a particular state of castle configuration.
    //.woe_state_#[%] = $
    // # - state number
    // % - region number
    // $ - binary representation of castles that are active for that region in that state (
    //     (ie. 0 is no castles, 5 is castle 0 and 2  (2^0 + 2^2 = 5))
    setarray .woe_state_0[0],4,0,0,0,0,0,0;
    setarray .woe_state_1[0],1,0,0,0,0,0,0;
    setarray .woe_state_2[0],2,0,0,0,0,0,0;
     
    //Setting for if script handles WoE controller function. Disable agit_controller.txt if you are using this.
    //For if you want to use something else to handle your woe stuff but only this script
    //to show info (1 - on, 0 - off...duh)
    set .active_woe, 1;
     
     
    //WoE inactive on map notifier. Basically notifies player if the castle they are entering is
    //WoE active or not
    set .notify_woe, 1;
     
    //-----------------------------------------------------------------------------------------//
    //CONFIG END                                                                               //
    //-----------------------------------------------------------------------------------------//
     
     
    //-----------------------------------------------------------------------------------------//
    //CONSTANTS START - Don't touch this unless you know what you are doing                    //
    //-----------------------------------------------------------------------------------------//
     
    //castle maps by region
    setarray .castles_prtg$[0],"prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05";
    setarray .castles_payg$[0],"payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05";
    setarray .castles_gefg$[0],"gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05";
    setarray .castles_aldeg$[0],"aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05";
    setarray .castles_arug$[0],"arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05";
    setarray .castles_schg$[0],"schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
    setarray .castles_novi$[0],"nguild_alde","nguild_gef","nguild_pay","nguild_prt";
     
    //woe kill functions for each castle
    setarray .woe_kill_prtg$[0],"Agit#prtg_cas01::OnAgitEnd","Agit#prtg_cas02::OnAgitEnd","Agit#prtg_cas03::OnAgitEnd","Agit#prtg_cas04::OnAgitEnd","Agit#prtg_cas05::OnAgitEnd";
    setarray .woe_kill_payg$[0],"Agit#payg_cas01::OnAgitEnd","Agit#payg_cas02::OnAgitEnd","Agit#payg_cas03::OnAgitEnd","Agit#payg_cas04::OnAgitEnd","Agit#payg_cas05::OnAgitEnd";
    setarray .woe_kill_gefg$[0],"Agit#gefg_cas01::OnAgitEnd","Agit#gefg_cas02::OnAgitEnd","Agit#gefg_cas03::OnAgitEnd","Agit#gefg_cas04::OnAgitEnd","Agit#gefg_cas05::OnAgitEnd";
    setarray .woe_kill_aldeg$[0],"Agit#aldeg_cas01::OnAgitEnd","Agit#aldeg_cas02::OnAgitEnd","Agit#aldeg_cas03::OnAgitEnd","Agit#aldeg_cas04::OnAgitEnd","Agit#aldeg_cas05::OnAgitEnd";
    setarray .woe_kill_arug$[0],"Manager#aru01_02::OnAgitEnd2","Manager#aru02_02::OnAgitEnd2","Manager#aru03_02::OnAgitEnd2","Manager#aru04_02::OnAgitEnd2","Manager#aru05_02::OnAgitEnd2";
    setarray .woe_kill_schg$[0],"Manager#sch01_02::OnAgitEnd2","Manager#sch02_02::OnAgitEnd2","Manager#sch03_02::OnAgitEnd2","Manager#sch04_02::OnAgitEnd2","Manager#sch05_02::OnAgitEnd2";
    setarray .woe_kill_novi$[0],"Agit_N01::OnAgitEnd","Agit_N02::OnAgitEnd","Agit_N03::OnAgitEnd","Agit_N04::OnAgitEnd";
     
    //region prefixs
    setarray .regions$[0],"prtg","payg","gefg","aldeg","arug","schg","novi";
     
    //region info
    setarray .region_names$[0],"Prontera", "Payon", "Geffen", "Aldebaran", "Arunafeltz", "Schwarzwald", "Novice Castles";
    setarray .region_maps$[0],"prt_gld", "pay_gld", "gef_fild13", "alde_gld", "aru_gld", "sch_gld", "prontera";
    //coords to warp player to region (0 is random)
    setarray .region_x[0],0, 0, 0, 0, 0, 0, 148;
    setarray .region_y[0],0, 0, 0, 0, 0, 0, 163;
     
    setarray .waitMsg$[0], "WoE Starts: ", "WoE Ends: ";
    setarray .startMsg$[0], "WoE is Starting", "WoE is Ending";
     
    set .ticks_in_day, 86400; //mmm...magic numbers
    setarray .daysOfWeek$[0], "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday";
     
    set .timer_refresh_rate, 500; //how many ms per timer refresh...keep less than 1000 (in milliseconds)
    set .change_state_sleep, 3000; //how long to show "WoE is Start|End-ing" msg for in ms. (in milliseconds)
    //Make sure WoE sessions are longer than this xD
    set .banner_refresh_rate, 10; //how many seconds per banner refresh...keep 1 or above (in seconds)
     
    //-----------------------------------------------------------------------------------------//
    //CONSTANTS END                                                                            //
    //-----------------------------------------------------------------------------------------//
     
    set .num_regions, getarraysize(.regions$);
    set .num_woes, getarraysize(.woe_1);
     
    //force WoE to end if active
    callfunc "WoEToggler", 0;
     
    for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
    //count num castles per region
    set .num_castles[.@i], getarraysize(getd(".castles_" + .regions$[.@i] + "$"));
    }
     
    //convert timestamps to readable format
    for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1)
    {
    set .@hrs, .woe_0[.@i] / 3600;
    set .@mins, .woe_0[.@i] % 3600 / 60;
    set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM"); 
     
    set .woe_0_str$[.@i], .@output$; 
     
    set .@hrs, .woe_1[.@i] / 3600;
    set .@mins, .woe_1[.@i] % 3600 / 60;
    set .@output$, ((.@hrs % 12)?.@hrs%12:12) + ":" + ((.@mins < 10)?"0"+.@mins:.@mins) + " " + ((.@hrs > 12)?"PM":"AM"); 
     
    set .woe_1_str$[.@i], .@output$; 
    }
     
    //calc number of woe states and consolidate states to create list of castles used
    set .num_states, 0;
    while(getarraysize(getd(".woe_state_" + (.num_states)))) {
    set .@state$, ".woe_state_" + .num_states;
    set .@i, 0;
    while(.@i < getarraysize(getd(.@state$))) {
    set .castleUsage[.@i], .castleUsage[.@i] | getd(.@state$ + "[" + .@i + "]");
    set .@i, .@i + 1;
    }
    set .num_states, .num_states + 1; 
    }
     
    for(set .@i, 0; .@i < .num_states; set .@i, .@i + 1) { 
    set .@woe_state_array$, ".woe_state_" + .@i;
    for(set .@k, 0; .@k < .num_regions; set .@k, .@k + 1) {
    if(.castleUsage[.@k] > 0) {
    set .@castles$, ".castles_" + .regions$[.@k] + "$";
    set .@castle_check, getd(.@woe_state_array$ + "[" + .@k + "]");
    if(.@castle_check == 0) { //region not in this state
    //region warp menu string
    set .region_warp$[.@i], .region_warp$[.@i] + "^DD0000" + .region_names$[.@k] + "^000000:";
    continue;
    } else {
    if(.@castle_check >= ((1 << .num_castles[.@k]) - 1)) {
    //includes all castles...just list as region.
    setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k]);
     
    //region warp menu string
    set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + "^000000:";
    } else {
    set .@j, 0;
    set .@output$, "";
    while(.@j < .num_castles[.@k]) {
    if(.@castle_check & (1 << .@j)) {
    set .@output$, .@output$ + GetCastleName(getd(.@castles$+"["+.@j+"]"));
    set .@castle_check, .@castle_check - (1 << .@j);
    if(.@castle_check) {
    if(.@output$ != "") 
    set .@output$, .@output$ + ", ";
    } else
    break;
    }
    set .@j, .@j + 1;
    }
    setd(".woe_state_str_" + .@i + "$[" + .@k + "]", .region_names$[.@k] + " ("+  .@output$ + ")");
     
    //region warp menu string
    set .region_warp$[.@i], .region_warp$[.@i] + "^00DD00" + .region_names$[.@k] + " ("+  .@output$ + ")^000000:";
    }
    }
    } else {
    set .region_warp$[.@i], .region_warp$[.@i] + ":";
    }
    }
    }
     
    donpcevent strnpcinfo(3)+"::OnFindCurIndex";
    donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
     
    if(.active_woe) {
    if(.notify_woe) {
    //set mapflag for all castle maps
    for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
    set .@region_array$, ".castles_" + .regions$[.@i] + "$";
    for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
    setmapflag getd(.@region_array$ + "[" + .@k + "]"), mf_loadevent;
    setd(".loadmap_region_" + getd(.@region_array$ + "[" + .@k + "]"), .@i + 1);
    setd(".loadmap_castleIndex_" + getd(.@region_array$ + "[" + .@k + "]"), .@k);
    }
    }
    }
    //activates WoE if needed
    donpcevent strnpcinfo(3)+"::OnDoWoE";
    }
    //flag that init occured
    set .init, 1;
     
    OnWoETimer:
    //timer stuff
    while (1) {
    set .remainTime, .count_tick - gettimetick(2);
    set .bannerTimer, .remainTime - (.remainTime % .banner_refresh_rate) + .banner_refresh_rate;
    set .min, .bannerTimer / 60;
    set .sec, .bannerTimer - .min * 60;
    set .hr, .min / 60;
    set .min, .min - .hr * 60;
    set .roomMsg$, .waitMsg$[.state] + .hr + ":" + ((.min < 10 )?"0":"") + .min + ":" + ((.sec < 10 )?"0":"") + .sec;
    sleep .timer_refresh_rate;
     
    if(.remainTime <= 0) {
    if(.active_woe) {
    donpcevent strnpcinfo(3)+"::OnDoWoE";
    }
    set .roomMsg$, .startMsg$[.state];
     
    set .woe_index, (.woe_index + .state) % .num_woes; //go to next index if needed
    set .state, (.state + 1) % 2; //flip state
     
    donpcevent strnpcinfo(3)+"::OnUpdateCountTick";
    sleep .change_state_sleep;
    }
    }
    end; //obligatory end =D 
     
    OnUpdateCountTick:
    set .count_tick, getd(".woe_" + .state + "[" + .woe_index + "]");
    set .count_tick, gettimetick(2) + .count_tick - gettimetick(1) + (.woe_day[.woe_index] - gettime(4) + 7) % 7 * .ticks_in_day;
     
    if(gettimetick(2) > .count_tick)
    set .count_tick, .count_tick + 7 * .ticks_in_day;
    end;
     
    OnFindCurIndex:
     
    set .@cur_day, gettime(4); 
    set .@cur_tick, gettimetick(1);
     
    set .woe_index, 0;
    set .state, 0;
     
    for(set .@i, 0; .@i < .num_woes; set .@i, .@i + 1) {
    if(.woe_day[.@i] < .@cur_day)
    continue;
     
    if(.woe_day[.@i] == .@cur_day) {
    if(.woe_0[.@i] >= .@cur_tick) {
    set .woe_index, .@i;
    set .state, 0;
    break;
    }
    if(.woe_1[.@i] >= .@cur_tick) {
    set .woe_index, .@i;
    set .state, 1;
    break;
    }
    }
    if(.woe_day[.@i] > .@cur_day) {
    set .woe_index, .@i;
    set .state, 0;
    break;
    } 
    }
    end;
     
    //On map notifier
    //Comment out OnPCLoadMapEvent label if .notify_woe is disabled to prevent unnecessary triggering
    OnPCLoadMapEvent:
    if(.state && .notify_woe) {
    getmapxy(.@map$, .@x, .@y, 0);
    set .@region, getd(".loadmap_region_" + .@map$) - 1;
    if(.@region >= 0) {
    set .@castleIndex, getd(".loadmap_castleIndex_" + .@map$);
    if(getd(".woe_state_" + .woe_state[.woe_index] + "[" + .@region + "]") & 1 << .@castleIndex)
    dispbottom "The [" + GetCastleName(.@map$) + "] castle is available for conquering during this WoE session";
    else
    dispbottom "The [" + GetCastleName(.@map$) + "] castle is NOT available for conquering during this WoE session";
    }
    }
    end;
     
    //------------------------------------------------------------------------------
    // WoE Controller Stuff Here
    //------------------------------------------------------------------------------
     
    OnDoWoE: 
    if((.state == 0 && .init) || (.state == 1 && !agitcheck())) { //starting
    callfunc "WoEToggler", 1; 
     
    //kills WoE in all castles that shouldn't have WoE
    set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
    for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
    set .@castles$, ".castles_" + .regions$[.@i] + "$";
    set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
     
    for(set .@k, 0; .@k < .num_castles[.@i]; set .@k, .@k + 1) {
    set .@map$, getd(.@castles$+"["+.@k+"]");
    if((.@castle_check & (1 << .@k)) == 0) {
    donpcevent getd(".woe_kill_" + .regions$[.@i] + "$[" + .@k + "]");
    }
    }
    }
     
    announce "The War Of Emperium has begun!",bc_all;
    donpcevent strnpcinfo(3)+"::OnDisplayOwners";
    } else { //ending
    if(agitcheck()) {
    callfunc "WoEToggler", 0;
    announce "The War Of Emperium is over!",bc_all;
    donpcevent strnpcinfo(3)+"::OnDisplayOwners";
    }
    }
    end;
     
    OnDisplayOwners: //displays based on current region
    set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
    for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
    set .@k, 0;
     
    set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
    set .@castles$, ".castles_" + .regions$[.@i] + "$";
     
    while(.@castle_check && .@k < .num_castles[.@i]) {
    if(.@castle_check & (1 << .@k)) {
    set .@map$, getd(.@castles$+"["+.@k+"]");
    if (GetCastleData(.@map$,1)) {
    announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently held by the [" + GetGuildName(GetCastleData(.@map$,1)) + "] guild.",bc_all;
    } else {
    announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently unoccupied.",bc_all;
    }
    set .@castle_check, .@castle_check - (1 << .@k);
    } 
    set .@k, .@k + 1; 
    }
    }
    end;
    }
    cydonia,125,166,4 script WoE Info 837,{
    if(getwaitingroomstate(3, strnpcinfo(3)) == -1)
    donpcevent strnpcinfo(3)+"::OnInit";
     
    doevent "WoEInfoBase::OnStartMenu";
    end;
     
    OnInit:
    while (1) {
    //only updates if msg is different
    set .banner$, getwaitingroomstate(4, strnpcinfo(3));
    if(getvariableofnpc(.roomMsg$, "WoEInfoBase") != .banner$) {
    delwaitingroom;
    waitingroom getvariableofnpc(.roomMsg$, "WoEInfoBase"), 0;
    }
    sleep 500;
    }
    end;
    }
     
    //zomg! it duplicates!!
    cydonia,137,109,6 duplicate(WoE Info) WoE Info#2winfo 837
     
    //---------------------------------------------------------------------------------------------------------------------
     
    //These two functions handle WoE's activation/deactivation. Since stable does not have AgitStart2/AgitEnd2, 
    //using the trunk version will result in catastrophic failure of the script. Double declaration of the following
    //functions fixes this (you will get warning messages though)
     
    function script WoEToggler { //<state> = 0|1
    if(getarg(0)) {
    AgitStart; 
    } else {
    AgitEnd;
    }
    return;
    }
     
    //if stable script will fail parsing this function, but the rest of the script will still be usable
    function script WoEToggler { //<state> = 0|1
    if(getarg(0)) {
    AgitStart;
    AgitStart2; 
    } else {
    AgitEnd;
    AgitEnd2; 
    }
    return;
    }
    

    My friend helped me Capuche here to be the solution

     

    fix

                announce "The War Of Emperium has begun!",bc_all;
                callsub "OnDisplayOwners";
            } else {            //ending
                if(agitcheck()) {
                    callfunc "WoEToggler", 0;
                    announce "The War Of Emperium is over!",bc_all;
                    callsub "OnDisplayOwners",1;
                }
            }
            end;
            
        OnDisplayOwners:    //displays based on current region
            set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
            for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
                set .@k, 0;
                
                set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
                set .@castles$, ".castles_" + .regions$[.@i] + "$";
                
                while(.@castle_check && .@k < .num_castles[.@i]) {
                    if(.@castle_check & (1 << .@k)) {
                        set .@map$, getd(.@castles$+"["+.@k+"]");
                        set .@gid, GetCastleData(.@map$,1);
                        if ( .@gid ) {
                            announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently held by the [" + GetGuildName(GetCastleData(.@map$,1)) + "] guild.",bc_all;
                            if ( getarg(0,0) ) {
                                set .@nb, query_sql( "select account_id from `char` where guild_id = "+ .@gid +" and online = 1", .@aid );
                                for ( set .@n, 0; .@n < .@nb; set .@n, .@n +1 )
                                    getitem 7539,15, .@aid[.@n];
                            }
                        } else {
                            announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently unoccupied.",bc_all;
                        }
                        set .@castle_check, .@castle_check - (1 << .@k);
                    }                
                    set .@k, .@k + 1;        
                }
            }
            end;
    }
  2. Yes, but for some reason have WoE not be making the award, as the woe of Wednesday and Sunday, so I thought I adicinar the system along with the control script as it makes checking the guild and castle at the end ,

  3. so how do I get the script to give a prize to each member of the guild at the end of woe?

     

     

     

     

    would be something like this?

    set .@nb, query_sql( "select account_id from `char` where guild_id = "+ .@gid +" and online = 1", .@aid );
    for ( set .@i, 0; .@i < .@nb; set .@i, .@i +1 ) {
    attachrid .@aid[.@i];
    getitem 7539,15;
    }
    end;
    }
    
  4. I have this script that against Woe, woe at the end of the castle and he announces winning side, I wanted to add an automatic reward for all members of the winning guild.

    announce "The War Of Emperium has begun!",bc_all;
    donpcevent strnpcinfo(3)+"::OnDisplayOwners";
    } else { //ending
    if(agitcheck()) {
    callfunc "WoEToggler", 0;
    announce "The War Of Emperium is over!",bc_all;
    donpcevent strnpcinfo(3)+"::OnDisplayOwners";
    }
    }
    end;
     
    OnDisplayOwners: //displays based on current region
    set .@woe_state_array$, ".woe_state_" + .woe_state[.woe_index];
    for(set .@i, 0; .@i < .num_regions; set .@i, .@i + 1) {
    set .@k, 0;
     
    set .@castle_check, getd(.@woe_state_array$ + "[" + .@i + "]");
    set .@castles$, ".castles_" + .regions$[.@i] + "$";
     
    while(.@castle_check && .@k < .num_castles[.@i]) {
    if(.@castle_check & (1 << .@k)) {
    set .@map$, getd(.@castles$+"["+.@k+"]");
    if (GetCastleData(.@map$,1)) {
    announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently held by the [" + GetGuildName(GetCastleData(.@map$,1)) + "] guild.",bc_all;
    } else {
    announce "The [" + GetCastleName(.@map$) + "] castle of the [" + .region_names$[.@i] + "] region is currently unoccupied.",bc_all;
    }
    set .@castle_check, .@castle_check - (1 << .@k);
    } 
    set .@k, .@k + 1; 
    }
    }
    end;
    }
  5. I want to make a change in src but when I go to compile error, wanted help to reshape to modification leaving her with the same function

     

     

     

    gcc -g -O2 -pipe -ffast-math -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-pointer-sign -Wno-switch -fno-strict-aliasing -DHAVE_SETRLIMIT -DHAVE_STRNLEN -Wno-unused -Wno-parentheses -DHAVE_MONOTONIC_CLOCK -I../../3rdparty/mt19937ar  -I/usr/include/mysql  -I../common -I/usr/include -c -o obj_sql/battle.o battle.c
    battle.c: In function ‘battle_check_target’:
    battle.c:3433: error: ‘tsd’ undeclared (first use in this function)
    battle.c:3433: error: (Each undeclared identifier is reported only once
    battle.c:3433: error: for each function it appears in.)
    make[1]: *** [obj_sql/battle.o] Error 1
    make[1]: Leaving directory `/home/emulador/src/map'
    make: *** [map_sql] Error 2
    You have new mail in /var/spool/mail/root
    -bash-4.1#
     

     

     

     

     

     

     

     

     

    src/map/battle.c

    if( t_bl == s_bl ) break;
    sd = BL_CAST(BL_PC, t_bl);
     
    if( sd->state.monster_ignore && flag&BCT_ENEMY )
    return 0; // Global inminuty only to Attacks
    + if(s_bl->type == BL_PC)
    + tsd = BL_CAST(BL_PC, s_bl);
    + if(s_bl->type == BL_PC && map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKPVP) && flag&BCT_ENEMY && map_getcell(tsd->bl.m,tsd->bl.x,tsd->bl.y,CELL_CHKPVP))
    + state |= BCT_ENEMY; //PvP enemy.
    if( sd->status.karma && s_bl->type == BL_PC && ((TBL_PC*)s_bl)->status.karma )
    state |= BCT_ENEMY; // Characters with bad karma may fight amongst them
    if( sd->state.killable ) {
    state |= BCT_ENEMY; // Everything can kill it
    strip_enemy = 0;
    }
  6. I am implementing the system cell_pvp which leaves only one aria in pvp map, I ultilizo a pre-renawal version of eAthena, I made the following change over time to give some compile errors, wanted to know what the problem is.

    if( sd->state.monster_ignore && flag&BCT_ENEMY )
    return 0; // Global inminuty only to Attacks
    
    + if(s_bl->type == BL_PC)
    + tsd = BL_CAST(BL_PC, s_bl);
    + if(s_bl->type == BL_PC && map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKPVP) && flag&BCT_ENEMY && map_getcell(tsd->bl.m,tsd->bl.x,tsd->bl.y,CELL_CHKPVP))
    + state |= BCT_ENEMY; //PvP enemy.
    
    if( sd->status.karma && s_bl->type == BL_PC && ((TBL_PC*)s_bl)->status.karma )
    state |= BCT_ENEMY; // Characters with bad karma may fight amongst them
    if( sd->state.killable ) {
    state |= BCT_ENEMY; // Everything can kill it
    strip_enemy = 0;
    
    

    error in console

     

    ql/sql.o ../../3rdparty/mt19937ar/mt19937ar.o -lrt -lm -lz  -ldl -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto
    make[1]: Leaving directory `/home/emulador/src/char_sql'
    make[1]: Entering directory `/home/emulador/src/map'
    gcc -g -O2 -pipe -ffast-math -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-pointer-sign -Wno-switch -fno-strict-aliasing -DHAVE_SETRLIMIT -DHAVE_STRNLEN -Wno-unused -Wno-parentheses -DHAVE_MONOTONIC_CLOCK -I../../3rdparty/mt19937ar  -I/usr/include/mysql  -I../common -I/usr/include -c -o obj_sql/battle.o battle.c
    battle.c: In function âbattle_check_targetâ:
    battle.c:3412: error: âtsdâ undeclared (first use in this function)
    battle.c:3412: error: (Each undeclared identifier is reported only once
    battle.c:3412: error: for each function it appears in.)
    battle.c:3414: error: expected â)â before âstateâ
    battle.c:3422: error: expected expression before â}â token
    make[1]: *** [obj_sql/battle.o] Error 1
    make[1]: Leaving directory `/home/emulador/src/map'
    make: *** [map_sql] Error 2
    -bash-4.1# ^C
    -bash-4.1# 

    up.

  7. My server has the maximum 700 status, this script just put it up to 255. he wanted to fix.

     

     

     

     

     

     

    cydonia,116,81,4    script    Salva Bilds    871,{
    // == Configurações ==
    Set @Npc$,"[ Build Saver ]";    // Nome do Npc.
    SetArray @Price[0],1500,200;    // Preço, em Zenys, para utilizar o Npc. O primeiro número é para não Vips e o segundo para Vips.
    SetArray @MaxSaves[0],8,20;        // Número máximo de builds a serem salvas. O primeiro número é para não Vips e o segundo para Vips.
    Set @CanPrivate,1;                // Nível de GM mínimo para definir build pública/particular.
    Set @CanSave,0;                    // Nível de GM mínimo para salvar uma build.
    Set @ReqLevel,99;                // Nível de Classe requerido para utilizar o npc.
    Set @PopBuilds,10;                // Número de Build Populares para se mostrar.
    // ===================
    // == Funções ==
    function BuildSaver;
    // =============
    while(true)
    {
        Mes @Npc$;
        Mes "Olá "+StrCharInfo(0)+", posso salvar Builds de Stats"+(@Price[(GetGMLevel() ? 1 : 0)]? " por um quantia de "+@Price[(GetGMLevel() ? 1 : 0)]+"z ":"")+" para você!";
        if(Zeny < @Price[(GetGMLevel() ? 1 : 0)])
        {
            Mes "Infelizmente você não tem Zenys para me pagar...";
            close;
        }
        Mes "O que deseja?";
        next;
        switch(select("- Ver Builds Populares","- Ver Minhas Builds","- Salvar Build","- Sair"))
        {
            case 1:
                BuildSaver(0);
                break;
            case 2:
                BuildSaver(1);
                break;
            case 3:
                Mes @Npc$;
                if(GetGMLevel() < @CanSave)
                {
                    Mes "Desculpe-me, mas você não está autorizado para salvar Builds.";
                    next;
                    break;
                }
                query_sql "Select `build_name` From `build_saver` Where `char_id` = "+GetCharID(0),@BName$;
                if(GetArraySize(@BName$) >= @MaxSaves[(GetGMLevel() ? 1 : 0)])
                {
                    Mes "Você já salvou o número máximo possível de Builds, por favor apague uma Build se deseja salvar outra.";
                    next;
                    break;
                }
                if(BaseLevel < @ReqLevel)
                {
                    Mes "Desculpe-me, mas você precisa ser, no mínimo, nível "+@ReqLevel+" para poder salvar suas Builds";
                    next;
                    break;
                }
                Mes "Deseja mesmo salvar sua Build atual?";
                next;
                if(select("- Sim:- Não") == 2)
                    break;
                Mes @Npc$;
                Mes "Por favor, digite um nome para sua Build atual:";
                next;
                input @BuildName$,1;
                query_sql "Select `build_name` From `build_saver` Where `build_name` = '"+@BuildName$+"' And `char_id` = "+GetCharID(0),@BName$;
                Mes @Npc$;
                if(@BName$ != "")
                {
                    Mes "Você já possui um Build salva com este nome, deseja sobrescrevê-la?";
                    next;
                    if(select("- Sim:- Não") == 2)
                        break;
                    Mes @Npc$;
                }
                if(GetGMLevel() >= @CanPrivate)
                {
                    Mes "Deseja que esta Build seja Pública ou Privada?";
                    Mes "Se for Pública, qualquer um poderá vê-la e copiá-la, caso seja Particular apenas você a verá.";
                    next;
                    Set @Public,select("- Pública:- Privada:- Cancelar") - 1;
                    if(@Public == 2)
                        break;
                    Mes @Npc$;
                }
                Mes "Build Salva com sucesso!";
                Set Zeny, Zeny - @Price[(GetGMLevel() ? 1 : 0)];
                query_sql "Insert Into `build_saver` Values ("+GetCharID(0)+", '"+@BuildName$+"', "+@Public+",'"+StrCharInfo(0)+"', "+Class+", "+BaseLevel+", "+ReadParam(bStr)+", "+ReadParam(bAgi)+", "+ReadParam(bVit)+", "+ReadParam(bInt)+", "+ReadParam(bDex)+", "+ReadParam(bLuk)+",0)";
                next;
                break;
            case 4:
                Mes @Npc$;
                Mes "Até a próxima!";
                close;
        }
    }
    function    BuildSaver    {
        DeleteArray @BuildName$[0],GetArraySize(@BuildName$);
        DeleteArray @Name$[0],GetArraySize(@Name$);
        DeleteArray @Class[0],GetArraySize(@Class);
        DeleteArray @Lvl[0],GetArraySize(@Lvl);
        DeleteArray @Str[0],GetArraySize(@Str);
        DeleteArray @Agi[0],GetArraySize(@Agi);
        DeleteArray @Vit[0],GetArraySize(@Vit);
        DeleteArray @Int[0],GetArraySize(@Int);
        DeleteArray @Dex[0],GetArraySize(@Dex);
        DeleteArray @Luk[0],GetArraySize(@Luk);
        DeleteArray @Copied[0],GetArraySize(@Copied);
        query_sql "Select `build_name`, `name`, `class`, `lvl`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `copiedtimes` From `build_saver` "+(!GetArg(0,0)?"Where `public` = 0 Order By `copiedtimes` Desc Limit "+@PopBuilds:"Where `char_id` = "+GetCharID(0)),@BuildName$,@Name$,@Class,@Lvl,@Str,@Agi,@Vit,@Int,@Dex,@Luk,@Copied;
        for(Set @i,0; @i < GetArraySize(@BuildName$); Set @i,@i + 1)
        {
            Mes @Npc$;
            Mes "Build \""+@BuildName$[@i]+"\""+(!GetArg(0,0)?" por "+@Name$[@i]+", "+JobName(@Class[@i]):"")+", Lv."+@Lvl[@i];
            Mes "Str: "+@Str[@i];
            Mes "Agi: "+@Agi[@i];
            Mes "Vit: "+@Vit[@i];
            Mes "Int: "+@Int[@i];
            Mes "Dex: "+@Dex[@i];
            Mes "Luk: "+@Luk[@i];
            Mes "Build Copiada "+@Copied[@i]+" vezes.";
            next;
        }
        if(!GetArraySize(@BuildName$))
        {
            Mes @Npc$;
            Mes "Nenhuma Build encontrada.";
            next;
            return;
        }
        if(BaseLevel < @ReqLevel)
            return;
        Mes @Npc$;
        Mes "Deseja aplicar "+(GetArg(0,0)?"ou apagar":"")+" alguma build?";
        next;
        Set @sel1,select((!GetArg(0,0)?"- Sim:- Não":"- Aplicar:- Apagar:- Cancelar")) - 1;
        if(@sel1 == (!GetArg(0,0)? 1 : 2))
            return;
        Mes @Npc$;
        Mes "Qual Build deseja "+(!@sel1?"aplicar":"apagar")+"?";
        next;
        Set @menu$,"";
        for(Set @i,0; @i < GetArraySize(@BuildName$); Set @i,@i + 1)
            if(@menu$ == "") Set @menu$,"Build \""+@BuildName$[@i]+"\" por "+@Name$[@i]+", "+JobName(@Class[@i])+", Lv."+@Lvl[@i];
            else Set @menu$,@menu$+":Build \""+@BuildName$[@i]+"\" por "+@Name$[@i]+", "+JobName(@Class[@i])+", Lv."+@Lvl[@i];
        Set @menu$,@menu$+":Cancelar";
        Set @sel,select(@menu$)-1;
        if(@sel == GetArraySize(@BuildName$))
            return;
        Mes @Npc$;
        if(BaseLevel < @Lvl[@sel])
        {
            Mes "Seu nível é menor do que o da Build \""+@BuildName$[@sel]+"\", portanto você não pode aplicá-la.";
            next;
            return;
        }
        Mes "Deseja mesmo "+(!@sel1?"aplicar":"apagar")+" esta Build?";
        Mes "Build \""+@BuildName$[@sel]+"\""+(!GetArg(0,0)?" por "+@Name$[@i]+", "+JobName(@Class[@i]):"")+", Lv."+@Lvl[@sel];
        Mes "Str: "+@Str[@sel];
        Mes "Agi: "+@Agi[@sel];
        Mes "Vit: "+@Vit[@sel];
        Mes "Int: "+@Int[@sel];
        Mes "Dex: "+@Dex[@sel];
        Mes "Luk: "+@Luk[@sel];
        next;
        if(select("- Sim:- Não") == 2)
            return;
        Mes @Npc$;
        Mes "Build "+(!@sel1?"Aplicada":"Apagada")+"!";
        if(!@sel1)
        {
            if(!GetArg(0,0) && StrCharInfo(0) != @Name$[@sel])
                query_sql "Update `build_saver` Set `copiedtimes` = `copiedtimes` + 1 Where `build_name` = '"+@BuildName$[@sel]+"' And `name` = '"+@Name$[@sel]+"' And `class` = "+@Class[@sel];
            ResetStatus;
            while(ReadParam(bStr) < @Str[@sel] && StatusPoint)
                StatusUp bStr;
            while(ReadParam(bVit) < @Vit[@sel] && StatusPoint)
                StatusUp bVit;
            while(ReadParam(bAgi) < @Agi[@sel] && StatusPoint)
                StatusUp bAgi;
            while(ReadParam(bInt) < @Int[@sel] && StatusPoint)
                StatusUp bInt;
            while(ReadParam(bDex) < @Dex[@sel] && StatusPoint)
                StatusUp bDex;
            while(ReadParam(bLuk) < @Luk[@sel] && StatusPoint)
                StatusUp bLuk;
        }
        else
            query_sql "Delete From `build_saver` Where `build_name` = '"+@BuildName$[@sel]+"' And `char_id` = "+GetCharID(0);
        Set Zeny, Zeny - @Price[(GetGMLevel() ? 1 : 0)];
        next;
        return;
    }
    OnInit:
        query_sql "Create Table If Not Exists `build_saver` ( `char_id` int(11) unsigned NOT NULL, `build_name` varchar(255) NOT NULL, `public` tinyint(1) unsigned NOT NULL, `name` varchar(255) NOT NULL, `class` mediumint(4) unsigned NOT NULL, `lvl` mediumint(4) unsigned NOT NULL, `str` tinyint(3) unsigned NOT NULL, `agi` tinyint(3) unsigned NOT NULL, `vit` tinyint(3) unsigned NOT NULL, `int` tinyint(3) unsigned NOT NULL, `dex` tinyint(3) unsigned NOT NULL, `luk` tinyint(3) unsigned NOT NULL, `copiedtimes` int(11) unsigned NOT NULL, Primary Key (`char_id`) )";
    end;
    }
  8. I have this script that makes automacamente awards to all members of the winning guild, the script works more WoE wednesday Castle prtg_cas01 not be doing the awards.

     

    -    script    guild_reward_send    -1,{
    OnAgitEnd:
        switch ( gettime(4) ) {
            case 0: set .@gid, getcastledata("prtg_cas03",1); break;
            case 2: set .@gid, getcastledata("prtg_cas01",1); break;
            case 4: set .@gid, getcastledata("prtg_cas02",1); break;
            default: end;
        }
        set .@nb, query_sql( "select account_id from `char` where guild_id = "+ .@gid +" and online = 1", .@aid );
        for ( set .@i, 0; .@i < .@nb; set .@i, .@i +1 ) {
            attachrid .@aid[.@i];
            getitem 7539,15;
            announce "[Premiação]: Premiação entregue a guild vencedora",0;
            dispbottom "Você recebeu 15 Moedas Poring pela sua vitória na Guerra do Emperium.";
        }
        end;
    }
  9. Is showing these errors in my console wanted to know how to solve.

    [Erro]:
    script error on autobonus line 0
        unexpected end of script
         0 : { specialeffect2 EF_GUARD;
    [Erro]:
    script error on autobonus line 0
        unexpected end of script
         0 : { bonus bShortWeaponDamageReturn,(getrefine()*3);
    [Erro]:
    script error on autobonus line 0
        unexpected end of script
         0 : { specialeffect2 EF_GUARD;
    [Erro]:
    script error on autobonus line 0
        unexpected end of script
         0 : { bonus bShortWeaponDamageReturn,(getrefine()*3);
    [Erro]:
    script error on autobonus line 0
        unexpected end of script
         0 : { specialeffect2 EF_GUARD;
    [Info]: Saved guild (204 - Editados): members
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Debug]: mapindex_id2name: Requested name for non-existant map index [0] in cache.
    [Erro]: buildin_rid2name: invalid RID
  10. still give error

    ../common/obj_all/core.o: In function `main':
    /home/emulador/src/common/core.c:259: undefined reference to `harmony_core_init'
    /home/emulador/src/common/core.c:273: undefined reference to `harmony_core_final'
    ../common/obj_all/socket.o: In function `delete_session':
    /home/emulador/src/common/socket.c:565: undefined reference to `harm_funcs'
    ../common/obj_all/socket.o: In function `WFIFOSET':
    /home/emulador/src/common/socket.c:676: undefined reference to `harm_funcs'
    ../common/obj_all/socket.o: In function `recv_to_fifo':
    /home/emulador/src/common/socket.c:330: undefined reference to `harm_funcs'
    ../common/obj_all/socket.o: In function `connect_client':
    /home/emulador/src/common/socket.c:431: undefined reference to `harm_funcs'
    collect2: ld returned 1 exit status
    make[1]: *** [map-server_sql] Error 1
    make[1]: Leaving directory `/home/emulador/src/map'
    make: *** [map_sql] Error 2
    -bash-4.1# make sql
  11. I was trying to install Harmony gave the following errors at compile time.

     

    ../common/obj_all/core.o: In function `main':
    /home/emulador/src/common/core.c:259: undefined reference to `harmony_core_init'
    /home/emulador/src/common/core.c:273: undefined reference to `harmony_core_final'
    ../common/obj_all/socket.o: In function `delete_session':
    /home/emulador/src/common/socket.c:565: undefined reference to `harm_funcs'
    ../common/obj_all/socket.o: In function `WFIFOSET':
    /home/emulador/src/common/socket.c:676: undefined reference to `harm_funcs'
    ../common/obj_all/socket.o: In function `recv_to_fifo':
    /home/emulador/src/common/socket.c:330: undefined reference to `harm_funcs'
    ../common/obj_all/socket.o: In function `connect_client':
    /home/emulador/src/common/socket.c:431: undefined reference to `harm_funcs'
    collect2: ld returned 1 exit status
    make[1]: ** [map-server_sql] Erro 1
    make[1]: Saindo do diretório `/home/emulador/src/map'
    make: ** [map_sql] Erro 2
    -bash-4.1#
  12. I will try to correct the correct part @ prace_playing to see if the end of the event the npc sends the prize, 
     
    Yes, the race takes place and ends normally, the only problem is that the npc does the prize at the end.

     

    Good *-* Now the race seems to be 100%, be sending the prize at the end of the race.. Trx.. =)

     

     

     

    fix

    //NPC Checker
    -    script    Checker#prace0    -1,{
    end;
    
    OnChequeo:
        for(set .@tmp1,0;.@tmp1<(getarraysize($prace_bidders));set .@tmp1,.@tmp1+1) {
            if(attachrid($prace_bidders[.@tmp1])) {
                if( @prace_playing != 1) end;
                dispbottom "The winner is "+$prace_winner$+" and you have bet for "+prace_winner$+".";
                if( prace_winner$ == $prace_winner$ && prace_winner$ != "") {  
                    dispbottom "You have won!";
                    mapannounce "cydonia"," Congratulations! "+strcharinfo(0)+" has won!",1,0xFFAB54;
                    getitem 7199,2;
                    emotion 21,1;
                } else
                    dispbottom "You have lost."; emotion 28,1;
                set prace_winner$,"";
                set @prace_playing,0;
            } //else { announce .@tmp1+" || "+$prace_bidders[.@tmp1],bc_all; }  //debug
        }
        for( set .@tmp1,0; .@tmp1 < (getarraysize( $prace_bidders )); set .@tmp1,.@tmp1 + 1 ) {
            set $prace_bidders[.@tmp1],0;
        }
    }
    
    -    script    Timers#prace0    -1,{
    
        OnClock0000: callsub OnCalll;
        OnClock0200: callsub OnCalll;
        OnClock0400: callsub OnCalll;
        OnClock0600: callsub OnCalll;
        OnClock0816: callsub OnCalll;
        OnClock1023: callsub OnCalll;
        OnClock1200: callsub OnCalll;
        OnClock1400: callsub OnCalll;
        OnClock1600: callsub OnCalll;
        OnClock1800: callsub OnCalll;
        OnClock2000: callsub OnCalll;
        OnClock2200: callsub OnCalll;
    
        OnCalll:
            set $prace_gate,1;
            announce "A 'Corrida dos Porings' irá começar em breve, façam suas apostas!",bc_all|bc_yellow;
            end;
    }
    //====== Principal: ============================================
    cydonia,100,59,3    script    Bidder#prace0    765,{
    
        set .@prace_zeny,20000000;    // Preço para apostar. [Padrão: 20000000]
    
        if ($prace_random < 1) callsub OnInit;
        if (@prace_playing==1) callsub AlreadyPlaying;
    
        if($prace_gate == 0){ mes "[Bidder]"; mes "Uma corrida está em andamento..."; close; }
    
        getmapxy(.@mapname$,.@x1,.@y,1,"Poring#prace1");
        getmapxy(.@mapname$,.@x2,.@y,1,"Angeling#prace2");
        getmapxy(.@mapname$,.@x3,.@y,1,"Metaling#prace3");
        getmapxy(.@mapname$,.@x4,.@y,1,"Deviling#prace4");
        getmapxy(.@mapname$,.@x5,.@y,1,"Poring Noel#prace5");
        if (.@x1 != 103 || .@x2 != 106 || .@x3 != 109 || .@x4 != 112 || .@x5 != 115){
        mes "[Bidder]"; mes "Uma corrida está em andamento..."; close;
        }
        mes "[Bidder]"; mes "Escolha o poring em que deseja apostar:";mes "Irá custar "+.@prace_zeny+" Zeny.";next;
        switch(select("Poring","Angeling","Metaling","Deviling","Poring Noel","Poporing")){
        case 1: callfunc "OnBid","Poring";
        case 2: callfunc "OnBid","Angeling";
        case 3: callfunc "OnBid","Metaling";
        case 4: callfunc "OnBid","Deviling";
        case 5: callfunc "OnBid","Poring Noel";
        }
    
        OnReady:
            set $prace_bets,$prace_bets+1;
             set $prace_bidders[$prace_bets],getcharid(3);
            set @prace_playing,1;
             mes "[Bidder]";
             mes "Eu tenho "+$prace_bets+" apostas.";
             setnpctimer 60000; startnpctimer;
             npctalk strcharinfo(0)+" fez sua aposta!";
             close;
    
        Start1: setnpctimer 0; startnpctimer; end;
        AlreadyPlaying: mes "[Bidder]"; mes "Você apostou em ^00bb00"+prace_winner$+"^000000."; close;
        
        StartRace:
            donpcevent "Metaling#prace3::OnRace";
            donpcevent "Poring#prace1::OnRace";
            donpcevent "Angeling#prace2::OnRace";
            donpcevent "Poring Noel#prace5::OnRace";
            donpcevent "Deviling#prace4::OnRace";
            end;
    
        OnStopRace:
            donpcevent "Poring#prace1::OnStop";
            donpcevent "Angeling#prace2::OnStop";
            donpcevent "Metaling#prace3::OnStop";
            donpcevent "Deviling#prace4::OnStop";
            donpcevent "Poring Noel#prace5::OnStop";
            if ($prace_winner$!="") callsub WinRace;
            end;
    
        ReturnRace:
            donpcevent "Poring#prace1::OnReturn";
            donpcevent "Angeling#prace2::OnReturn";
            donpcevent "Metaling#prace3::OnReturn";
            donpcevent "Deviling#prace4::OnReturn";
            donpcevent "Poring Noel#prace5::OnReturn";
            end;
    
        WinRace:
            set $prace_gate,0;
            mapannounce "cydonia","O vencedor é o "+$prace_winner$+".",1,0xFFAB54;
            donpcevent "Checker#prace0::OnChequeo";
            setnpctimer 30000;startnpctimer;
            end;
    
        OnInit:
            set $prace_random,70;
            set $prace_random2,600;
            set $prace_winner$,"";
            set $prace_bets,0;
            set $prace_bidders,0;
            end;
     
        OnTimer500: mapannounce "cydonia","Porings, em suas marcas...",1,0xFFAB54; end;    
        OnTimer3000: mapannounce "cydonia","...3...",1,0xFFAB54; end;    
        OnTimer4000: mapannounce "cydonia","...2...",1,0xFFAB54; end;    
        OnTimer5000: mapannounce "cydonia","...1...",1,0xFFAB54; callsub StartRace; end;
        OnTimer6000: stopnpctimer; mapannounce "cydonia","Gooo!!!",1,0xFFAB54; end;
        OnTimer35000: set $prace_winner$,""; set $prace_bets,0; stopnpctimer; callsub ReturnRace;
        OnTimer90000: npctalk "Eu tenho "+$prace_bets+" aposta(s). Alguém mais?"; end;
        OnTimer110000: npctalk "A corrida irá começar em breve. Última chance."; end;
        OnTimer120000: callsub Start1;
    }
    
    //====== Função Apostar: =======================================
    function    script    OnBid    {
    
        getmapxy(.@mapname$,.@x1,.@y,1,"Poring#prace1");
        getmapxy(.@mapname$,.@x2,.@y,1,"Angeling#prace2");
        getmapxy(.@mapname$,.@x3,.@y,1,"Metaling#prace3");
        getmapxy(.@mapname$,.@x4,.@y,1,"Deviling#prace4");
        getmapxy(.@mapname$,.@x5,.@y,1,"Poring Noel#prace5");
        if (.@x1 == 103 || .@x2 == 106 || .@x3 == 109 || .@x4 == 112 || .@x5 == 115){
        if (Zeny < .@prace_zeny) { callsub OnZeny; } else { set Zeny,Zeny-.@prace_zeny; }
         set prace_winner$,getarg(0); callsub OnReady;
        }
        mes "[Bidder]"; mes "Uma corrida está em andamento..."; close;
    
        OnZeny: set prace_winner$,""; mes "[Bidder]"; mes "Você não tem Zeny suficiente."; close;
    
        OnReady: set $prace_bets,$prace_bets+1; set $prace_bidders[$prace_bets],getcharid(3);
            set @prace_playing,1; mes "[Bidder]"; mes "Eu tenho "+$prace_bets+" apostas.";
             setnpctimer 60000; startnpctimer; npctalk strcharinfo(0)+" fez sua aposta!"; close;
    }
    //====== Monstros: ==============================================
    cydonia,103,54,4    script    Poring#prace1    1002,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 103,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Poring#prace1");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Poring"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,106,54,4    script    Angeling#prace2    1096,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 106,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Angeling#prace2");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Angeling"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,109,54,4    script    Metaling#prace3    1613,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 109,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Metaling#prace3");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Metaling"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,112,54,4    script    Deviling#prace4    1582,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 112,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Deviling#prace4");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Deviling"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,115,54,4    script    Poring Noel#prace5    1062,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 115,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Poring Noel#prace5");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Poring Noel"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
  13. is that I used your example to see if it worked. before it was so

     

    cydonia,99,44,0    script    Checker#prace0    -1,{
    end;
    
    OnChequeo:
        set .@prace_prize, 17006;        // ID do prêmio para quem vencer.[Padrão: ????]
        set .@prace_prize_quantity, 1; // Quantidade do prêmio.         [Padrão: 1]
    
        set $prace_gate,0;
        for(set .@i,0; .@i < (getarraysize($prace_bidders)); set .@i, .@i + 1){
        if(attachrid($prace_bidders[.@i])){
        if (@prace_playing!=1) end;
        set @z, rand(150000,400000);
        dispbottom "O vencedor é o "+$prace_winner$+" e você apostou em "+@prace_winner$+".";
        if (@prace_winner$==$prace_winner$ && @prace_winner$!=""){  
               dispbottom "Você venceu! Prêmio: 1 "+getitemname(@id); mapannounce "cydonia"," Parabéns! "+strcharinfo(0)+" venceu!",1,0xFFAB54;
               getitem .@prace_prize,1; emotion 21,1; warp "prontera",150,170;
           } else { dispbottom "Você perdeu."; emotion 28,1; warp "prontera",150,170; }
               set @prace_winner$,"";set @prace_playing,0;
          } //else { announce .@i+" || "+$prace_bidders[.@i],bc_all; }  //debug
    }     
        for(set .@i,0; .@i < (getarraysize($prace_bidders)); set .@i, .@i + 1) set $prace_bidders[.@i],0;
    }
  14. the race is nearly 100%, she is starting and ending normally, just do not be giving the prize to the player,

     

     

     

    //NPC Checker
    -    script    Checker#prace0    -1,{
    end;
    
    OnChequeo:
        for(set .@tmp1,0;.@tmp1<(getarraysize($prace_bidders));set .@tmp1,.@tmp1+1) {
            if(attachrid($prace_bidders[.@tmp1])) {
                if( prace_playing != 1) end;
                dispbottom "The winner is "+$prace_winner$+" and you have bet for "+prace_winner$+".";
                if( prace_winner$ == $prace_winner$ && prace_winner$ != "") {  
                    dispbottom "You have won!";
                    mapannounce "cydonia"," Congratulations! "+strcharinfo(0)+" has won!",1,0xFFAB54;
                    getitem 7199,2;
                    emotion 21,1;
                } else
                    dispbottom "You have lost."; emotion 28,1;
                set prace_winner$,"";
                set prace_playing,0;
            } //else { announce .@tmp1+" || "+$prace_bidders[.@tmp1],bc_all; }  //debug
        }
        for( set .@tmp1,0; .@tmp1 < (getarraysize( $prace_bidders )); set .@tmp1,.@tmp1 + 1 ) {
            set $prace_bidders[.@tmp1],0;
        }
    }
    
    -    script    Timers#prace0    -1,{
    
        OnClock0000: callsub OnCalll;
        OnClock0200: callsub OnCalll;
        OnClock0400: callsub OnCalll;
        OnClock0600: callsub OnCalll;
        OnClock0816: callsub OnCalll;
        OnClock1023: callsub OnCalll;
        OnClock1200: callsub OnCalll;
        OnClock1400: callsub OnCalll;
        OnClock1600: callsub OnCalll;
        OnClock1800: callsub OnCalll;
        OnClock2000: callsub OnCalll;
        OnClock2200: callsub OnCalll;
    
        OnCalll:
            set $prace_gate,1;
            announce "A 'Corrida dos Porings' irá começar em breve, façam suas apostas!",bc_all|bc_yellow;
            end;
    }
    //====== Principal: ============================================
    cydonia,100,59,3    script    Bidder#prace0    765,{
    
        set .@prace_zeny,20000000;    // Preço para apostar. [Padrão: 20000000]
    
        if ($prace_random < 1) callsub OnInit;
        if (@prace_playing==1) callsub AlreadyPlaying;
    
        if($prace_gate == 0){ mes "[Bidder]"; mes "Uma corrida está em andamento..."; close; }
    
        getmapxy(.@mapname$,.@x1,.@y,1,"Poring#prace1");
        getmapxy(.@mapname$,.@x2,.@y,1,"Angeling#prace2");
        getmapxy(.@mapname$,.@x3,.@y,1,"Metaling#prace3");
        getmapxy(.@mapname$,.@x4,.@y,1,"Deviling#prace4");
        getmapxy(.@mapname$,.@x5,.@y,1,"Poring Noel#prace5");
        if (.@x1 != 103 || .@x2 != 106 || .@x3 != 109 || .@x4 != 112 || .@x5 != 115){
        mes "[Bidder]"; mes "Uma corrida está em andamento..."; close;
        }
        mes "[Bidder]"; mes "Escolha o poring em que deseja apostar:";mes "Irá custar "+.@prace_zeny+" Zeny.";next;
        switch(select("Poring","Angeling","Metaling","Deviling","Poring Noel","Poporing")){
        case 1: callfunc "OnBid","Poring";
        case 2: callfunc "OnBid","Angeling";
        case 3: callfunc "OnBid","Metaling";
        case 4: callfunc "OnBid","Deviling";
        case 5: callfunc "OnBid","Poring Noel";
        }
    
        OnReady:
            set $prace_bets,$prace_bets+1;
             set $prace_bidders[$prace_bets],getcharid(3);
            set @prace_playing,1;
             mes "[Bidder]";
             mes "Eu tenho "+$prace_bets+" apostas.";
             setnpctimer 60000; startnpctimer;
             npctalk strcharinfo(0)+" fez sua aposta!";
             close;
    
        Start1: setnpctimer 0; startnpctimer; end;
        AlreadyPlaying: mes "[Bidder]"; mes "Você apostou em ^00bb00"+@prace_winner$+"^000000."; close;
        
        StartRace:
            donpcevent "Metaling#prace3::OnRace";
            donpcevent "Poring#prace1::OnRace";
            donpcevent "Angeling#prace2::OnRace";
            donpcevent "Poring Noel#prace5::OnRace";
            donpcevent "Deviling#prace4::OnRace";
            end;
    
        OnStopRace:
            donpcevent "Poring#prace1::OnStop";
            donpcevent "Angeling#prace2::OnStop";
            donpcevent "Metaling#prace3::OnStop";
            donpcevent "Deviling#prace4::OnStop";
            donpcevent "Poring Noel#prace5::OnStop";
            if ($prace_winner$!="") callsub WinRace;
            end;
    
        ReturnRace:
            donpcevent "Poring#prace1::OnReturn";
            donpcevent "Angeling#prace2::OnReturn";
            donpcevent "Metaling#prace3::OnReturn";
            donpcevent "Deviling#prace4::OnReturn";
            donpcevent "Poring Noel#prace5::OnReturn";
            end;
    
        WinRace:
            set $prace_gate,0;
            mapannounce "cydonia","O vencedor é o "+$prace_winner$+".",1,0xFFAB54;
            donpcevent "Checker#prace0::OnChequeo";
            setnpctimer 30000;startnpctimer;
            end;
    
        OnInit:
            set $prace_random,70;
            set $prace_random2,600;
            set $prace_winner$,"";
            set $prace_bets,0;
            set $prace_bidders,0;
            end;
     
        OnTimer500: mapannounce "cydonia","Porings, em suas marcas...",1,0xFFAB54; end;    
        OnTimer3000: mapannounce "cydonia","...3...",1,0xFFAB54; end;    
        OnTimer4000: mapannounce "cydonia","...2...",1,0xFFAB54; end;    
        OnTimer5000: mapannounce "cydonia","...1...",1,0xFFAB54; callsub StartRace; end;
        OnTimer6000: stopnpctimer; mapannounce "cydonia","Gooo!!!",1,0xFFAB54; end;
        OnTimer35000: set $prace_winner$,""; set $prace_bets,0; stopnpctimer; callsub ReturnRace;
        OnTimer90000: npctalk "Eu tenho "+$prace_bets+" aposta(s). Alguém mais?"; end;
        OnTimer110000: npctalk "A corrida irá começar em breve. Última chance."; end;
        OnTimer120000: callsub Start1;
    }
    
    //====== Função Apostar: =======================================
    function    script    OnBid    {
    
        getmapxy(.@mapname$,.@x1,.@y,1,"Poring#prace1");
        getmapxy(.@mapname$,.@x2,.@y,1,"Angeling#prace2");
        getmapxy(.@mapname$,.@x3,.@y,1,"Metaling#prace3");
        getmapxy(.@mapname$,.@x4,.@y,1,"Deviling#prace4");
        getmapxy(.@mapname$,.@x5,.@y,1,"Poring Noel#prace5");
        if (.@x1 == 103 || .@x2 == 106 || .@x3 == 109 || .@x4 == 112 || .@x5 == 115){
        if (Zeny < .@prace_zeny) { callsub OnZeny; } else { set Zeny,Zeny-.@prace_zeny; }
         set @prace_winner$,getarg(0); callsub OnReady;
        }
        mes "[Bidder]"; mes "Uma corrida está em andamento..."; close;
    
        OnZeny: set @prace_winner$,""; mes "[Bidder]"; mes "Você não tem Zeny suficiente."; close;
    
        OnReady: set $prace_bets,$prace_bets+1; set $prace_bidders[$prace_bets],getcharid(3);
            set @prace_playing,1; mes "[Bidder]"; mes "Eu tenho "+$prace_bets+" apostas.";
             setnpctimer 60000; startnpctimer; npctalk strcharinfo(0)+" fez sua aposta!"; close;
    }
    //====== Monstros: ==============================================
    cydonia,103,54,4    script    Poring#prace1    1002,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 103,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Poring#prace1");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Poring"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,106,54,4    script    Angeling#prace2    1096,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 106,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Angeling#prace2");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Angeling"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,109,54,4    script    Metaling#prace3    1613,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 109,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Metaling#prace3");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Metaling"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,112,54,4    script    Deviling#prace4    1582,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 112,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Deviling#prace4");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Deviling"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
    cydonia,115,54,4    script    Poring Noel#prace5    1062,{
    end;
        OnRace: initnpctimer; startnpctimer; end;
        OnStop: stopnpctimer; end;
        OnReturn: npcwalkto 115,54; end;
        OnTimer1100:
            getmapxy(.@mapname$,.@x,.@y,1,"Poring Noel#prace5");
            if(rand(100) < $prace_random) npcwalkto .@x,.@y-1;
             setnpctimer rand($prace_random2); startnpctimer;
             if ((.@y-1) == 31) { set $prace_winner$,"Poring Noel"; emotion 29; donpcevent "Bidder#prace0::OnStopRace"; }
    }
×
×
  • Create New...