AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Changing szRejectReason in FM_ClientConnect (https://forums.alliedmods.net/showthread.php?t=243228)

PRoSToTeM@ 07-01-2014 12:17

Changing szRejectReason in FM_ClientConnect
 
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;



Arkshine 07-01-2014 12:20

Re: Changing szRejectReason in FM_ClientConnect
 
You have to call the function (engfunc) and supercede it (what you do already).

PRoSToTeM@ 07-01-2014 12:46

Re: Changing szRejectReason in FM_ClientConnect
 
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@ 07-01-2014 13:13

Re: Changing szRejectReason in FM_ClientConnect
 
2 Attachment(s)
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:
https://forums.alliedmods.net/attach...3&d=1404234688

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:
https://forums.alliedmods.net/attach...4&d=1404234688

Arkshine 07-01-2014 13:17

Re: Changing szRejectReason in FM_ClientConnect
 
Not sure what you mean. But to do what you want, I would supercede original call and call the function (engfunc) with new string.

PRoSToTeM@ 07-01-2014 13:22

Re: Changing szRejectReason in FM_ClientConnect
 
Quote:

Originally Posted by Arkshine (Post 2160386)
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.

PRoSToTeM@ 07-01-2014 13:26

Re: Changing szRejectReason in FM_ClientConnect
 
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 ?

Arkshine 07-01-2014 13:54

Re: Changing szRejectReason in FM_ClientConnect
 
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.

PRoSToTeM@ 07-01-2014 14:18

Re: Changing szRejectReason in FM_ClientConnect
 
Quote:

Originally Posted by Arkshine (Post 2160408)
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.


All times are GMT -4. The time now is 21:11.

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