Raised This Month: $ Target: $400
 0% 

Some help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sn3amtz
Senior Member
Join Date: Jan 2015
Location: France
Old 01-10-2016 , 00:33   Some help
Reply With Quote #1

I want to create a cvar for enabled and disabled plugin
god_kill 0/1

Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

public plugin_init() 
{
    register_plugin("Free Godmode", "0.1", "zmd94")
    
    RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1)
}

public fw_PlayerKilled(iVictim, iKiller)  
{
    if (iVictim == iKiller || !is_user_alive(iKiller)) 
        return
    
    set_user_godmode(iKiller, 1)
    set_task(2.0, "Reset", iKiller)
}

public Reset(id)
{
    if(is_user_alive(id))
    {
        set_user_godmode(id, 0)
    }
}

Last edited by Sn3amtz; 01-10-2016 at 00:38.
Sn3amtz is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-10-2016 , 01:27   Re: Some help
Reply With Quote #2

Spoiler

Last edited by raizo11; 01-14-2016 at 17:02.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
Baws
Veteran Member
Join Date: Oct 2012
Old 01-10-2016 , 04:13   Re: Some help
Reply With Quote #3

Quote:
Originally Posted by raizo11 View Post
Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

public plugin_init() 
{
    register_plugin("Free Godmode", "0.1", "zmd94")

    register_cvar("god_kill", "1")
    
    RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1)
}

public fw_PlayerKilled(iVictim, iKiller)  
{
    if (iVictim == iKiller || !is_user_alive(iKiller) || !get_cvar_num("god_kill") )
        return
    
    set_user_godmode(iKiller, 1)
    set_task(2.0, "Reset", iKiller)
}

public Reset(id)
{
    if(is_user_alive(id))
    {
        set_user_godmode(id, 0)
    }
}
pcvars are way better.
__________________
Like my clean plugins and work?
Baws is offline
Sn3amtz
Senior Member
Join Date: Jan 2015
Location: France
Old 01-14-2016 , 17:00   Re: Some help
Reply With Quote #4

And how to make a cvar for task ?

Example : amx_reset 2.0 ,3,0

Thanks

Last edited by Sn3amtz; 01-14-2016 at 17:00.
Sn3amtz is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 01-15-2016 , 12:30   Re: Some help
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

new g_timecvarg_god_kill
new Float:g_time

public plugin_init() 
{
    
register_plugin("Free Godmode""0.1""zmd94")
    
g_god_kill register_cvar("god_kill""1")
    
g_timecvar register_cvar("god_kill_time""2")
    
g_time get_pcvar_float(g_timecvar)

    
RegisterHam(Ham_Killed"player""fw_PlayerKilled"1)
}

public 
fw_PlayerKilled(iVictimiKiller)  
{
    if (
iVictim == iKiller || !is_user_alive(iKiller) || !get_pcvar_num(g_god_kill)) 
        return
    
    
set_user_godmode(iKiller1)
    
set_task(g_time"Reset"iKiller)
}

public 
Reset(id)
{
    if(
is_user_alive(id))
    {
        
set_user_godmode(id0)
    }


Last edited by siriusmd99; 01-18-2016 at 01:36.
siriusmd99 is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 01-16-2016 , 17:12   Re: Some help
Reply With Quote #6

PHP Code:
!get_cvar_num("g_god_kill"

PHP Code:
!get_pcvar_num(g_god_kill
__________________
Like my clean plugins and work?
Baws is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-16-2016 , 17:43   Re: Some help
Reply With Quote #7

Code:
#include <amxmodx>
#include <hamsandwich>
#include <dhudmessage>
#include <fun>

new bool:g_bAttack[33] = {true, ...}

public plugin_init() 
{
    register_plugin("x", "1.0", "-")

    register_cvar("god_on", "1")
    register_cvar("amx_reset", "1.0")
    
    RegisterHam(Ham_TakeDamage, "player", "onTakeDamagePre", false)
    RegisterHam(Ham_TraceAttack, "player", "onTraceAttack")
    RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1)
}

public onTakeDamagePre(victim, inflictor, attacker, Float:dmg, dmgbits)
{
    if(!is_user_alive(attacker) || get_user_team(attacker) == get_user_team(victim))
        return HAM_IGNORED
    
    return g_bAttack[attacker] ? HAM_IGNORED : HAM_SUPERCEDE
}

public onTraceAttack(ent, attacker, Float:damage, Float:direction[3], trace, dmgbits)
    return !g_bAttack[attacker] ? HAM_SUPERCEDE : HAM_IGNORED


public fw_PlayerKilled(iVictim, iKiller)  
{
    if (iVictim == iKiller || !is_user_alive(iKiller) || !get_cvar_num("god_on") )
        return
    if(get_user_team(iKiller) == 1)
    set_user_rendering(iKiller, kRenderFxGlowShell, 255, 0, 0, kRenderNormal)
    if(get_user_team(iKiller) == 2)
    set_user_rendering(iKiller, kRenderFxGlowShell, 0, 0, 255, kRenderNormal)
    set_user_godmode(iKiller, 1)
    g_bAttack[iKiller] = false
    new Float:GodKill = get_cvar_float("amx_reset")
    set_task(GodKill, "Reset", iKiller)
    set_dhudmessage(110, 55, 110, -1.0, 0.70, 1, 0.1, 3.0, 0.1, 2.0, false)
    show_dhudmessage(iKiller, "God Mode Is Enabled After Kill A Enemy")
    show_dhudmessage(iVictim, "Gang-Bang Protection Enabled")
}

public Reset(id)
{
    if(is_user_alive(id))
    {
        set_user_godmode(id, 0)
        set_user_rendering(id) 
        g_bAttack[id] = true
    }
}

Last edited by raizo11; 01-18-2016 at 06:21.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
Depresie
Veteran Member
Join Date: Nov 2013
Old 01-16-2016 , 22:54   Re: Some help
Reply With Quote #8

I didn't think anyone could of written that code in that many lines... also, you forgot to remove task on disconnect

PHP Code:
#include <amxmodx> 
#include <hamsandwich> 
#include <fun> 

new cvar_godmode_enabledcvar_godmode_duration

public plugin_init()  

    
register_plugin("Free Godmode""0.1""zmd94"
    
    
cvar_godmode_enabled register_cvar("amx_godmode_enabled""1")
    
cvar_godmode_duration register_cvar("amx_godmode_duration""2.0")
    
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled"1


public 
client_disconnect(id)
{
    
remove_task(id)
}

public 
fw_PlayerKilled(iVictimiKiller)   
{
    if(
iVictim != iKiller && is_user_alive(iKiller) && get_pcvar_num(cvar_godmode_enabled))
    {
         
set_user_godmode(iKiller1)
         
remove_task(iKiller)
         
set_task(get_pcvar_float(cvar_godmode_duration), "Reset"iKiller
         
    }
}

public 
Reset(id

    if(
is_user_connected(id)) 
    { 
        
set_user_godmode(id0
    } 

__________________

Last edited by Depresie; 01-16-2016 at 22:55.
Depresie is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 01-17-2016 , 02:46   Re: Some help
Reply With Quote #9

Quote:
Originally Posted by Baws View Post
PHP Code:
!get_cvar_num("g_god_kill"

PHP Code:
!get_pcvar_num(g_god_kill
Oh.. Thanks. Never will write on mobile anymore.
siriusmd99 is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 01-17-2016 , 22:03   Re: Some help
Reply With Quote #10

Quote:
Originally Posted by siriusmd99 View Post
Oh.. Thanks. Never will write on mobile anymore.
You still have the quotes there. Remove them buddy.
__________________
Like my clean plugins and work?
Baws is offline
Reply


Thread Tools
Display Modes

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 09:28.


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