AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Redefine client_print function with a condition (https://forums.alliedmods.net/showthread.php?t=295210)

OciXCrom 03-19-2017 10:50

Redefine client_print function with a condition
 
What I'm trying to do is automatically transform a client_print(id, print_chat, message[]) message in a CC_SendMessage(id, message[]) function. So, I tried several methods:

PHP Code:

#define client_print(%1,%2,%3) CC_SendMessage(%1,%3) 

This is correct, but it will work for all messages type, not only print_chat.

PHP Code:

#define client_print(%1,print_chat,%3) CC_SendMessage(%1,%3) 

This is also correct, but it works only if the function is written without spaces, which is very rarely the case.

PHP Code:

#define client_print CC_PrintTransform

stock CC_PrintTransform(const id, const iType, const szInput[], any:...)
{
    if(
iType != print_chat)
        return
        
    new 
szMessage[188]
    
vformat(szMessagecharsmax(szMessage), szInput4)
    
CC_SendMessage(idszMessage)


This worked, but it will block all other print types.

So, I'm out of ideas. Is it possible to use some kind of a condition with the preprocessor, such as:

PHP Code:

#define client_print(%1,%2,%3) (if(%2 == print_chat) CC_SendMessage(%1,%3)) 

?

OciXCrom 03-19-2017 12:55

Re: Redefine client_print function with a condition
 
I explained perfectly well what I want.

EFFx 03-19-2017 13:28

Re: Redefine client_print function with a condition
 
Quote:

Originally Posted by killerZM (Post 2504845)
nope , i see nothin special just use normal client_print so or explain more .....

Quote:

Originally Posted by OciXCrom (Post 2504809)
What I'm trying to do is automatically transform a client_print(id, print_chat, message[]) message in a CC_SendMessage(id, message[]) function

Thats all what you should know.

fysiks 03-19-2017 13:51

Re: Redefine client_print function with a condition
 
Find and Replace with Regex.

edon1337 03-19-2017 14:48

Re: Redefine client_print function with a condition
 
Quote:

Originally Posted by OciXCrom (Post 2504836)
I explained perfectly well what I want.

He's just trying to become a Veteran Member don't mind him.

OciXCrom 03-19-2017 15:09

Re: Redefine client_print function with a condition
 
Find what, replace what? More information please. I have never used regex. And I'm asking if this can be done with a simple #define. I don't want to use any other includes for doing this.

klippy 03-19-2017 15:48

Re: Redefine client_print function with a condition
 
Have an editor that can do a Find & Replace with Regex. Then search for
Code:

client_print\s*\((.+?),\s*print_chat\s*,(.+?)\)
and replace with
Code:

CC_SendMessage($1,$2)
Just tested in Sublime Text 3.

killerZM 03-19-2017 16:17

Re: Redefine client_print function with a condition
 
Quote:

Originally Posted by edon1337 (Post 2504871)
He's just trying to become a Veteran Member don't mind him.

haah , what ?i dont a care about a ;rank
@edit : i deleted the posts live in happiness now boy

edon1337 03-19-2017 17:38

Re: Redefine client_print function with a condition
 
Quote:

Originally Posted by killerZM (Post 2504909)
haah , what ?i dont a care about a ;rank
@edit : i deleted the posts live in happiness now boy

It doesn't bother me, lol.

OciXCrom 03-19-2017 18:10

Re: Redefine client_print function with a condition
 
Quote:

Originally Posted by KliPPy (Post 2504894)
Have an editor that can do a Find & Replace with Regex. Then search for
Code:

client_print\s*\((.+?),\s*print_chat\s*,(.+?)\)
and replace with
Code:

CC_SendMessage($1,$2)
Just tested in Sublime Text 3.

You mean users will need to use a different editor in order to do that? What I want to do is simply add a #include which will contain a #define or something like that which will replace all print_chat messages with a custom function. If it requires down loading/using additional files, I can live without it. The point is to keep it simple and easy for people to use.


All times are GMT -4. The time now is 17:56.

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