AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Plugins VIP FREE (https://forums.alliedmods.net/showthread.php?t=337473)

Adi1997 04-23-2022 12:31

[HELP] Plugins VIP FREE
 
Hello, I have a VIP FREE plugin, I set it to be active from "20" to "6 in the morning", it has the / timevip command, but when I write / timevip it only shows 1 hour, not all the time it should be " Time left until the free vip ends in "54" min ", after those 54 min I write again" Time left until the end of the free vip "59" min ", it is resumed from the beginning, you can make me show the exact hours" Time left until the end of vip free 4 hours and 13 minutes, 5 hours and 24 minutes etc! THANK YOU VERY MUCH!
SOURCE:
HTML Code:

#include <amxmodx>

#define VIP_FLAG ADMIN_LEVEL_H

new const vip_time[] = {20, 6};
new const TAG[] = "[Server]";

new g_msg_saytext, g_sync, cvar_freevip, g_maxplayers;
new vip_free = 0;

public plugin_init()
{
    register_plugin("Vip Free", "4.0", "cyby");
   
    set_task(60.0, "check_time", _, _, _, "b");
    set_task(1.0, "hud_mess", _, _, _, "b");
   
    cvar_freevip = register_cvar("vip_free", "0");
   
    g_msg_saytext = get_user_msgid("SayText");
    g_maxplayers = get_maxplayers();
    g_sync = CreateHudSyncObj();
    cached_vars();
    set_task(1.0, "check_time");
    register_clcmd("say /timevip", "time_remain");
}

public client_putinserver(id)
{
    if(!vip_free)
        return;
   
    if(!(get_user_flags(id) & VIP_FLAG))
    {
        new flags = get_user_flags(id);
        flags |= VIP_FLAG
        set_user_flags(id, flags);
    }
}

public cached_vars()
    vip_free = get_pcvar_num(cvar_freevip);

public check_time()
{
    new o;
    time(o, _, _);
   
    if(!vip_free)
    {
        if(o >= vip_time[0] || o < vip_time[1])
        {
            vip_free = 1;
            set_pcvar_num(cvar_freevip, 1);
            color(0, ".v%s.g Eventul.e Free VIP.g a fost activat!", TAG);
        }
    }
    else
    {
        if(o < vip_time[0] && o >
= vip_time[1])
        {
            vip_free = 0;
            set_pcvar_num(cvar_freevip, 0);
            color(0, ".v%s.g Eventul.e Free VIP.g a fost dezactivat!", TAG);
            for(new i = 1; i <= g_maxplayers; i++)
            {
                if(!is_user_connected(i) || get_user_flags(i) & VIP_FLAG)
                    continue;
                   
                remove_user_flags(i);
            }
            server_cmd("amx_reloadadmins");
        }
    }
}

public time_remain(id)
{
    switch(vip_free)
    {
        case 1: color(id, ".v%s.g Timp ramas pana se termina vip-ul free.e %s.g.", TAG, time_left_vip());
        case 0: color(id, ".v%s.g Timp ramas pana incepe vip-ul free.e %s.g.", TAG, time_left_vip());
    }
    return PLUGIN_HANDLED;
}

public hud_mess()
{
    if(!vip_free)
        return;
   
    set_hudmessage(random(256), random(256), random(256), 0.00, 0.17, 0, 1.1, 1.0);
    ShowSyncHudMsg(0, g_sync, " [Server] Event VIP GRATUIT ON!");
    new flage;
    for(new i = 1; i <= g_maxplayers; i++)
    {
        if(!is_user_connected(i) || get_user_flags(i) & VIP_FLAG)
            continue;
           
        flage = get_user_flags(i);
        flage |= VIP_FLAG
        set_user_flags(i, flage);
    }
}

stock color(const id, const input[], any:...)
{
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)

    replace_all(msg, 190, ".v", "^4")
    replace_all(msg, 190, ".g", "^1")
    replace_all(msg, 190, ".e", "^3")

    if(id) players[0] = id; else get_players(players, count, "ch")
    {
        for(new i = 0; i < count; i++)
        {
            if(is_user_connected(players[i]))
            {
                message_begin(MSG_ONE_UNRELIABLE, g_msg_saytext, _, players[i])
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}

stock time_left_vip()
{
    new timp_ramas[16], len = 0;
    new h, m, lh, lm;
    time(h, m, _);
    switch(vip_free)
    {
        case 1: lh = vip_time[1] - h;
        case 0: lh = vip_time[0] - h;
    }
    lm = 60 - m;
    if(lm < 60)
        lh--;
   
    if(lh >
0)
        len += formatex(timp_ramas[len], charsmax(timp_ramas) - len, "%d or%s", lh, lh == 1 ? "a" : "e");
       
    if(lm < 60)
        len += formatex(timp_ramas[len], charsmax(timp_ramas) - len, " %d minut%s", lm, lm == 1 ? "" : "e");
       
    return timp_ramas;
}
stock add_time(x)

{

        new j;

        switch(x)

        {

                case 0: j = 24;

                case 1: j = 23;

                case 2: j = 22;

                case 3: j = 21;

                case 4: j = 20;

                case 5: j = 19;

                case 6: j = 18;

                case 7: j = 17;

                case 8: j = 16;

                case 9: j = 15;

                case 10: j = 14;

                case 11: j = 13;

                case 12: j = 12;

                case 13: j = 11;

                case 14: j = 10;

                case 15: j = 9;

                case 16: j = 8;

                case 17: j = 7;

                case 18: j = 6;

                case 19: j = 5;

                case 20: j = 4;

                case 21: j = 3;

                case 22: j = 2;

                case 23: j = 1;

        }

        if(x < vip_time[1])

                j = 0;

       

        return j;

}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE

*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }

*/


Craxor 04-24-2022 03:18

Re: [HELP] Plugins VIP FREE
 
And , what are we supposed to do?
Do you want us to modify the source?

Adi1997 04-24-2022 05:18

Re: [HELP] Plugins VIP FREE
 
Quote:

Originally Posted by Craxor (Post 2777724)
And , what are we supposed to do?
Do you want us to modify the source?

I want to solve the problem, it doesn't show me the correct time, the vip takes 8 hours and 15 minutes, for example, the plugin shows that it is still 58 after those 58 minutes, again it shows 1 hour, I want if you can change it to show exactly not one hour each ... for example "Free vip time ends in 5 hours and 15 minutes"

OciXCrom 04-25-2022 06:31

Re: [HELP] Plugins VIP FREE
 
The best way to solve this would be to rewrite the plugin completely because the code is garbage.
Are you sure there aren't any better alternative than this? I'm sure there are. I suggest you post a new plugin request instead.

Adi1997 04-25-2022 06:36

Re: [HELP] Plugins VIP FREE
 
Quote:

Originally Posted by OciXCrom (Post 2777870)
The best way to solve this would be to rewrite the plugin completely because the code is garbage.
Are you sure there aren't any better alternative than this? I'm sure there are. I suggest you post a new plugin request instead.

Thanks, I really appreciate it! I will make a plugin request today, Thank you


All times are GMT -4. The time now is 21:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.