Raised This Month: $51 Target: $400
 12% 

Ham_CS_RoundRespawn issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-15-2016 , 09:00   Ham_CS_RoundRespawn issue
Reply With Quote #1

I've been playing with the Ham_CS_RoundRespawn native and i noticed something that i think doesn't work as it is supposed to

In the first case, i noticed that when Ham_CS_RoundRespawn is returned as HAM_SUPERCEDE
The player will not be respawned ( obviously ) on the next round or after sv_restart, but instead he will keep his origin and remain alive

In this case i think the player should be automatically killed if RoundRespawn is returned SUPERCEDE when the event is called

In the second case, i noticed that when HAM_CS_RoundRespawn is returned as SUPERCEDE for a player while he is alive and then he gets killed, he will still be respawned on the next round

Code here

Write in chat spawn to forbid respawning for you
Write in chat kill to get killed
Notice that you will still get respawned

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <hlsdk_const>
#include <xs>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Depresie"

new g_Spawn[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say kill""cmdkill")
    
register_clcmd("say spawn""cmdspawn")
    
    
RegisterHam(Ham_CS_RoundRespawn"player""event_round_spawn")
    
    
// Add your code here...
}

public 
cmdkill(id)
{
    
user_silentkill(id)
}

public 
cmdspawn(id)
{
    if(
g_Spawn[id])
    { 
        
g_Spawn[id] = false 
        
        client_print
(0print_chat"NO SPAWN FOR YOU")
    }
    
    else
    {
        
g_Spawn[id] = true
        client_print
(0print_chat"SPAWN ALLOWED")
    }
}

public 
event_round_spawn(id)
{
    if(!
g_Spawn[id])
    {
        return 
HAM_SUPERCEDE
    
}
    
    return 
HAM_IGNORED

__________________

Last edited by Depresie; 11-15-2016 at 09:05.
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-15-2016 , 09:40   Re: Ham_CS_RoundRespawn issue
Reply With Quote #2

Quote:
with the Ham_CS_RoundRespawn native
It's not a native. That's the thing - AMXX does exactly nothing with how these virtual functions work. If something in Ham doesn't work as expected when you supercede or whatever, it's because the game was coded that way.

EDIT:
Poking around, I found that RoundRespawn() is not exactly what respawns the player, but respawn() which is called from it. That respawn() function is also called from PlayerDeathThink() once player is eligible for respawning (after being granted a spawn on new round).
If you wanted to stop players fully from respawning, you would have to either block respawn() from being called or make CHalfLifeMultiplay::FCanPlayerRespawn() return FALSE.

Last edited by klippy; 11-15-2016 at 10:02.
klippy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-15-2016 , 10:25   Re: Ham_CS_RoundRespawn issue
Reply With Quote #3

So the problem happens because respawn() is also called by PlayerDeathThink() right ?

In this case this function works properly, i mean it hooked the RoundRespawn() event properly, but in order to avoid this situation, we would need a hook on both RoundRespawn() and PlayerDeathThink(), or directly on the respawn() function

Well, i guess i will wait for Arks respond to see if we are gonna get a new function that hooks PlayerDeathThink() or replace this one with a function that hooks respawn() directly..

Or else i will have to rethink my manager plugin =\

Also, if something doesn't work as expected when you supercede or whatever, because the game was coded that way, i think that should be categorized as a bug, and be fixed in order to work as expected
__________________

Last edited by Depresie; 11-15-2016 at 10:27.
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-15-2016 , 10:59   Re: Ham_CS_RoundRespawn issue
Reply With Quote #4

You wouldn't want to supercede PlayerDeathThink(), there's much more going on in there than just a respawn() call. By the way you can hook it just by simply hooking Ham_Think, but I don't know if there is a way to tell if m_pfnThink is set to PlayerDeathThink without using say Okapi. So it's a no-go.

Basically you either stop respawn() from being called or make HalfLifeMultiplay::FCanPlayerRespawn() return FALSE. I don't know if there is some other way.

Quote:
Also, if something doesn't work as expected when you supercede or whatever, because the game was coded that way, i think that should be categorized as a bug, and be fixed in order to work as expected
It doesn't work the way you expect it to. Hamsandwich works just fine. Again, there is no extra code for any virtual method in Hamsandwich and it will stay that way. If you need something to prevent spawning just by calling a native or returning a certain value from a forward, create an API that will do all the nasty work.

Last edited by klippy; 11-15-2016 at 11:01.
klippy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-15-2016 , 11:26   Re: Ham_CS_RoundRespawn issue
Reply With Quote #5

IMO we should have functions for such things as blocking respawn or ending a round in amxx by default without the need of using okapi and orpheu, along with a native that is setting the user's speed properly without the need of resetting it manually using other functions..

But hey, let's write one API for each and use extra modules that require extra configs and offsets and stuff...
Got another idea, let's ditch amxx and start scripting in metamod..

I am really getting tired of having to do work arounds all the time in order to get things done..
__________________
Depresie is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-15-2016 , 11:38   Re: Ham_CS_RoundRespawn issue
Reply With Quote #6

These things are entirely game specific. Not every game handles speed or respawning the same way and not every game has rounds. These are out of AMXX's scope, and only where they may belong are game-specific modules.
Even then, if a plugin uses newer "better" API to set speed, other plugins that use different methods to set speed may mess it up. Then if you wanted to support multiple games it would add more complexity to your plugin as you would have to do game-specific stuff for multiple games. Setting speed is fine as it is right now.
After all it's a two-minute job to hook Player_ResetMaxSpeed for Counter-Strike and set speed there.

Modules are there to provide access to stuff that you can't normally access from Pawn with AMXX, they only extend the toolset, and your job as a scripter is to use those tools to write code.
klippy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-15-2016 , 12:00   Re: Ham_CS_RoundRespawn issue
Reply With Quote #7

Well, since Arks is getting new functions into cstrike, implementing these three things would be nice =\
I know there are already many things on the to do list, and Arks is working his ass off on the new build, but if he would consider these three things, that would be great
__________________

Last edited by Depresie; 11-15-2016 at 12:02.
Depresie is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-15-2016 , 13:35   Re: Ham_CS_RoundRespawn issue
Reply With Quote #8

Quote:
Originally Posted by KliPPy View Post
You wouldn't want to supercede PlayerDeathThink(), there's much more going on in there than just a respawn() call. By the way you can hook it just by simply hooking Ham_Think, but I don't know if there is a way to tell if m_pfnThink is set to PlayerDeathThink without using say Okapi. So it's a no-go.

Basically you either stop respawn() from being called or make HalfLifeMultiplay::FCanPlayerRespawn() return FALSE. I don't know if there is some other way.


It doesn't work the way you expect it to. Hamsandwich works just fine. Again, there is no extra code for any virtual method in Hamsandwich and it will stay that way. If you need something to prevent spawning just by calling a native or returning a certain value from a forward, create an API that will do all the nasty work.
Just an ideea, try spawning a bot, then kill him. Game will automatically set m_pfnThink to CBasePlayer:: PlayerDeathThink address, then hook Killed and retrieve the offset value. That's a trick that I've used to get CWeaponBox::Kill, it may work here too. You just need the right moment to retrieve the offset(so you don't get other values).
__________________

Last edited by HamletEagle; 11-15-2016 at 13:35.
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-15-2016 , 13:49   Re: Ham_CS_RoundRespawn issue
Reply With Quote #9

Never mind, still cannot block it properly... >.<
__________________

Last edited by Depresie; 11-16-2016 at 06:21.
Depresie is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 11-16-2016 , 13:42   Re: Ham_CS_RoundRespawn issue
Reply With Quote #10

You can post this issue to the ReGameDLL_CS repository on github.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Old 12-09-2016, 00:43
jackseason
This message has been deleted by Arkshine. Reason: Spambot
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 20:58.


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