AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can i log something to UDP but not file? (https://forums.alliedmods.net/showthread.php?t=293122)

seves985 01-23-2017 12:57

How can i log something to UDP but not file?
 
I want to modify a script to log data only via UDP but not to a file.

I found out that the annoying messages were logged via:
Code:

log_message ("[Fly] successfully loaded.")
After searching a bit within the amxmodx directory, i get the file amxmodx.inc and found on the AMX Mod X API this information:
Code:

native log_message(const message[], any:...);
Than i made a second instance of log_message like...
Code:

native log_message_udp(const message[], any:...);
...and changed any log_message within the script to log_message_udp.

So for now, i think i need to modify the part with any: but i dont know how.

The documentation doesn't help me a lot at this point.

Any hints?

Thanks in advance!

--
Best regards
Alex

Black Rose 01-23-2017 13:14

Re: How can i log something to UDP but not file?
 
"any" is a tag that enables you to supply any tagged argument without getting tag mismatch warnings. For example: CsTeams:v or Float:v.
"..." means you can supply as many arguments as you want. Very common with string formatting functions. In some cases they are also used to leave room for more arguments in the future without giving warnings when using old includes.

Usually when you want to log something you also want to include variables, especially when debugging.

Here's an example:
log_message("Message: %d, %s", random(100), "Hello");

I don't understand what you mean by UDP and I also can't find the function log_message_udp(). Are you saying you want it in the console but not in the log? Then I would suggest server_print().

edon, fast is not always good. I think I edited this post at least 5 times.
Some might call that perfectionism others might call it OCD.
If moderators can see the post edit history I'm really sorry.

edon1337 01-23-2017 13:15

Re: How can i log something to UDP but not file?
 
In any you write string/float/integer 's names (Obviously if your print contains one).
Example :

PHP Code:

new name[18];
get_user_name(idname17);

client_print(idprint_chat"Your Name %s"name

Syntax :
client_print(index, type, message[], any)

EDIT : Cmon BlackRose you too fast xd

fysiks 01-23-2017 20:18

Re: How can i log something to UDP but not file?
 
What exactly are you trying to do? Trying to stream a log via UDP is unreliable (since the primary definition of UDP is that it is unreliable).

To implement the formatting, you'll need to look at functions that use vformat(). You'll find many around here that do.


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

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