Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

bank ammo packów


  • Zamknięty Temat jest zamknięty
Brak odpowiedzi do tego tematu

#1 Seele ^

    Nowy

  • Użytkownik

Reputacja: 0
zer0.

  • Postów:2
  • Lokalizacja:zza pieca
Offline

Napisano 02.11.2009 19:46

Dałby ktoś rade przerobić ten plugin tak, żeby bank ammo packów działał tylko dla określonej flagi w users.ini ?


Gdyby ktoś dał rade, proszę również o zaznaczenie odpowiedniego wersu w kodzie


// ZP Bank - allows saving of ammo packs
/*    cvars

zp_bank 1                //<0/1> set whether plugin enabled or not
zp_bank_limit 1000000    //maximium storage capacity of each person's account
zp_bank_blockstart 1    //<0/1> set whether bank blocks zombie plague from giving the initial 5 ammo packs on start if user has an account

*/

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fakemeta>
#include <zombieplague>

static const version[] = "0.3";
static const plugin[] = "ZP Bank";

enum pcvar
{
    enable = 0,
    cap,
    start
}
new pcvars[pcvar];
new bankstorage[33];

new gvault, thinkobj;

public plugin_init()
{
    register_plugin(plugin, version, "Random1");
    
    gvault = nvault_open("Zombie Bank");
    
    pcvars[enable] =            register_cvar("zp_bank", "1");
    pcvars[cap] =                register_cvar("zp_bank_limit", "1000000");
    pcvars[start] =                register_cvar("zp_bank_blockstart", "1");
    
    if ( get_pcvar_num(pcvars[cap]) > 2147483646 )
    {
        set_pcvar_num(pcvars[cap], 2147483646);
        server_print("[%s] Due to a 32 bit restriction in perl zp_ammo_limit reset based on restriction", plugin);
    }
    
    register_clcmd("say", "handle_say");
    register_clcmd("say_team", "handle_say");
    
    thinkobj = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
    if ( pev_valid(thinkobj) )
    {
        set_pev(thinkobj, pev_classname, "advertisement_loop");
        set_pev(thinkobj, pev_nextthink, get_gametime() + 240.0);
        register_forward(FM_Think, "fourmin_think");
    }
}
public fourmin_think(ent)
{
    if ( ent != thinkobj ) return FMRES_IGNORED;
    
    if ( !get_pcvar_num(pcvars[enable]) ) return FMRES_IGNORED;
    
    client_print(0, print_chat, "[%s]Enabled. %d is the storage limit", plugin, get_pcvar_num(pcvars[cap]));
    client_print(0, print_chat, "[%s] Currently Ammo packs are savable by typing ^"deposit <amount>^".", plugin);
    client_print(0, print_chat, "[%s] To retrieve your ammo packs type ^"withdraw <amount>^"", plugin);
    
    set_pev(ent, pev_nextthink, get_gametime() + 240.0);
    
    return FMRES_HANDLED;    
}
public plugin_end()
    nvault_close(gvault);
    
public handle_say(id)
{
    if ( !get_pcvar_num(pcvars[enable]) ) return PLUGIN_CONTINUE;
    
    new text[70], arg1[32], arg2[32], arg3[6];
    read_args(text, sizeof(text)-1);
    remove_quotes(text);
    arg1[0] = '^0';
    arg2[0] = '^0';
    arg3[0] = '^0';
    parse(text, arg1, sizeof(arg1)-1, arg2, sizeof(arg2)-1, arg3, sizeof(arg3)-1);
    //dbg_log("cmd_say() arg1:#%s# arg2:#%s# arg3:#%s#", arg1, arg2, arg3);

    // if the chat line has more than 2 words, we're not interested at all
    if (arg3[0] == 0)
    {
        //strip forward slash if present
        if ( equali(arg1, "/", 1) ) format(arg1, 31, arg1[1]);
        
        if ( equali(arg1, "deposit", 7) || equali(arg1, "send", 4) || equali(arg1, "store", 5) )
        {
            if ( isdigit(arg2[0]) || (arg2[0] == '-' && isdigit(arg2[1])) )
            {
                new value = str_to_num(arg2);
                store_cash(id, value);
                return PLUGIN_HANDLED;
            }
            else if ( equali(arg2, "all") )
            {
                store_cash(id, -1);
                return PLUGIN_HANDLED;
            }                
            else if ( arg2[0] == 0 )
                client_print(id, print_chat, "[%s] to deposit ammo packs in bank say deposit <amount to deposit>", plugin);
            
            return PLUGIN_CONTINUE;
        }
        else if ( equali(arg1, "withdraw", 8) || equali(arg1, "take", 4) || equali(arg1, "retrieve", 8) )
        {
            if ( isdigit(arg2[0]) || (arg2[0] == '-' && isdigit(arg2[1])) )
            {
                new value = str_to_num(arg2);
                take_cash(id, value);
                return PLUGIN_HANDLED;
            }
            else if ( equali(arg2, "all") )
            {
                take_cash(id, -1);
                return PLUGIN_HANDLED;
            }
            else if ( arg2[0] == 0 )
                client_print(id, print_chat, "[%s] to withdraw ammo packs from bank say withdraw <amount to withdraw>", plugin);
            
            return PLUGIN_CONTINUE;
        }
        else if ( equali(arg1, "mybank", 6) || equali(arg1, "account", 7) || equali(arg1, "bank", 4) )
        {
            if ( arg2[0] == 0 ) {
                client_print(id, print_chat, "[%s] Currently your account has %d ammo packs in it",plugin, bankstorage[id]);
                return PLUGIN_HANDLED;
            }
            else {
                new player = cmd_target(id,arg2,2);
                if ( !player ) return PLUGIN_CONTINUE;
                client_print(id, print_chat, "[%s] %s has %d ammo packs", plugin, arg2, bankstorage[player]);
                return PLUGIN_HANDLED;
            }
        }
    }
    else if ( equali( arg1, "donate", 6 ) )
    {
        give_cmd(id, arg2, arg3);
        return PLUGIN_HANDLED;
    }
    return PLUGIN_CONTINUE;
}
give_cmd(id, target[], amnt[])
{
    new temp = str_to_num(amnt);
    if ( temp < 0 )
    {
        client_print(id, print_chat, "[%s] The ^"amount^" argument passed is negative, either overflowed or your trying to cheat", plugin );
        return;
    }
    new player = cmd_target(id, target, 8);
    if ( !player ) return;
    
    new temp2 = bankstorage[id] + zp_get_user_ammo_packs(id);
    if ( temp > temp2 )
    {
        client_print(id, print_chat, "[%s] You don't have enough ammo packs to donate, you only have %d out of %d specified",plugin,
            temp2, temp);
        
        return;
    }
    static playername[32], givename[32];
    get_user_name(player, playername, 31);
    get_user_name(id, givename, 31);
    client_print(id, print_chat, "[%s] You just donated %d ammo packs to %s", plugin, temp, playername);
    client_print(player, print_chat, "[%s] %s just donated %d ammo packs to you", plugin, givename, temp);
    bankstorage[player] += temp;
    if ( bankstorage[id] > temp ) bankstorage[id] -= temp;
    else
    {
        temp -= bankstorage[id];
        bankstorage[id] = 0;
        zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - temp);
    }
}
//public zp_user_disconnect_pre(id)
public client_disconnect(id)
    if ( bankstorage[id] > 0 ) save_data(id);

//public zp_user_connect_post(id)
public client_connect(id)
{    
    bankstorage[id] = 0;    //clear residual before loading
    retrieve_data(id);
}

store_cash(id, amnt)
{
    if ( !get_pcvar_num(pcvars[enable]) ) return;
    
    if ( amnt == -1 )
    {
        bankstorage[id] += zp_get_user_ammo_packs(id);
        zp_set_user_ammo_packs(id, 0);
        checkmax(id);
    }
    else if ( amnt > 0 )
    {        
        new temp = zp_get_user_ammo_packs(id);
        new limit = get_pcvar_num(pcvars[cap]);
        if ( temp >= amnt )
        {            
            if ( bankstorage[id] + amnt <= limit )
            {
                bankstorage[id] += amnt
                zp_set_user_ammo_packs(id, temp - amnt);
            }
            else
            {
                new overflow = bankstorage[id] + amnt - limit;
                bankstorage[id] = limit;
                zp_set_user_ammo_packs(id, temp - amnt + overflow);
                client_print(id, print_chat, "[%s] Your bank account has reached it's maximium capacity of %d", plugin, limit);
                client_print(id, print_chat, "[%s] Only %d of the %d you specified to deposit has been deposited", plugin,
                amnt - overflow, amnt);
            }
        }
        else
            client_print(id, print_chat, "[%s] Amount specified(%d) is greater than current ammo pack count(%d)", plugin,
            amnt, temp);            
    }
    else
        take_cash(id, -amnt);
}

take_cash(id, amnt)
{
    if ( !get_pcvar_num(pcvars[enable]) ) return;
    
    if ( amnt == 0 ) return;    //otherwise a non terminal loop is possible
    
    if ( amnt == -1 )
    {
        zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + bankstorage[id])
        bankstorage[id] = 0;
    }
    else if ( amnt > 0 )
    {
        if ( bankstorage[id] >= amnt )
        {
            zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + amnt);
            bankstorage[id] -= amnt;
        }
        else {
            client_print(id, print_chat, "[%s] Amount specified(%d) is greater than whats in bank(%d)", plugin,
            amnt, bankstorage[id]);        
        }    
    }
    else store_cash(id, -amnt);
}

save_data(id)
{
    new AuthID[35];
    get_user_authid(id,AuthID,34);
    new vaultkey[40],vaultdata[13];
    
    formatex( vaultkey, 39, "__%s__", AuthID);
    formatex( vaultdata, 12, "%i", bankstorage[id] );

    nvault_set(gvault, vaultkey, vaultdata);
}

retrieve_data(id)
{
    new AuthID[35];
    get_user_authid(id,AuthID,34);
    new vaultkey[40], vaultdata[13];
    
    format(vaultkey, 39, "__%s__", AuthID);

    nvault_get(gvault, vaultkey, vaultdata, 12);
        
    bankstorage[id] = str_to_num(vaultdata);
    checkmax(id);    
    
    // If they have an account don't allow zombie mod to give them 5 ammo packs at beggining
    if ( get_pcvar_num(pcvars[start]) && bankstorage[id] > 0 )
        zp_set_user_ammo_packs(id, 0);
}

checkmax(id)
{
    if ( bankstorage[id] > get_pcvar_num(pcvars[cap]) )
        bankstorage[id] = get_pcvar_num(pcvars[cap]);
        
    else if ( bankstorage[id] < 0 )
        bankstorage[id] = 0;
}
  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych