Checking If Server Variable Not Exists
#1

Hi,i made a function which automatically adds tag to server hostname if its hosted on ip *,but there is a problem that if the variable "bind" is not in the server.cfg,it adds the server tag in that case too,anyone knows a fix for that?

Код:
				
if(!strcmp(GetServerIP(), "***.***.***.***", false))
{
    SendRconCommand("hostname "HOSTNAME" "HOSTNAME_TAG"");
}
else
{
    SendRconCommand("hostname "HOSTNAME"");
}
Reply
#2

Anyone :/
Reply
#3

Try That forward ChangeHostNameUpdate();
public ChangeHostnameUpdate()
{
SetTimer("hostname",3000,1);
(1000 = 100 second)
return 1;
}
new var = random(4);
switch (var)
{
case 0: SendRconCommand("hostname [Hostname]");
case 1: SendRconCommand("hostname [Hostname]");
case 2: SendRconCommand("hostname [Hostname]");
}
Reply
#4

try this

PHP код:
                
if(!strcmp(GetServerIP(), "***.***.***.***"false))
{
new 
hName[100];
strint(hName,HOSTNAME_TAG,sizeof(HOSTNAME));
    
SendRconCommand("hostname hName");
}
else
{
    
SendRconCommand("hostname "HOSTNAME"");

i don't know if this will work repley if it did
Reply
#5

or you can do
PHP код:

#define HOSTNAME1 "hostname ihfqzfmlqsdjflqhsdfl "
#define HOSTNAME2 "hostname ksdhfklqdhflqkhfkhk [TAAG]"
if(!strcmp(GetServerIP(), "***.***.***.***"false))
{
    
SendRconCommand(HOSTNAME1);
}
else
{
    
SendRconCommand(HOSTNAME2);

Reply
#6

The tag is working properly,but im asking to remove the tag if the "bind" is not defined in server.cfg
Reply
#7

pawn Код:
new string[16];
GetConsoleVarAsString("bind", string, sizeof(string));
if(string[0] == EOS)
{
    // There is no 'bind' or 'bind' is null.
}
else
{
    // There is a 'bind' in server.cfg (or has been set in console)
}
Reply
#8

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
new string[16];
GetConsoleVarAsString("bind", string, sizeof(string));
if(string[0] == EOS)
{
    // There is no 'bind' or 'bind' is null.
}
else
{
    // There is a 'bind' in server.cfg (or has been set in console)
}
Can i use GetServerVarAsString?
Reply
#9

Depends what version of SA-MP you're using.

https://sampwiki.blast.hk/wiki/GetServerVarAsString

Quote:

This function, as of 0.3.7 R2, is deprecated. Please see GetConsoleVarAsString

Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)