AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Licensed Class (https://forums.alliedmods.net/showthread.php?t=183373)

CryWolf 04-21-2012 04:21

Licensed Class
 
Hi Allied Modders community, i whanna create a plugin only for my own IP class, i seem to succeded with IP but with class doesn't work at all here is my code:
Code:

#include < amxmodx >
#include < amxmisc >

// Licensed IP
#define LICENSED_CLASS_IP "84.247."

public plugin_init() {
    register_plugin("licensed class", "0.1", "wolfy");
   
    new LICENSED_IP[20];
    get_user_ip(0, LICENSED_IP, 21, 1);
   
    if(!containi(LICENSED_IP, LICENSED_CLASS_IP))
    {
        server_print("You have no licensed class ip, the plugin will not work.")
        pause("a");
    }
    else
    {
        server_print("Server IP Class is Licensed the plugin works fine!")
    }
}

it doesn't whanna work, what can i do ?

Thanks

claudiuhks 04-21-2012 04:32

Re: Licensed Class
 
amxmisc is not required. containi function returns a value which is not equal with -1 on match. get_user_ip with first argument zero will return net_address command value. I don't think you can block one plugin. If I start my server with command net_address set on 84.247. your plugin will accept me.

CryWolf 04-21-2012 04:56

Re: Licensed Class
 
I know that, but still i whanna make it work, can you give me an example of how would you do it, if you whant or anyone else, i'll really apreciated

Thank you.

claudiuhks 04-21-2012 05:11

Re: Licensed Class
 
PHP Code:

#include < amxmodx >

// Licensed IP
#define LICENSED_CLASS_IP "84.247."

public plugin_init() {
    new 
LICENSED_IP[24];
    
get_user_ip(0LICENSED_IP231);
    
    if( !( -
!= containi(LICENSED_IPLICENSED_CLASS_IP)) )
       
set_fail_state("You have no licensed class ip, the plugin will not work.");



CryWolf 04-21-2012 05:26

Re: Licensed Class
 
Thanks claudiuhks :D i shall use it!

BadJoke: nu cred ca sunt permise alte limbi inafara de engleza conform acestei sectiuni, mai ales locatia ta :)) bafta baieti!

CryWolf 04-27-2012 11:45

Re: Licensed Class
 
BUMP:

This metod allows me to use 2 or 3 IP classes in the same plugin ? or i just need to create them separate ?

Thanks

Tirant 04-27-2012 21:03

Re: Licensed Class
 
just use equali

Bugsy 04-28-2012 00:28

Re: Licensed Class
 
PHP Code:

new const LicensedIP[][] = 
{
    
"192.1.",
    
"191.13.",
    
"212.212.",
    
"33.3.",
    
"75.55.",
    
"121.88."
}
    
public 
plugin_init() 
{
    if( !
CheckServerIP() )
    {
        
server_print("You have no licensed class ip, the plugin will not work.")
        
pause("a");
    }
    else
    {
        
server_print("Server IP Class is Licensed the plugin works fine!")
    }
}

bool:CheckServerIP()
{
    new 
szIP16 ] , bool:bFound;
    
    
get_user_ipszIP charsmaxszIP ) , );
    
    for ( new 
sizeofLicensedIP ) ; i++ )
    {
        if ( 
equalszIP LicensedIP] , strlenLicensedIP] ) ) )
        {
            
bFound true;
            break;
        }
    }
    
    return 
bFound;



CryWolf 04-28-2012 03:03

Re: Licensed Class
 
Thank you Bugsy, verry much!


All times are GMT -4. The time now is 07:48.

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