nomy

Untitled

Oct 3rd, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.29 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <dhooks>
  3. #include <sdktools>
  4.  
  5. new Handle:hClientPrintf = INVALID_HANDLE;
  6.  
  7. public OnPluginStart()
  8. {    
  9.     new Handle:gameconf = LoadGameConfigFile("clientprintf-hook.games");
  10.     if(gameconf == INVALID_HANDLE)
  11.     {
  12.         SetFailState("Failed to find clientprintf-hook.games.txt gamedata");
  13.     }
  14.     new offset = GameConfGetOffset(gameconf, "ClientPrintf");
  15.     if(offset == -1)
  16.     {
  17.         SetFailState("Failed to find offset for ClientPrintf");
  18.         CloseHandle(gameconf);
  19.     }
  20.     StartPrepSDKCall(SDKCall_Static);
  21.     if(!PrepSDKCall_SetFromConf(gameconf, SDKConf_Signature, "CreateInterface"))
  22.     {
  23.         SetFailState("Failed to get CreateInterface");
  24.         CloseHandle(gameconf);
  25.     }
  26.    
  27.     PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
  28.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL);
  29.     PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
  30.    
  31.     new String:interface[64];
  32.     if(!GameConfGetKeyValue(gameconf, "EngineInterface", interface, sizeof(interface)))
  33.     {
  34.         SetFailState("Failed to get engine interface name");
  35.         CloseHandle(gameconf);
  36.     }
  37.    
  38.     new Handle:temp = EndPrepSDKCall();
  39.     new Address:addr = SDKCall(temp, interface, 0);
  40.    
  41.     CloseHandle(gameconf);
  42.     CloseHandle(temp);
  43.    
  44.     if(!addr) SetFailState("Failed to get engine ptr");
  45.    
  46.     hClientPrintf = DHookCreate(offset, HookType_Raw, ReturnType_Void, ThisPointer_Ignore, Hook_ClientPrintf);
  47.     DHookAddParam(hClientPrintf, HookParamType_Edict);
  48.     DHookAddParam(hClientPrintf, HookParamType_CharPtr);
  49.     DHookRaw(hClientPrintf, false, addr);
  50. }
  51. public MRESReturn:Hook_ClientPrintf(Handle:hParams)
  52. {
  53.     decl String:buffer[1024];
  54.     DHookGetParamString(hParams, 2, buffer, 1024);
  55.     if(buffer[1] == '"' && (StrContains(buffer, "\" (") != -1 || (StrContains(buffer, ".smx\" ") != -1)))
  56.     {
  57.         DHookSetParamString(hParams, 2, "");
  58.         return MRES_ChangedHandled;
  59.     }
  60.     else if(StrContains(buffer, "To see more, type \"sm plugins") != -1)
  61.     {
  62.         DHookSetParamString(hParams, 2, "О_О,это конфиденциальная информация!\nBLOCK by Pheonix (˙·٠●Феникс●٠·˙)\n");
  63.         return MRES_ChangedHandled;
  64.     }
  65.     return MRES_Ignored;
  66. }
Add Comment
Please, Sign In to add comment