Raised This Month: $ Target: $400
 0% 

Changing szRejectReason in FM_ClientConnect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-01-2014 , 12:17   Changing szRejectReason in FM_ClientConnect
Reply With Quote #1

I'm trying to change szRejectReason ClientConnect, but in fact it does not change. How I can change it?
PHP Code:
#include <amxmodx>
#include <fakemeta>

#pragma ctrlchar    '\'

public plugin_init() {
    
register_forward(FM_ClientConnect"ClientConnect_Pre"false);
}

public 
ClientConnect_Pre(const iClient, const pszName[], const pszAddress[], szRejectReason[128]) {
    
szRejectReason[0] = 'A';
    
szRejectReason[1] = 'c';
    
szRejectReason[2] = 'c';
    
szRejectReason[3] = 'e';
    
szRejectReason[4] = 's';
    
szRejectReason[5] = 's';
    
szRejectReason[6] = ' ';
    
szRejectReason[7] = 'd';
    
szRejectReason[8] = 'e';
    
szRejectReason[9] = 'n';
    
szRejectReason[10] = 'i';
    
szRejectReason[11] = 'e';
    
szRejectReason[12] = 'd';
    
szRejectReason[13] = '\0';
    
    
forward_return(FMV_CELLtrue);
    
    return 
FMRES_SUPERCEDE;

__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-01-2014 , 12:20   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #2

You have to call the function (engfunc) and supercede it (what you do already).
__________________
Arkshine is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-01-2014 , 12:46   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #3

Arkshine ClientConnect is gamedll function, if it returns false (but fakemeta change "true" to "false") engine will reject client with szRejectReason (it isn't const string):
fakemeta code:
PHP Code:
#define SIMPLE_BOOL_HOOK_EDICT_CONSTSTRING_CONSTSTRING_STRING128(call) \
    
qboolean call (edict_t *e, const char *sza, const char *szbchar blah[128]) \
    { \
        
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i),  (cell)ENTINDEX(e), sza, szb, blah)); \
        
RETURN_META_VALUE(mswi(lastFmRes),(int)mlCellResult 1); \
    } \ 
engine decompiled code:
PHP Code:
      snprintf(*(char **)arg0x80u"Connection rejected by game\n"v22);
      
v18 = *(_DWORD *)arg;
      
v17 v25;
      
v16 s;
      
v15 = (int)v26;
      if ( (
gEntityInterface.pfnClientConnect)(
             
v26,
             
s,
             
v25,
             *(
_DWORD *)arg) )
      {
        
MSG_WriteByte(&a19);
        
v7 Info_Serverinfo();
        
v14 v7;
        
v8 va("fullserverinfo \"%s\"\n"v7);
        
MSG_WriteString(&a1v8);
        
v9 svs.m_pClients;
        for ( 
0svs.m_iMaxClients; ++v9 )
        {
          if ( 
v9 == host_client || v9->m_fActive || v9->m_fConnected || v9->m_fSpawned )
            
SV_FullClientUpdate(v9, (int)&a1);
          ++
i;
        }
        
Netchan_CreateFragments(1, &host_client->m_netchan, &a1);
        
Netchan_FragSend(&host_client->m_netchan);
      }
      else
      {
        
MSG_WriteByte(&host_client->m_netchan.msg9);
        
v14 = *(_DWORD *)arg;
        
v6 va("echo %s\n", *(_DWORD *)arg);
        
MSG_WriteString(&host_client->m_netchan.msgv6);
        
v22 = *(char **)arg;
        
SV_DropClient(host_client0"Server refused connection because:  %s", *(_DWORD *)arg);
      } 
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-01-2014 , 13:13   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #4

Code:
PHP Code:
#include <amxmodx>
#include <fakemeta>

#pragma ctrlchar    '\'

public plugin_init() {
    
register_forward(FM_ClientConnect"ClientConnect_Pre"false);
}

public 
ClientConnect_Pre(const iClient, const pszName[], const pszAddress[], szRejectReason[128]) {
    
szRejectReason[0] = 'A';
    
szRejectReason[1] = 'c';
    
szRejectReason[2] = 'c';
    
szRejectReason[3] = 'e';
    
szRejectReason[4] = 's';
    
szRejectReason[5] = 's';
    
szRejectReason[6] = ' ';
    
szRejectReason[7] = 'd';
    
szRejectReason[8] = 'e';
    
szRejectReason[9] = 'n';
    
szRejectReason[10] = 'i';
    
szRejectReason[11] = 'e';
    
szRejectReason[12] = 'd';
    
szRejectReason[13] = '\0';
    
    
dllfunc(DLLFunc_ClientConnectiClientpszNamepszAddressszRejectReason);
    
    
forward_return(FMV_CELLtrue);
    
    return 
FMRES_SUPERCEDE;

Result:


Code:
PHP Code:
qboolean ClientConnect_Pre(edict_t *pEntity, const char *pszName, const char *pszAddresschar szRejectReason[128]) {
    
szRejectReason[0] = 'A';
    
szRejectReason[1] = 'c';
    
szRejectReason[2] = 'c';
    
szRejectReason[3] = 'e';
    
szRejectReason[4] = 's';
    
szRejectReason[5] = 's';
    
szRejectReason[6] = ' ';
    
szRejectReason[7] = 'd';
    
szRejectReason[8] = 'e';
    
szRejectReason[9] = 'n';
    
szRejectReason[10] = 'i';
    
szRejectReason[11] = 'e';
    
szRejectReason[12] = 'd';
    
szRejectReason[13] = '\0';

    
MDLL_ClientConnect(pEntitypszNamepszAddressszRejectReason);

    
RETURN_META_VALUE(MRES_SUPERCEDEfalse);

Result:
Attached Thumbnails
Click image for larger version

Name:	Безымянный.png
Views:	305
Size:	2.9 KB
ID:	135113   Click image for larger version

Name:	Безымянный2.png
Views:	333
Size:	2.8 KB
ID:	135114  
__________________

Last edited by PRoSToTeM@; 07-01-2014 at 13:15.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-01-2014 , 13:17   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #5

Not sure what you mean. But to do what you want, I would supercede original call and call the function (engfunc) with new string.
__________________

Last edited by Arkshine; 07-01-2014 at 13:19.
Arkshine is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-01-2014 , 13:22   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
Not sure what you mean. But to do what you want, I would supercede original call and call the function (engfunc) with new string.
I want to change szRejectReason string. Amxx plugin code doesn't change reason, but metamod plugin change it successfully. That is dllfunc, not engfunc.
__________________

Last edited by PRoSToTeM@; 07-01-2014 at 13:23.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-01-2014 , 13:26   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #7

Amxmodx push in arguments copy of the string, not original string. When I change the copy, the original remains the same.
Metamod push in arguments original string.

But how I can change original string in amxmodx plugin ?
__________________

Last edited by PRoSToTeM@; 07-01-2014 at 13:27.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Old 07-01-2014, 13:50
Arkshine
This message has been deleted by Arkshine. Reason: nvm
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-01-2014 , 13:54   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #9

Ah, yeah, you're right, confusing with something else. I understand better.

Well, I don't see any way, I guess we need a native to set param on the fly, like Ham. That's would be nice.
__________________
Arkshine is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-01-2014 , 14:18   Re: Changing szRejectReason in FM_ClientConnect
Reply With Quote #10

Quote:
Originally Posted by Arkshine View Post
Ah, yeah, you're right, confusing with something else. I understand better.

Well, I don't see any way, I guess we need a native to set param on the fly, like Ham. That's would be nice.
I think it will be useful for forward API (CreateMultiForward, ExecuteForward and other), not only for modules as fakemeta and hamsandwich.
__________________

Last edited by PRoSToTeM@; 07-01-2014 at 14:19.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
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 21:11.


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