AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved]Simple code to detect country (https://forums.alliedmods.net/showthread.php?t=60554)

eXist 09-06-2007 22:15

[Solved]Simple code to detect country
 
*EDIT* I know there are a lot of plugins that do similar things, but I decided to write my own because I disliked many of the current ones. Also, it helps me learn small :(.

Still learning, but I'm working on code to detect, then display a users country based on say input from a user. It is just for fun, but I would like to get it functioning.

For example: A user types '/country playername' in all chat, then I want it to display the user country to everyone. I guess I'm still retarded cause I can't get it to work :(.

Code:
#include <amxmodx> #include <amxmisc> #include <geoip> public plugin_init() {     register_plugin("Show Country","1.0","eXist`")     register_clcmd("say /country","showCountry",0,"Shows a users Country") } public showCountry(id) {     //Checks for flags m or s :: I know its weird, don't ask :D.     if((get_user_flags(id) & ADMIN_LEVEL_A) || (get_user_flags(id) & ADMIN_LEVEL_G)){         new args[128], name[33], target, userip[17], usercountry[46], msg[128]         read_argv(2,args,127)                 target = cmd_target(id,args,2)                 get_user_name(target,name,32)         get_user_ip(target,userip,16,1)         geoip_country(userip,usercountry,45)                 set_hudmessage(255,255,255,-1.0,0.35,0,6.0,12.0,0.1,0.2,4)         format(msg,127,"%s is from %s",name,usercountry)         show_hudmessage(0,msg)          } }

eXist 09-07-2007 20:54

Re: Simple code to detect country
 
I think I found my problem. It is the read_argv command, it doesn't seem to be reading anything it all.

Is there a different command I should use to read chat, or something will read all the chat, and I can get the part I want?

Arkshine 09-07-2007 20:59

Re: Simple code to detect country
 
You have to add after the reading : remove_quotes( args )

You should debug by yourself. Put a client_print() or whatever and see !

eXist 09-07-2007 23:30

Re: Simple code to detect country
 
Quote:

Originally Posted by arkshine (Post 528645)
You have to add after the reading : remove_quotes( args )

You should debug by yourself. Put a client_print() or whatever and see !

I went through and debugged it all with client_print() before you posted this :D. Well yeah, I have it working at 100 %, but thanks for replying.

Everything has been fixed.

X-Script 09-07-2007 23:34

Re: [Solved]Simple code to detect country
 
Since when could you read a print_chat?


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

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