AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   match for IP (https://forums.alliedmods.net/showthread.php?t=88897)

Salmus 03-30-2009 09:15

match for IP
 
Hello !

I'm trying to create a plugin for my community only, and I want to match for IP (listen) to protect my work against leechers or non-community members.

I'm thinking about:

new serverip;
serverip = get_cvar_pointer(ip);


But if I echo it, server dies ... I'm thinking about something like (php code)


$mainclass = "66.66.66";
$serverip = get_cvar_pointer(ip);

$serveripEXPLODE = explode(".", $serverip");
$serveripDONE = $serveripEXPLODE[0] . "." . $serveripEXPLODE[1] . "." . $serveripEXPLODE[2];

if(!$serveripDONE==$serverip) {
server_cmd("quit");
}
else {
[...]
}


So, if user doesn't have system CVAR IP containing "66.66.66" then it will kill the server

Thank you in advance !

iNspiratioN 03-30-2009 09:49

Re: match for IP
 
This is AMXX Scripting Forum not PHP isnt it?

Salmus 03-30-2009 10:06

Re: match for IP
 
You're right, but ... trying to learn ...


I did something like this:

#include <amxmodx>
new serverip[64];
[...]
get_cvar_string("ip",serverip,63);
[...]
client_print(id, "ServerIPCVAR %s", serverip);

but:
home/groups/amxmodx/tmp3/text7p4iyD.sma(44) : error 035: argument type mismatch (argument 2) ...

BOYSplayCS 03-30-2009 11:19

Re: match for IP
 
Display the whole code.

Also, get_cvar_string("ip",serverip,63)

Why do you wrap ip in quotes?

:/

fysiks 03-30-2009 21:24

Re: match for IP
 
Quote:

Originally Posted by BOYSplayCS (Post 793227)
Display the whole code.

Also, get_cvar_string("ip",serverip,63)

Why do you wrap ip in quotes?

:/

Because it's a cvar name and not a pointer.

BOYSplayCS 03-31-2009 06:36

Re: match for IP
 
Ah, didn't notice that at first glance. Thanks for the explanation.

Styles 03-31-2009 13:29

Re: match for IP
 
haha you can hex that out in a second sorry :-/

hleV 03-31-2009 14:04

Re: match for IP
 
Quote:

Originally Posted by Salmus (Post 793180)
You're right, but ... trying to learn ...


I did something like this:

#include <amxmodx>
new serverip[64];
[...]
get_cvar_string("ip",serverip,63);
[...]
client_print(id, "ServerIPCVAR %s", serverip);

but:
home/groups/amxmodx/tmp3/text7p4iyD.sma(44) : error 035: argument type mismatch (argument 2) ...

You forgot to specify the type of print in the 2nd argument. The string is the 3rd argument.
Code:
enum {         print_notify = 1,         print_console,         print_chat,         print_center, };   native client_print(index,type,const message[],any:...);

Speed! 03-31-2009 14:29

Re: match for IP
 
Quote:

Originally Posted by hleV (Post 794136)
You forgot to specify the type of print in the 2nd argument. The string is the 3rd argument.
Code:
enum {         print_notify = 1,         print_console,         print_chat,         print_center, };   native client_print(index,type,const message[],any:...);

offtopic: which is print_notify :\ I've never saw it LOL

Exolent[jNr] 03-31-2009 14:37

Re: match for IP
 
If you are using "developer 1", you will notice that your console is shown in the top left of your screen.
print_notify prints messages in that same section (not sure if it goes to your console, but I'd assume it does).


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

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