AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can anybody help me with my plugin? (https://forums.alliedmods.net/showthread.php?t=167781)

fantarn 09-20-2011 03:46

Can anybody help me with my plugin?
 
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", "IP:PORT")
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

e12harry 09-20-2011 04:43

Re: Can anybody help me with my plugin?
 
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)

fantarn 09-20-2011 04:54

Re: Can anybody help me with my plugin?
 
Thanks :)

Doc-Holiday 09-20-2011 05:04

Re: Can anybody help me with my plugin?
 
instead of hardcoding the 31 in get_pcvar_string use charsmax(szIp)

fantarn 09-20-2011 05:23

Re: Can anybody help me with my plugin?
 
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

Doc-Holiday 09-20-2011 05:37

Re: Can anybody help me with my plugin?
 
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]

e12harry 09-20-2011 05:47

Re: Can anybody help me with my plugin?
 
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)



Doc-Holiday 09-20-2011 05:50

Re: Can anybody help me with my plugin?
 
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

e12harry 09-20-2011 05:58

Re: Can anybody help me with my plugin?
 
!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

fantarn 09-20-2011 06:07

Re: Can anybody help me with my plugin?
 
Thanks it works now :)


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

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