AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Announce + Client Information (https://forums.alliedmods.net/showthread.php?t=24727)

broertje 03-01-2006 16:38

Announce + Client Information
 
My first plugin,i didn't tested it out,but i wan't some comments ...
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Announce + Client info" #define VERSION "1.0" #define AUTHOR "Broertje" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say /myinfo","mi",ADMIN_ALL,"Shows Clients Information") } public client_putinserver(id)     {     new name[33]     get_user_name(id,name,32)     if(is_user_admin(id))         {         set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 12.0)         show_hudmessage(0, "%s has joined the n00bs",name)                   return PLUGIN_HANDLED     }           set_hudmessage(85, 255, 0, 0.00, -1.0, 0, 6.0, 12.0)     show_hudmessage(0,"Welcome %s. Have fun here!",name)           return PLUGIN_HANDLED } public client_disconnect(id)     {     new name[33]     get_user_name(id,name,32)     if(is_user_admin(id))         {         set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 12.0)         show_hudmessage(0, "%s has left the house",name)                   return PLUGIN_HANDLED     }           set_hudmessage(85, 255, 0, 0.00, -1.0, 0, 6.0, 12.0)     show_hudmessage(0,"%s has left. Goodbye!",name)           return PLUGIN_HANDLED } public mi(id)     {       new ping, loss, curtime     get_user_ping(id,ping, loss)       get_user_time(id,curtime)       if(is_user_alive(id))           if(is_user_connected(id))           {           client_print(id, print_chat, "Your ping is: %s , You've been playing: %s on server.",ping,curtime)       }    }

Des12 03-01-2006 17:42

Re: Announce + Client Information
 
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Announce + Client info" #define VERSION "1.0" #define AUTHOR "Broertje" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say /myinfo","mi",ADMIN_ALL,"Shows Clients Information") } public client_putinserver(id)     {     new name[33]     get_user_name(id,name,32)     if(is_user_admin(id))         {         set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 12.0)         show_hudmessage(0, "%s has joined the n00bs",name)                   return PLUGIN_HANDLED     }           set_hudmessage(85, 255, 0, 0.00, -1.0, 0, 6.0, 12.0)     show_hudmessage(0,"Welcome %s. Have fun here!",name)           return PLUGIN_HANDLED } public client_disconnect(id)     {     new name[33]     get_user_name(id,name,32)     if(is_user_admin(id))         {         set_hudmessage(255, 0, 0, -1.0, 0.0, 0, 6.0, 12.0)         show_hudmessage(0, "%s has left the house",name)                   return PLUGIN_HANDLED     }           set_hudmessage(85, 255, 0, 0.00, -1.0, 0, 6.0, 12.0)     show_hudmessage(0,"%s has left. Goodbye!",name)           return PLUGIN_HANDLED } public mi(id)     {       new ping, loss, curtime     get_user_ping(id,ping, loss)       get_user_time(id,curtime)       if(is_user_alive(id))           if(is_user_connected(id))           {           client_print(id, print_chat, "Your ping is: %i , You've been playing: %i on server.",ping,curtime)       }    }

broertje 03-02-2006 06:27

errr...
Yes?

mysticssjgoku4 03-02-2006 20:18

Quote:

Originally Posted by broertje
errr...
Yes?

He fixed your variables in the strings at the end from %s to %i.

broertje 03-03-2006 09:56

Oh thx,can u explain why it need to be %i and not %s

DataMatrix 03-03-2006 09:59

%i = Integer (Number)
%s = String (Word)
%d = Delimiter (minus, plus, etc. I think)

I think that's what they are.

PM 03-03-2006 10:44

Those are printf-like format specifiers; google for printf to know more (although I think the new optimized format in the upcoming AMXx release doesn't support all of the format type characters)

Anyway:

%d or %i -> Prints a signed number in base 10 (decimal)
%u -> Prints an unsigned (=always positive) number in base 10
%x -> Prints an unsigned number in base 16 (hexadecimal)
%c -> Prints a character (say you'd pass 'a' as parameter, then it would print an a)
%f -> Prints a decimal floating point number (something like 3.14)
%g is used as %f; I always use %f because I don't know the difference.
%s -> Prints a string (like "hello pm" )

There's also flags, width and precision; like %02d will alway output 2 digits at least; if it would print only one digit a 0 will be appended on the left side.


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

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