Locking a gamemode [+REP]
#1

Hello guys,
I'd like to know how I can restrict a gamemode to a praticular server by using it's IP.
I mean, how can I get it's IP and make sure it'll run on the very same IP and not any other IPs.
OnGameModeInit()
{
// get the server's IP
// if the server's IP is different than X then exit
}


+REPing the helper
Reply
#2

Fairly it has no use as you can simply just edit it in the script if it would be leaked for example.
Reply
#3

Quote:
Originally Posted by Spydah
View Post
Fairly it has no use as you can simply just edit it in the script if it would be leaked for example.
I'm handing of the AMX version and I'd like to prevent possible leaks and 'pass-aways'.
Wouldn't it be helpful in these cases?
Reply
#4

Don't think there's such a way, handing out your script to others is basically asking for them to use it.
Reply
#5

If you have to physically prevent your script from being used elsewhere, you're doing it wrong. Don't use untrusted hosts, don't give the script to friends, don't do anything that may compromise the script.
Reply
#6

There's a reason to why I'm asking this, yet you answer other questions which were not even asked.
Is it or is it not possible to block it ? If so, how?
Reply
#7

I see the point of this, but honestly if you're just handing out .amx then there isn't a point. You can't edit an .amx and you can't convert it back to .pwn - so as far as I can see you're safe
Reply
#8

Quote:
Originally Posted by benjenden
View Post
I see the point of this, but honestly if you're just handing out .amx then there isn't a point. You can't edit an .amx and you can't convert it back to .pwn - so as far as I can see you're safe
It's a very unique gamemode, I don't want people to use it. I'm giving it to someone so he'd host it but I don't want him to post the amx online or something, so what I want is that if he does then no one will be able to use it.
Can you help me do that?
Reply
#9

The only (not even complete) protection is the AntiDeAMX function (which prevents the DeAMX program to decompile your script) - search for it.

All other things (even checking the server IP) can be worked around if the person trying to run it is a bit experienced in C.
For example, if you check the servers IP with a plugin, one can write a plugin which returns the needed IP - The IP can be either brute-forced or decompiled. Even SAMP natives can theoretically be manipulated.

There is no completely safe way to achieve this, you can only prevent non-experienced programmers to break your protection.

Your best option is making sure you give it to trustworthy people.
Reply
#10

Add this somewhere in your script

PHP Code:
stock GetServerIP()
{
    new static, 
sIp[16];
    
GetServerVarAsString("bind"sIpsizeof(sIp));
    return 
sIp;

Add this in your server.cfg
PHP Code:
bind yourserverip 
It will look like this [This is example , just copy "bind yourserverip"
PHP Code:
echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 50
port 7777
hostname SA
-MP 0.3 Server
gamemode0 grandlarc 1
filterscripts gl_actions gl_realtime gl_property gl_mapicon ls_elevator attachments skinchanger vspawner ls_mall ls_beachside
announce 0
chatlogging 0
weburl www
.sa-mp.com
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 0
logtimeformat 
[%H:%M:%S]
language English
bind yourserverip 
Reply
#11

If you know the IP of the server (like getting it through the GetServerIP function posted above), you could compare it and use
PHP Code:
    SendRconCommand("exit"); 
To shutdown the server when the IP doesn't match to the string you hardcoded.

You only need to give the amx file, as this file is your compiled script.
Just don't give your pwn file and you should be safe, they won't be able to edit it.
Reply
#12

But the problem is, everyone can edit the server.cfg
Reply
#13

Why are people so secretive over code? I understand it's yours and you made it but if people shared more code SAMP would have a lot more things being done, and server would have new things to add as it'd open up doors. I don't think it's possible you could come up with alternatives but meh there's no real way of directly doing.
Reply
#14

Quote:
Originally Posted by MicroKyrr
View Post
But the problem is, everyone can edit the server.cfg
If you set bind to a wrong IP (server cfg) the server will not start.
If you leave it empty or set it to localhost the server will shut down due to the code he uses in his script.

So it basically does what it should, it prevents most of the people from running his script on another server.
Reply
#15

Quote:
Originally Posted by NaS
View Post
If you set bind to a wrong IP (server cfg) the server will not start.
If you leave it empty or set it to localhost the server will shut down due to the code he uses in his script.

So it basically does what it should, it prevents most of the people from running his script on another server.
Quote:
Originally Posted by AmigaBlizzard
View Post
If you know the IP of the server (like getting it through the GetServerIP function posted above), you could compare it and use
PHP Code:
    SendRconCommand("exit"); 
To shutdown the server when the IP doesn't match to the string you hardcoded.

You only need to give the amx file, as this file is your compiled script.
Just don't give your pwn file and you should be safe, they won't be able to edit it.
Quote:
Originally Posted by MicroKyrr
View Post
Add this somewhere in your script

PHP Code:
stock GetServerIP()
{
    new static, 
sIp[16];
    
GetServerVarAsString("bind"sIpsizeof(sIp));
    return 
sIp;

Add this in your server.cfg
PHP Code:
bind yourserverip 
It will look like this [This is example , just copy "bind yourserverip"
PHP Code:
echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 50
port 7777
hostname SA
-MP 0.3 Server
gamemode0 grandlarc 1
filterscripts gl_actions gl_realtime gl_property gl_mapicon ls_elevator attachments skinchanger vspawner ls_mall ls_beachside
announce 0
chatlogging 0
weburl www
.sa-mp.com
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 0
logtimeformat 
[%H:%M:%S]
language English
bind yourserverip 
First of all, I'd like the thank the three of you for helping me.
I got a question though. Assuming I did add these codelines into my script, what will happen if he removes/doesn't add the "bind yourserverip" line?
Reply
#16

PHP Code:
    if(!fexist("NOT_LEAKED_SCRIPT.txt"))
    {
        new 
i;
        while(
!= 1)
        {
            for(new 
500> -1o--)
            {
                
printf("STOP STEALING SCRIPTS");
            }
        }
        
SendRconCommand("exit");
    } 
Simply, create a text file named "NOT_LEAKED_SCRIPT" in scriptfiles folder, supposing the guy will steal your amx doesn't know your server files!
Reply
#17

Quote:
Originally Posted by Amit1998
View Post
First of all, I'd like the thank the three of you for helping me.
I got a question though. Assuming I did add these codelines into my script, what will happen if he removes/doesn't add the "bind yourserverip" line?
It is an empty string then, thus it is invalid. Make sure you check the string for its length using strlen().
I'm not sure if it automatically sets to the IP it is running on, but even if that happens it would not be the IP you specified.
Reply
#18

Quote:
Originally Posted by NaS
View Post
It is an empty string then, thus it is invalid. Make sure you check the string for its length using strlen().
I'm not sure if it automatically sets to the IP it is running on, but even if that happens it would not be the IP you specified.
What do you mean?
I'll try re-phrasing myself as I think you didn't quite understand me, or alternatively I wasn't the one to understand you.
Assuming the server.cfg does not contain the line bind yourserverip, what will happen?
Reply
#19

Quote:
Originally Posted by Amit1998
View Post
What do you mean?
I'll try re-phrasing myself as I think you didn't quite understand me, or alternatively I wasn't the one to understand you.
Assuming the server.cfg does not contain the line bind yourserverip, what will happen?
If there's no bind IP in the .cfg, then it's not the same as your IP, so it still wont work.
Etc. if there's a bind it checks if these are the same:
"255.167.12.711" (his ip) doesn't match "122.129.566.762" (your ip)

And if there isn't a bind it will just be empty:
" " doesn't match "122.129.566.762" (your ip)

Just as an example.
Reply
#20

Quote:
Originally Posted by Amit1998
View Post
What do you mean?
I'll try re-phrasing myself as I think you didn't quite understand me, or alternatively I wasn't the one to understand you.
Assuming the server.cfg does not contain the line bind yourserverip, what will happen?
I actually answered your question - Either "bind" will be empty (the variable still exists!) or filled with an invalid IP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)