Raised This Month: $ Target: $400
 0% 

|SOLVED| Plugin ON/OFF


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-20-2015 , 12:51   |SOLVED| Plugin ON/OFF
Reply With Quote #1

Cam someone please help me to add cvar for on/off? (when cvar is 1,plugin is runing,when cvar is 0 plugin is off)

PHP Code:
#include <amxmodx>
#include <fakemeta_util>
#include <hamsandwich>
#include <biohazard>
#include <bhextra>

new bool:g_WallClimb[33]
new 
Float:g_wallorigin[32][3]
new 
iMaxClientsitem_climb

public plugin_init() 
{
    
register_plugin("Extra Item: Wall climb""1.0""Accelerator")
    
register_forward(FM_Touch"fwd_touch")
    
register_forward(FM_PlayerPreThink"fwd_playerprethink")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
        
register_event("HLTV""OnNewRound""a""1=0""2=0")
    
    
iMaxClients get_maxplayers()
    
    
item_climb bh_register_extra_item("|BIO|Wall climb""JUMP+hold R to climb"800BH_TEAM_ZOMBIEITEM)

}

public 
bh_extra_item_selected(playeritemid)
{
    if (
itemid == item_climb)
    {
        if (
g_WallClimb[player])
        {
            
client_print(playerprint_chat"You already have bought the wall climb.")
            return 
PLUGIN_HANDLED;
        }
                      
        
g_WallClimb[player] = true
    
}
    return 
PLUGIN_CONTINUE;
}

public 
client_disconnect(id)
{
        
g_WallClimb[id] = false
}
        
public 
fw_PlayerKilled(victimattackershouldgib)
{
    
g_WallClimb[victim] = false
}

public 
OnNewRound()
{
    new 
id
    
for(id 1id <= iMaxClientsid++)
    {
        if(!
is_user_connected(id)) continue;
        
        
g_WallClimb[id] = false
    
}
}

public 
client_connect(id)
{
    
g_WallClimb[id] = false
}

public 
fwd_touch(idworld)
{
    if(!
is_user_alive(id) || !g_WallClimb[id])
        return 
FMRES_IGNORED
        
    pev
(idpev_origing_wallorigin[id])

    return 
FMRES_IGNORED
}

public 
wallclimb(idbutton)
{
    static 
Float:origin[3]
    
pev(idpev_originorigin)

    if(
get_distance_f(origing_wallorigin[id]) > 25.0)
        return 
FMRES_IGNORED  // if not near wall
    
    
if(fm_get_entity_flags(id) & FL_ONGROUND)
        return 
FMRES_IGNORED
        
    
if(button IN_FORWARD)
    {
        static 
Float:velocity[3]
        
velocity_by_aim(id70velocity)
        
fm_set_user_velocity(idvelocity)
    }
    else if(
button IN_BACK)
    {
        static 
Float:velocity[3]
        
velocity_by_aim(id, -70velocity)
        
fm_set_user_velocity(idvelocity)
    }
    return 
FMRES_IGNORED
}    

public 
fwd_playerprethink(id
{
    if(!
g_WallClimb[id]) 
        return 
FMRES_IGNORED
    
    
new button fm_get_user_button(id)
    
    if(
button IN_RELOAD//Use button = climb
        
wallclimb(idbutton)

    return 
FMRES_IGNORED

sorry problem solved

Last edited by Krtola; 02-20-2015 at 13:17. Reason: SOLVED
Krtola is offline
Send a message via Skype™ to Krtola
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-20-2015 , 15:04   Re: |SOLVED| Plugin ON/OFF
Reply With Quote #2

Why the .... peoples ask for help and then, when they find the solution they don't want to post it ?
__________________
HamletEagle is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-20-2015 , 15:52   Re: |SOLVED| Plugin ON/OFF
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Why the .... peoples ask for help and then, when they find the solution they don't want to post it ?
If someone really needs (if use the same plugin) and has the same problem of course I'll write...
Krtola is offline
Send a message via Skype™ to Krtola
ANTICHRISTUS
kingdom of weird stuff
Join Date: Jun 2010
Location: My kingdom is not in thi
Old 02-20-2015 , 17:18   Re: |SOLVED| Plugin ON/OFF
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
Why the ....Hell
Quote:
peoples ask for help and then, when they find the solution they don't want to post it ?
Haste !
Quote:
Originally Posted by Krtola View Post
If someone really needs (if use the same plugin) and has the same problem of course I'll write...
yore right !

Visitors will make accounts just to ask in (revive) your thread. Also GoogleBots want to know but can't. They will be banned.
__________________

Last edited by ANTICHRISTUS; 02-20-2015 at 17:29.
ANTICHRISTUS is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 02-20-2015 , 17:35   Re: |SOLVED| Plugin ON/OFF
Reply With Quote #5

new on_off

in public plugin_init add on_off = register_cvar("climb_on_off", "1")

PHP Code:
public bh_extra_item_selected(playeritemid

    if (
itemid == item_climb
    { 
        if (
g_WallClimb[player]) 
        { 
            
client_print(playerprint_chat"You already have bought the wall climb."
            return 
PLUGIN_HANDLED
        } 
                       
        
g_WallClimb[player] = true 
    

    return 
PLUGIN_CONTINUE


PHP Code:
public bh_extra_item_selected(playeritemid)
{
    if (
itemid == item_climb)
    {
        if (
g_WallClimb[player])
        {
            
client_print(playerprint_chat"You already have bought the wall climb.")
            return 
PLUGIN_HANDLED;
        }

        if (
get_pcvar_num(on_off) == 0)
        {
                
client_print(playerprint_chat"Climb item is currently switched off.")
                return 
PLUGIN_HANDLED;
        }
                      
        
g_WallClimb[player] = true

    
}
    return 
PLUGIN_CONTINUE;

Krtola is offline
Send a message via Skype™ to Krtola
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:43.


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