viewing paste #itemmall | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
//===== eAthena Script ============================================
//= #itemall
//===== By: =======================================================
//= Originally by goddameit
//= redo by ~AnnieRuru~
//===== Current Version: ==========================================
//= 1.0
//===== Compatible With: ==========================================
//= eAthena 14910 Trunk TXT/SQL
//===== Description: ==============================================
//= give items to all players in the map, or on the server
//===== Topic =====================================================
//= http://www.eathena.ws/board/index.php?showtopic=276326
//===== Additional Comments: ======================================
//= topic splitted
//=================================================================
 
-   script  itemall -1,{
OnWhisperGlobal:
    if ( getgmlevel() < 80 ) end; // configure minimum GM level here
    if ( compare( @whispervar0$, "map" ) )
        set .@map$, strcharinfo(3);
    else if ( compare( @whispervar0$, "all" ) == 0 ) {
        dispbottom "[itemall] Please enter \"map#<item id>#<item amount>\" or \"all#<item id>#<item amount>\"";
        end;
    }
    set .@itemid, atoi( @whispervar1$ );
    set .@amount, atoi( @whispervar2$ );
    if ( getiteminfo( .@itemid, 0 ) == -1 ) {
        dispbottom "[itemall] Invalid item ID";
        end;
    }
    if ( .@amount == 0 )
        set .@amount, 1;
    set .@origin$, strcharinfo(0);
    while ( .@i < $online_count ) {
        attachrid getd("$online_aid"+ .@i );
        if ( .@map$ == "" || strcharinfo(3) == .@map$ ) {
            message strcharinfo(0), .@origin$ +" gives you "+ .@amount +" "+ getitemname(.@itemid);
            getitem .@itemid, .@amount;
        }
        set .@i, .@i +1;
    }
    end;
 
OnPCLoginEvent:
    setd "$online_aid"+ $online_count, getcharid(3);
    set $online_count, $online_count +1;
    end;
OnPCLogoutEvent:
    while ( .@i < $online_count && getd("$online_aid"+ .@i ) != getcharid(3) )
        set .@i, .@i +1;
    if ( $online_count == .@i ) end; // prevent @loadnpc/@reloadscript bug becos not in the array
    while ( .@i < $online_count ) {
        setd "$online_aid"+ .@i, getd("$online_aid"+ ( .@i +1 ) );
        set .@i, .@i +1;
    }
    set $online_count, $online_count -1;
    end;
OnInit:
    if ( getusers(1) ) end;
    while ( .@i < $online_count ) {
        setd "$online_aid"+ .@i, 0;
        set .@i, .@i +1;
    }
    set $online_count, 0;
    end;
}
Viewed 842 times, submitted by Guest.