Raised This Month: $ Target: $400
 0% 

Can anybody help me with my plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fantarn
Member
Join Date: Feb 2011
Old 09-20-2011 , 03:46   Can anybody help me with my plugin?
Reply With Quote #1

Hello i made a plugin but i cant solve this problem with the cvar.

Quote:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "IP show"
#define VERSION "1.0"
#define AUTHOR "Fantarn"


public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /ip", "serverip")

}

public serverip(id)
{
client_print(0, print_chat, "The Server ip is 109.72.82.22:27022")
}
global:
new szIp
plugin_init
IP = register_cvar("amx_serverip", "IPORT")
new szIp[32]
get_pcvar_string(%s, szIp, charsmax(szIp))
The plugin does if you say /ip you see the server's ip but i want that you can change the ip/port that it says with a cvar.
some friends helped me with this but i still dont know how to fix this..
im new to scripting.

Thanks
fantarn is offline
e12harry
Member
Join Date: Apr 2010
Old 09-20-2011 , 04:43   Re: Can anybody help me with my plugin?
Reply With Quote #2

Propably you don't need cvar.
See this thread: http://forums.alliedmods.net/showthread.php?t=116285
If you have to use cvar:

Code:
#include <amxmodx>

#define PLUGIN "IP show"
#define VERSION "1.0"
#define AUTHOR "Fantarn"

new gCvarServerIp;
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /ip", "serverip")
    gCvarServerIp = register_cvar("amx_serverip","109.72.82.22:27022")
}

public serverip(id)
{
    new szIp[32]
    get_pcvar_string(gCvarServerIp, szIp, 31)
    client_print(0, print_chat, "The Server ip is %s", szIp)
}
Note that if any player will say /ip, all players will see the ip of the server.
If you want to show ip to only one player change
Code:
client_print(0, print_chat, "The Server ip is %s", szIp)
to
Code:
client_print(id, print_chat, "The Server ip is %s", szIp)
e12harry is offline
fantarn
Member
Join Date: Feb 2011
Old 09-20-2011 , 04:54   Re: Can anybody help me with my plugin?
Reply With Quote #3

Thanks
fantarn is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-20-2011 , 05:04   Re: Can anybody help me with my plugin?
Reply With Quote #4

instead of hardcoding the 31 in get_pcvar_string use charsmax(szIp)
Doc-Holiday is offline
fantarn
Member
Join Date: Feb 2011
Old 09-20-2011 , 05:23   Re: Can anybody help me with my plugin?
Reply With Quote #5

Ok my code so far is :

Quote:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <colorchat>

#define PLUGIN "ShowIP"
#define VERSION "1.0"
#define AUTHOR "Fantarn"

new gCvarServerIp;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /ip", "serverip")
gCvarServerIp = register_cvar("amx_serverip","109.72.82.22:27 022")
}

public serverip(id)
{
new szIp[32]
get_pcvar_string(gCvarServerIp, szIp, 31)
client_print(0, print_chat, "The Server ip is %s", szIp)
}
i need to know 2 more things.
1. How do i make the text "The server ip is" Green using Colorchat.
2. How do i make that it automatically says the server's ip without Cvar.

Thanks
fantarn is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-20-2011 , 05:37   Re: Can anybody help me with my plugin?
Reply With Quote #6

use [php][/php] tags....

PHP Code:
get_pcvar_string(gCvarServerIpszIpcharsmax(szIp)) <--- Easier in the long run 
as for the last part
PHP Code:
new szServerIP[32]
get_user_ip(0szServerIPcharsmax(szServerIP));
client_print(idprint_chat"The Server ip is %s"szServerIP); 
[/php]
Doc-Holiday is offline
e12harry
Member
Join Date: Apr 2010
Old 09-20-2011 , 05:47   Re: Can anybody help me with my plugin?
Reply With Quote #7

You can try:
PHP Code:
#include <amxmodx>
#include <colorChat>

#define PLUGIN "IP show"
#define VERSION "1.0"
#define AUTHOR "Fantarn"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /ip""serverip")
}

public 
serverip(id)
{
    new 
szIP32 ]
    
get_user_ip( !is_dedicated_server( ), szIPcharsmax(szIP) )
    
    
ColorChat(0GREEN"The Server ip is %s"szIP)

e12harry is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-20-2011 , 05:50   Re: Can anybody help me with my plugin?
Reply With Quote #8

Use the one i posted i was informed that !is_dedicated_server returns a 1 if its not a dedicated server which will not give you the servers ip

Last edited by Doc-Holiday; 09-20-2011 at 05:54.
Doc-Holiday is offline
e12harry
Member
Join Date: Apr 2010
Old 09-20-2011 , 05:58   Re: Can anybody help me with my plugin?
Reply With Quote #9

!is_dedicated_server has something to do with sv_lan 0
Propably if it is dedicated server than server is 0 othervise server is 1
e12harry is offline
fantarn
Member
Join Date: Feb 2011
Old 09-20-2011 , 06:07   Re: Can anybody help me with my plugin?
Reply With Quote #10

Thanks it works now
fantarn is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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