AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   semi godmode (https://forums.alliedmods.net/showthread.php?t=62591)

l4ulwtlln 10-30-2007 21:37

semi godmode
 
is it possible to have a semi godmode? what i mean is that users cant take damage from weapons (ak, mp5, usp, he nade, knife, ect) but can take damage from falling from a high place, map damaging triggers, drowning, ect.

Wilson [29th ID] 10-31-2007 04:39

Re: semi godmode
 
Check out how this plugin is operated. It hooks the shot then changes the hitbox to the head. You can simply change the hitbox to "none"

It won't affect high places or drowning or anything - just weapons. I'm not sure it will fix the knife for you though.

kp_uparrow 10-31-2007 16:19

Re: semi godmode
 
i say it will block knife attacks, because the endpoint can be modified to knife someone from far away

ConnorMcLeod 10-31-2007 17:12

Re: semi godmode
 
You can use hamsandwich module to hook damage.

Sylwester 10-31-2007 18:38

Re: semi godmode
 
this should work fine:

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <fun>

new g_max_players

public plugin_init(){
    
register_plugin"NoWeaponDmg""1.0""Sylwester")
    
register_forward(FM_TraceLine"traceline")
    
register_forward(FM_TraceHull"tracehull"1)
    
register_event("Damage""damage_event""b""2!0")

    
g_max_players get_maxplayers()
}

//block bullets
public traceline(Float:v1[3], Float:v2[3], noMonsterspentToSkip){
    new 
iAttacker pentToSkip
    
new iVictim get_tr(TR_pHit)

    if ( 
iVictim >= && iVictim <= g_max_players && iAttacker >= && iAttacker <= g_max_players){
        
set_tr(TR_flFraction1.0)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}

//block knife
public tracehull(Float:v1[3], Float:v2[3], noMonstershullNumberpentToSkip){
    new 
iAttacker pentToSkip
    
new iVictim get_tr(TR_pHit)

    if ( 
iVictim >= && iVictim <= g_max_players && iAttacker >= && iAttacker <= g_max_players){
        
set_tr(TR_flFraction1.0)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}

//block HE grenades
public damage_event(id){
    if(
id || id g_max_players)
        return 
PLUGIN_CONTINUE
    
new weapon
    
new bodypart
    
new attacker get_user_attacker(idweaponbodypart)
    if(
attacker || attacker g_max_players)
        return 
PLUGIN_CONTINUE

    
new damage read_data(2)
    if(
weapon==4//grenade
        
set_user_health(idget_user_health (attacker) + damage)
    
    return 
PLUGIN_HANDLED



l4ulwtlln 10-31-2007 23:14

Re: semi godmode
 
@Wilson [29th ID]
Will it work for CS?


@connorr
I'm not familiar with the hamsandwich module so this would be impossible for me to do alone.


@Sylwester
Thank! Bullet and Knife blocking works without a problem but the way u "block" nades doesn't. u set the players health back to what ever they had after they had already taken damage so that means if the user has 1 HP, and then got hit by a nade, they would die. anyway to avoid this?

ConnorMcLeod 11-01-2007 06:32

Re: semi godmode
 
I'm not familiar either, but in this case, the use of ham looks like fakemeta.

Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> new g_max_clients public plugin_init() {     register_plugin( "No Weapons Damage" , "0.1" , "connor" )     RegisterHam( Ham_TakeDamage , "player" , "player_TakeDamage" ) } public plugin_cfg() {     g_max_clients = global_get( glb_maxClients ) } public player_TakeDamage( this , idinflictor , idattacker , Float:damage , damagebits ) {     if( 1 <= idattacker <= g_max_clients )         return HAM_SUPERCEDE     return HAM_IGNORED }

Sylwester 11-01-2007 08:48

Re: semi godmode
 
I fixed problem with nades by giving player 256 more hp on "player spawn" and removing it if his hp drop under 256. Player will not see any difference on his HUD but spectators gonna see wrong amount of hp.
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <fun>

#define MAX_PLAYERS 32

new g_max_players
new bool:g_restart_attempt[MAX_PLAYERS 1]

public 
plugin_init(){
    
register_plugin"NoWeaponDmg""1.0""Sylwester")
    
register_forward(FM_TraceLine"traceline")
    
register_forward(FM_TraceHull"tracehull"1)
    
register_event("Damage""damage_event""b""2!0")

    
g_max_players get_maxplayers()
    
    
register_event("ResetHUD""event_hud_reset""be")
    
register_clcmd("fullupdate""clcmd_fullupdate"
    
register_event("TextMsg""event_restart_attempt""a""2=#Game_will_restart_in")
}


public 
traceline(Float:v1[3], Float:v2[3], noMonsterspentToSkip){
    new 
iAttacker pentToSkip
    
new iVictim get_tr(TR_pHit)

    if ( 
iVictim >= && iVictim <= g_max_players && iAttacker >= && iAttacker <= g_max_players){
        
set_tr(TR_flFraction1.0)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}


public 
tracehull(Float:v1[3], Float:v2[3], noMonstershullNumberpentToSkip){
    new 
iAttacker pentToSkip
    
new iVictim get_tr(TR_pHit)

    if ( 
iVictim >= && iVictim <= g_max_players && iAttacker >= && iAttacker <= g_max_players){
        
set_tr(TR_flFraction1.0)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}


public 
damage_event(id){
    if(
id || id g_max_players)
        return 
PLUGIN_CONTINUE
    
new weapon
    
new bodypart
    
new attacker get_user_attacker(idweaponbodypart)
    if(
attacker || attacker g_max_players)
        return 
PLUGIN_CONTINUE

    
new damage read_data(2)
    if(
weapon==4//grenade
        
set_user_health(idget_user_health (attacker) + damage)
    
    if(
get_user_health(id)<=256)
        
set_user_health(idget_user_health(id) - 256)
    return 
PLUGIN_HANDLED
}


public 
clcmd_fullupdate() {
    return 
PLUGIN_HANDLED_MAIN
}
 
public 
event_restart_attempt() {
    new 
players[32], num
    get_players
(playersnum"a")
    for (new 
inum; ++i)
        
g_restart_attempt[players[i]] = true
}   

public 
event_hud_reset(id) {
    if (
g_restart_attempt[id]) {
        
g_restart_attempt[id] = false
        
return
    } 
    
event_player_spawn(id)
}

public 
event_player_spawn(id) {
    
set_user_health(idget_user_health(id) + 256)



purple_pixie 11-01-2007 11:26

Re: semi godmode
 
Quote:

Originally Posted by connorr (Post 548275)
I'm not familiar either, but in this case, the use of ham looks like fakemeta.

Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> new g_max_clients public plugin_init() {     register_plugin( "No Weapons Damage" , "0.1" , "connor" )     RegisterHam( Ham_TakeDamage , "player" , "player_TakeDamage" ) } public plugin_cfg() {     g_max_clients = global_get( glb_maxClients ) } public player_TakeDamage( this , idinflictor , idattacker , Float:damage , damagebits ) {     if( 1 <= idattacker <= g_max_clients )         return HAM_SUPERCEDE     return HAM_IGNORED }

Well I for one am fairly familiar with HS, and that looks to me like it should work fine.
I don't think you need to include FM though.

And might I say, that's a very sly way to do it - if it works it'd be morally wrong to use any other method.

ConnorMcLeod 11-01-2007 13:48

Re: semi godmode
 
I've tested and it works fine.
FM needed for global_get, but get_maxplayers() could do the trick.


All times are GMT -4. The time now is 01:20.

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