summaryrefslogblamecommitdiff
path: root/npc/functions/timer.txt
blob: 27e09f13ed3728f288fded71d0e334bf7b37c4d6 (plain) (tree)
























































































                                                                                                   
// Evol Script
// Authors: Gumi, Jesusalva

// areatimer("<map>", <x1>, <y1>, <x2>, <y2>, <tick>, "<npc>::<event>")
function	script	areatimer	{
    // Legacy
    if (getargcount() > 7)
        .@ox=1;
    // Variables
    .@m$=getarg(.@ox); .@ox+=1;
    .@x1=getarg(.@ox); .@ox+=1;
    .@y1=getarg(.@ox); .@ox+=1;
    .@x2=getarg(.@ox); .@ox+=1;
    .@y2=getarg(.@ox); .@ox+=1;
    .@tk=getarg(.@ox); .@ox+=1;
    .@e$=getarg(.@ox); .@ox+=1;
    .@c = getunits(BL_PC, .@players, false, .@m$, .@x1, .@y1, .@x2, .@y2);
    for (.@i = 0; .@i < .@c; .@i++) {
        addtimer(.@tk, .@e$, .@players[.@i]);
    }
    return .@i;
}

// areadeltimer("<map>", <x1>, <y1>, <x2>, <y2>, "<npc>::<event>")
function	script	areadeltimer	{
    .@c = getunits(BL_PC, .@players, false, getarg(0), getarg(1), getarg(2), getarg(3), getarg(4));
    for (.@i = 0; .@i < .@c; .@i++) {
        deltimer(getarg(5), .@players[.@i]);
    }
    return .@i;
}

// areatimer2("<map>", <x1>, <y1>, <x2>, <y2>, <tick>, "<npc>::<event>")
function	script	areatimer2	{
    .@c = getunits(BL_PC, .@players, false, getarg(0), getarg(1), getarg(2), getarg(3), getarg(4));
    for (.@i = 0; .@i < .@c; .@i++) {
        deltimer(getarg(6), .@players[.@i]);
        addtimer(getarg(5), getarg(6), .@players[.@i]);
    }
    return .@i;
}

// addtimer2(<tick>, "<npc>::<event>")
function	script	addtimer2	{
    deltimer(getarg(1));
    addtimer(getarg(0), getarg(1));
    return;
}


// maptimer("<map>", <tick>, "<npc>::<event>")
function	script	maptimer	{
    .@c = getunits(BL_PC, .@players, false, getarg(0));
    for (.@i = 0; .@i < .@c; .@i++) {
        addtimer(getarg(1), getarg(2), .@players[.@i]);
    }
    return .@i;
}

// Same as maptimer() but deletes any previously running timer
// maptimer2("<map>", <tick>, "<npc>::<event>")
function	script	maptimer2	{
    .@c = getunits(BL_PC, .@players, false, getarg(0));
    for (.@i = 0; .@i < .@c; .@i++) {
        deltimer(getarg(2), .@players[.@i]);
        addtimer(getarg(1), getarg(2), .@players[.@i]);
    }
    return .@i;
}

// mapdeltimer("<map>", "<npc>::<event>")
function	script	mapdeltimer	{
    .@c = getunits(BL_PC, .@players, false, getarg(0));
    for (.@i = 0; .@i < .@c; .@i++) {
        deltimer(getarg(1), .@players[.@i]);
    }
    return .@i;
}

// partytimer("<map>", <tick>, "<npc>::<event>", partyid)
function	script	partytimer	{
    .@c = getunits(BL_PC, .@players, false, getarg(0));
    for (.@i = 0; .@i < .@c; .@i++) {
        if (getcharid(2, strcharinfo(0,"",.@players[.@i]) ) == getarg(3))
            addtimer(getarg(1), getarg(2), .@players[.@i]);
    }
    return .@i;
}