AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved MultiJump Help (https://forums.alliedmods.net/showthread.php?t=314891)

lantimilan 03-12-2019 06:04

MultiJump Help
 
Hello i have one version for multijump its with reapi, i need to set to work with time in day to buy multijump and from 23:00 to 10:00 to have free multijump, and have file .ini to set in direct in plugin to show sms

Code:

#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <multi_jump>

#pragma semicolon 1

new const PLUGIN_VERSION[] = "1.0";

/****************************************************************************************
****************************************************************************************/

#define GetCvarDesc(%0) fmt("%l", %0)

new g_iBuyPrice;
new g_iBuyPriceSteam;
new g_iBuyJumps;

public plugin_init()
{
        register_plugin("Multi Jump: Buy", PLUGIN_VERSION, "w0w");
        register_dictionary("multi_jump_buy.ini");

        // say/say_team commands
        register_saycmd("mj", "func_BuyJumps");
        // console command
        register_clcmd("amx_buymj", "func_BuyJumps");

        new pCvar;

        pCvar = create_cvar("mj_buy_price", "30", FCVAR_NONE, GetCvarDesc("MJ_BUY_CVAR_PRICE"), true, 0.0, true, 2147483520.0);
        bind_pcvar_num(pCvar, g_iBuyPrice);

        pCvar = create_cvar("mj_buy_price_steam", "20", FCVAR_NONE, GetCvarDesc("MJ_BUY_CVAR_PRICE_STEAM"), true, 0.0, true, 2147483520.0);
        hook_cvar_change(pCvar, "hook_CvarChange_PriceSteam");

        pCvar = create_cvar("mj_buy_additional_jumps", "1", FCVAR_NONE, GetCvarDesc("MJ_BUY_CVAR_ADDITIONAL_JUMPS"), true, 1.0);
        bind_pcvar_num(pCvar, g_iBuyJumps);

        AutoExecConfig(true, "multi_jump_buy");
}

public OnConfigsExecuted()
{
        if(g_iBuyPriceSteam && !has_reunion())
                set_fail_state("Reunion is not available to use mj_buy_price_steam CVar. Set the CVar to 0 or disable the plugin.");
}

public func_BuyJumps(id)
{
        if(!func_CanBuyJumps(id))
                return PLUGIN_HANDLED;

        new iMoney;

        rg_add_account(id, -(is_user_steam(id) ? g_iBuyPriceSteam : g_iBuyPrice));

        mj_give_user_jumps(id, g_iBuyJumps);
        rg_add_account(id, -iMoney);
        client_print_color(id, print_team_default, "%l", "MJ_BUY_SUCCESS", mj_get_user_jumps(id));

        return PLUGIN_HANDLED;
}

bool:func_CanBuyJumps(id)
{
        if(!is_user_alive(id))
        {
                client_print_color(id, print_team_red, "%l", "MJ_BUY_ERROR_DEAD");
                return false;
        }

        new iMoney = get_member(id, m_iAccount);

        if(iMoney < g_iBuyPrice)
        {
                client_print_color(id, print_team_red, "%l", "MJ_BUY_ERROR_NEED_MONEY", g_iBuyPrice - iMoney);
                return false;
        }
        return true;
}

public hook_CvarChange_PriceSteam(pCvar, const szOldValue[], szNewValue[])
{
        g_iBuyPriceSteam = str_to_num(szNewValue);

        if(g_iBuyPriceSteam && !has_reunion())
                set_fail_state("Reunion is not available to use mj_buy_price_steam CVar. Set the CVar to 0 or disable the plugin.");
}

// thanks to mx?! (BlackSignature)
stock register_saycmd(szSayCmd[], szFunc[])
{
        new const szPrefix[][] = { "say /", "say_team /", "say .", "say_team ." };

        for(new i, szTemp[MAX_NAME_LENGTH]; i < sizeof(szPrefix); i++)
        {
                formatex(szTemp, charsmax(szTemp), "%s%s", szPrefix[i], szSayCmd);
                register_clcmd(szTemp, szFunc);
        }
}

File .ini
Code:

[en]
MJ_BUY_SUCCESS = ^4* ^1You've successfully done the purchase. Your jumps: ^4%d
MJ_BUY_ERROR_DEAD = ^3* ^1You're dead and can't do the purchase
MJ_BUY_ERROR_NEED_MONEY = ^3* ^1You need ^4%d$ ^1to do the purchase


Mordekay 03-12-2019 10:17

Re: MultiJump Help
 
Code:

        if(g_iBuyPriceSteam && !has_reunion())
                set_fail_state("Reunion is not available to use mj_buy_price_steam CVar. Set the CVar to 0 or disable the plugin.");

To stingy to buy the game you want to play but running plugins where users can buy crap extras.
Lol...

thEsp 03-14-2019 17:27

Re: MultiJump Help
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define ADMINACCESS ADMIN_CHAT

new g_iStartTime 23
new g_iStopTime 10

new jumpnum[33] = 0
new bool:dojump[33] = false

public plugin_init()
{
    
register_plugin("MultiJump","1.1","twistedeuphoria")
    
register_cvar("amx_maxjumps","1")
    
register_cvar("amx_mjadminonly","0")
}

public 
client_putinserver(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_disconnect(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_PreThink(id)
{

    
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
new nbut get_user_button(id)
    new 
obut get_user_oldbutton(id)
    if((
nbut IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut IN_JUMP))
    {
        new 
szTimeHour[64]
        
get_time("%H",szTimeHour,charsmax(szTimeHour))
    
    
        new 
iTimeHour str_to_num(szTimeHour)
    
        if(
jumpnum[id] < get_cvar_num("amx_maxjumps") && (iTimeHour g_iStartTime || g_iStopTime iTimeHour))
        {
            
dojump[id] = true
            jumpnum
[id]++
            return 
PLUGIN_CONTINUE
        
}
    }
    if((
nbut IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
    {
        
jumpnum[id] = 0
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_PostThink(id)
{    
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
if(dojump[id] == true)
    {
        new 
Float:velocity[3]    
        
entity_get_vector(id,EV_VEC_velocity,velocity)
        
velocity[2] = random_float(265.0,285.0)
        
entity_set_vector(id,EV_VEC_velocity,velocity)
        
dojump[id] = false
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE


Make sure the system time is set to 24-hour format.

Relaxing 03-15-2019 09:09

Re: MultiJump Help
 
Quote:

Originally Posted by thEsp (Post 2643338)
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define ADMINACCESS ADMIN_CHAT

new g_iStartTime 23
new g_iStopTime 10

new jumpnum[33] = 0
new bool:dojump[33] = false

public plugin_init()
{
    
register_plugin("MultiJump","1.1","twistedeuphoria")
    
register_cvar("amx_maxjumps","1")
    
register_cvar("amx_mjadminonly","0")
}

public 
client_putinserver(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_disconnect(id)
{
    
jumpnum[id] = 0
    dojump
[id] = false
}

public 
client_PreThink(id)
{

    
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
new nbut get_user_button(id)
    new 
obut get_user_oldbutton(id)
    if((
nbut IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut IN_JUMP))
    {
        new 
szTimeHour[64]
        
get_time("%H",szTimeHour,charsmax(szTimeHour))
    
    
        new 
iTimeHour str_to_num(szTimeHour)
    
        if(
jumpnum[id] < get_cvar_num("amx_maxjumps") && (iTimeHour g_iStartTime || g_iStopTime 23))
        {
            
dojump[id] = true
            jumpnum
[id]++
            return 
PLUGIN_CONTINUE
        
}
    }
    if((
nbut IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))
    {
        
jumpnum[id] = 0
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_PostThink(id)
{    
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE
    
if(get_cvar_num("amx_mjadminonly") && (!access(id,ADMINACCESS))) return PLUGIN_CONTINUE
    
if(dojump[id] == true)
    {
        new 
Float:velocity[3]    
        
entity_get_vector(id,EV_VEC_velocity,velocity)
        
velocity[2] = random_float(265.0,285.0)
        
entity_set_vector(id,EV_VEC_velocity,velocity)
        
dojump[id] = false
        
return PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE


Make sure the system time is set to 24-hour format.

23 to 10 means 23:00 to 10:59
And that's 11 A.M

lantimilan 03-15-2019 09:13

Re: MultiJump Help
 
I think something its wrong with time when i test last night in 23 : 34 i cant make multijump when i test in morning 8:25 i see working i think something its wrong

thEsp 03-15-2019 13:19

Re: MultiJump Help
 
I edited the post since I misplaced some valueS in a line. But... Don't know what type of problem you face. If it is possible, just set the server time to 24 hour format as I've said. Elsewise you can only multi jump if the time is set to a period such as 5-10 (am or pm, should work with both).

eat1k 03-15-2019 14:08

Re: MultiJump Help
 
Add the check with time to bool:func_CanBuyJumps(id)


All times are GMT -4. The time now is 09:48.

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