AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ok can someone explain this line of code. (https://forums.alliedmods.net/showthread.php?t=12763)

teame06 04-24-2005 04:58

ok can someone explain this line of code.
 
Quote:

console_print(id,"%2d %-16.15s %-20s %-8d %-4.3s %-4.3s %s", players[a],name,authid,
get_user_userid(players[a]),(flags&ADMIN_IMMUNITY)?lYes:lNo,
(flags&ADMIN_RESERVATION)?lYes:lNo,sflags)
Quote:

Originally Posted by This is the part of the code i want to be explained.
"%2d %-16.15s %-20s %-8d %-4.3s %-4.3s %s"

I see %s %d %s %s %s, i understand that but i don't under -20 -8 -4.3 -4.3 is that suppose to be tab spacing when it printed?

I want to know because i'm writing a simple script for my server so i can just see people ip.

xeroblood 04-24-2005 12:18

Yes, they are basically place holders..

%-23.45f for example, means that the output will be left-aligned (the minus sign), there will be space for 16 numbers before the decimal (if the number was 23.45 then there would be 14 spaces in front of the number 23) and finally the .15 means that the output may have upto 15 precision points after the decimal (which sometimes gets padded with zeros, not sure if that happens in Small tho or not)

So 23.45 may look something like:

_ _ _ _ _ _ _ _ _ _ _ _ _ _23.450000000000000


At least that's what I remember from C/C++...

But what is strange is that they have the modifiers for a string (%s) which I have never seen done before..


All times are GMT -4. The time now is 16:38.

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