Raised This Month: $32 Target: $400
 8% 

Best way for spawn protection


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-23-2016 , 08:51   Best way for spawn protection
Reply With Quote #1

What is the best way. To set spawn protection without bugging
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-23-2016 , 09:48   Re: Best way for spawn protection
Reply With Quote #2

Return ham_supercede on ham_takedamage pre.
__________________
Bugsy is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 10-23-2016 , 11:24   Re: Best way for spawn protection
Reply With Quote #3

set_user_godmode from fun module should also work pretty well

with the ham_takedamage method players will still be vulnerable to aimpunch when shot at, this shouldn't be a thing with set_user_godmode

Last edited by jimaway; 10-23-2016 at 11:26.
jimaway is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-23-2016 , 14:02   Re: Best way for spawn protection
Reply With Quote #4

heres my method. but i guess sometimes it bugges
PHP Code:
public fw_ham_respawn_post(id)
{
         if(!
is_user_alive(id)) return;
         
         
spawn_protection(id)
}

public 
spawn_protection(id)
{
    new 
Float:fPTime get_pcvar_float(g_pcvr_protection_time)
    
    if(!
fPTime)
        return;
    
    
g_fProtection_time[id] = fPTime get_gametime()
    
set_user_godmode(id1)
    
    
remove_task(id+TASK_PROTECTION)
    
set_task(1.0"protection_off"id+TASK_PROTECTION__"b")
    
    new 
iColor[3], sColor[12]
    
get_pcvar_string(g_pcvr_protection_colorsColorcharsmax(sColor))
    
format_rgb(sColoriColor)
    
set_user_rendering(idkRenderFxGlowShelliColor[0], iColor[1], iColor[2], kRenderNormal16)
}

public 
protection_off(taskid)
{
    new 
id taskid TASK_PROTECTION
    
    
if(!is_user_connected(id))
    {
        
remove_task(taskid)
        return;
    }
    if(!
is_user_alive(id))
    {
        
set_user_rendering(id)
        
remove_task(taskid)
        return;
    }
    if(
get_gametime() < g_fProtection_time[id])
    {
        
set_hudmessage(757575, -1.00.3011.01.0,0.30.34)
        
show_hudmessage(id"Protection : %d"floatround((g_fProtection_time[id]-get_gametime())))
        
        return;
    }
    
    
set_user_godmode(id0)
    
set_user_rendering(id)
    
    
cprint(id"^4%s ^3You have no longer a ^4proctection!"MODE_TAG)
    
remove_task(taskid)


Last edited by Natsheh; 10-23-2016 at 14:04.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 10-23-2016 , 15:36   Re: Best way for spawn protection
Reply With Quote #5

Or you can use fakemeta

set_pev(id,pev_takedamage,id,DAMAGE_NO);

and

set_pev(id,pev_takedamage,id,DAMAGE_AIM);
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
PartialCloning
Senior Member
Join Date: Dec 2015
Old 10-23-2016 , 16:29   Re: Best way for spawn protection
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
heres my method. but i guess sometimes it bugges
What part is bugged?

Quote:
Originally Posted by ^SmileY View Post
Or you can use fakemeta

set_pev(id,pev_takedamage,id,DAMAGE_NO);

and

set_pev(id,pev_takedamage,id,DAMAGE_AIM);
That's the same as using set_user_godmode.
PartialCloning is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-23-2016 , 17:05   Re: Best way for spawn protection
Reply With Quote #7

sometimes the bot/player his protection wont be removed...

Last edited by Natsheh; 10-23-2016 at 18:18.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
PartialCloning
Senior Member
Join Date: Dec 2015
Old 10-24-2016 , 00:09   Re: Best way for spawn protection
Reply With Quote #8

You'll have to go into more details if you want help. The code looks fine.

Is the hud message displayed when the bug occurs? Any error logs? If you're using this in a deathmatch server, are you sure "fw_ham_respawn_post" is called when you respawn players?
PartialCloning is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-24-2016 , 13:05   Re: Best way for spawn protection
Reply With Quote #9

nvm solved using post think to check if player still has the protection and also by making a bitsum to check if user has a godmode. , IDK if its the best method.

heres the code...

PHP Code:
public fw_player_respawn(id)
{
    if(!
is_user_alive(id))
        return 
HAM_IGNORED;
    
    
sp_on(id)
    return 
HAM_HANDLED;
}

public 
sp_on(id)
{
    new 
Float:fPTime get_pcvar_float(g_pcvr_protection_time)
    
    if(!
fPTime)
        return;
    
    if(
check_flag(g_protection,id))
    {
        
remove_task(id+TASK_PROTECTION)
        
set_task(1.0"protection_off"id+TASK_PROTECTION__"b")
        return;
    }
    
    
set_flag(g_protectionid)
    
g_fProtection_time[id] = fPTime get_gametime()
    
set_user_godmode(id1)
    
    new 
iColor[3], sColor[12]
    
get_pcvar_string(g_pcvr_protection_colorsColorcharsmax(sColor))
    
format_rgb(sColoriColor)
    
set_user_rendering(idkRenderFxGlowShelliColor[0], iColor[1], iColor[2], kRenderNormal16)
    
    
set_task(0.1"protection_off"id+TASK_PROTECTION__"b")
}


public 
protection_off(taskid)
{
    new 
id taskid TASK_PROTECTION
    
    
if(!is_user_connected(id))
    {
        
unset_flag(g_protection,id)
        
remove_task(taskid)
        return;
    }
    if(!
is_user_alive(id))
    {
        
unset_flag(g_protection,id)
        
set_user_rendering(idkRenderFxNone000kRenderNormal16)
        
remove_task(taskid)
        return;
    }
    if(
get_gametime() < g_fProtection_time[id])
    {
        
set_hudmessage(757575, -1.00.3011.01.0,0.30.34)
        
show_hudmessage(id"Protection : %d"floatround((g_fProtection_time[id]-get_gametime())))
        
        return;
    }
    
    
unset_flag(g_protection,id)
    
set_user_godmode(id0)
    
set_user_rendering(idkRenderFxNone000kRenderNormal16)
    
    
cprint(id"^4%s ^3You have no longer a ^4proctection!"MODE_TAG)
    
remove_task(taskid)
}

public 
client_PostThink(id)
{
    if(!
is_user_alive(id))
        return;
    
    
// in case of bug...
    
if(get_user_godmode(id) && check_flag(g_protection,id) && !task_exists(id+TASK_PROTECTION))
    {
        
protection_off(id+TASK_PROTECTION)
    }


Last edited by Natsheh; 10-24-2016 at 16:28.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 10-24-2016 , 18:36   Re: Best way for spawn protection
Reply With Quote #10

that's a horrible way to fix this. what is TASK_PROTECTION? do you use any other tasks? how do you hook public fw_player_respawn(id)? do you respawn players with a plugin?

posting the full code will most likely get you a proper fix for your problem
jimaway is offline
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 08:09.


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