• 0
Myriad

How to allow one ip use on an NPC

Question

Hello!

 

I'm guessing this has been done time and time again, but my search skills are newbie at best.

I have this particular NPC which I only want to be allowed to use once per IP, and then restricted from then on.

 

E.g.

Player A buys Jellopy from NPC on Account 1.

Player A logs out, logs into Account 2.

Player A is denied buying Jellopy from NPC on Account 2.

 

It would be as if the NPC took a record of the IP, and then once that IP was in the system, anyone carrying the IP could not buy the jellopy again.

Share this post


Link to post
Share on other sites

6 answers to this question

  • 0

Posted (edited)

Yes i understand all that. I want to make it so the NPC takes a record of their IP and block usage of that npc afterwards.

 

I did some searching and found a guild pack script to use in what I'm after. From this thread: https://rathena.org/board/topic/94294-guild-pack-npc-giver-help-please/

 

1. First script needs label to call in callsub:

 

S_Check_IP:
    return query_sql("SELECT 1 FROM `guildpack` join login on login.`last_ip` = `guildpack`.`last_ip` where login.account_id = "+ getcharid(CHAR_ID_ACCOUNT), .@tmp);

 

2. Then define IP:

 

.@myip$ = getcharip();

 

3. Return true through callsub if IP exists in table:

 

    if (callsub(S_Check_IP))
    {
        mes .@name$;
        mes("^616D7EIt seems I have already recorded your IP Address: ^ff0000" + .@myip$ + "^000000.");
        close;
    }

 

4. If does not exist, enter new entry to previously created table:

 

query_sql("INSERT INTO `guildpack` VALUES (NULL," + getcharid(CHAR_ID_ACCOUNT) + ",'" + escape_sql(strcharinfo(PC_NAME)) + "','" + .@myip$ + "')");

 

All in all it looks something like this: https://pastebin.com/Lk8MHMBg

 

This can be used for get_unique_id() too if you have gepard shield.

 

My intention was to use this in a Lottery script, so people could only purchase one ticket per week.

After each lottery draw, the table would be truncated so everybody can buy tickets again.

Edited by True Zeal

Share this post


Link to post
Share on other sites
  • 0

Posted (edited)

It is not that complicated to change IP, just sayin...

So, don't do serious stuff depending upon that logic...

Edited by Habilis

Share this post


Link to post
Share on other sites
  • 0


*getcharip({"<character name>"|<account id>|<char id>})

 

 

This function will return the IP address of the invoking character, or, if 

a player is specified, of that character. A blank string is returned if no 

player is attached.

 

 

Examples:

 

 

// Outputs IP address of attached player.

    mes("Your IP: " + getcharip());

 

 

// Outputs IP address of character "Silver".

    mes("Silver's IP: " + getcharip("Silver"));

 

Share this post


Link to post
Share on other sites
  • 0

Yes i understand all that. I want to make it so the NPC takes a record of their IP and block usage of that npc afterwards.

 

I did some searching and found a guild pack script to use in what I'm after. From this thread: https://rathena.org/board/topic/94294-guild-pack-npc-giver-help-please/

 

1. First script needs label to call in callsub:

 

S_Check_IP:
    return query_sql("SELECT 1 FROM `guildpack` join login on login.`last_ip` = `guildpack`.`last_ip` where login.account_id = "+ getcharid(CHAR_ID_ACCOUNT), .@tmp);

 

2. Then define IP:

 

.@myip$ = getcharip();

 

3. Return true through callsub if IP exists in table:

 

    if (callsub(S_Check_IP))
    {
        mes .@name$;
        mes("^616D7EIt seems I have already recorded your IP Address: ^ff0000" + .@myip$ + "^000000.");
        close;
    }

 

4. If does not exist, enter new entry to previously created table:

 

query_sql("INSERT INTO `guildpack` VALUES (NULL," + getcharid(CHAR_ID_ACCOUNT) + ",'" + escape_sql(strcharinfo(PC_NAME)) + "','" + .@myip$ + "')");

 

All in all it looks something like this: https://pastebin.com/Lk8MHMBg

 

This can be used for get_unique_id() too if you have gepard shield.

 

My intention was to use this in a Lottery script, so people could only purchase one ticket per week.

After each lottery draw, the table would be truncated so everybody can buy tickets again.

 

To put in any script, would I just need to change the storage table, 'guildpack'? Give me an example, please.

Share this post


Link to post
Share on other sites
  • 0

 

Yes i understand all that. I want to make it so the NPC takes a record of their IP and block usage of that npc afterwards.

 

I did some searching and found a guild pack script to use in what I'm after. From this thread: https://rathena.org/board/topic/94294-guild-pack-npc-giver-help-please/

 

1. First script needs label to call in callsub:

 

S_Check_IP:
    return query_sql("SELECT 1 FROM `guildpack` join login on login.`last_ip` = `guildpack`.`last_ip` where login.account_id = "+ getcharid(CHAR_ID_ACCOUNT), .@tmp);

 

2. Then define IP:

 

.@myip$ = getcharip();

 

3. Return true through callsub if IP exists in table:

 

    if (callsub(S_Check_IP))
    {
        mes .@name$;
        mes("^616D7EIt seems I have already recorded your IP Address: ^ff0000" + .@myip$ + "^000000.");
        close;
    }

 

4. If does not exist, enter new entry to previously created table:

 

query_sql("INSERT INTO `guildpack` VALUES (NULL," + getcharid(CHAR_ID_ACCOUNT) + ",'" + escape_sql(strcharinfo(PC_NAME)) + "','" + .@myip$ + "')");

 

All in all it looks something like this: https://pastebin.com/Lk8MHMBg

 

This can be used for get_unique_id() too if you have gepard shield.

 

My intention was to use this in a Lottery script, so people could only purchase one ticket per week.

After each lottery draw, the table would be truncated so everybody can buy tickets again.

 

To put in any script, would I just need to change the storage table, 'guildpack'? Give me an example, please.

 

Yeah. In mine, I changed guildpack to lottery

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now