Jump to content


Photo

How to allow one ip use on an NPC


Best Answer True Zeal, 20 April 2017 - 07:35 AM

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.

Go to the full post


  • Please log in to reply
6 replies to this topic

#1 True Zeal

True Zeal

    Advanced Member

  • Members
  • PipPipPip
  • 411 posts
  • LocationAlberta
  • Emulator:Hercules

Posted 19 April 2017 - 12:16 PM

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.


I ask a lot of questions. Prepare to be frustrated.


#2 Habilis

Habilis

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • IRC Nickname:Habilis
  • LocationMontreal, Canada
  • Emulator:Hercules

Posted 19 April 2017 - 12:34 PM

It is not that complicated to change IP, just sayin...
So, don't do serious stuff depending upon that logic...

Edited by Habilis, 19 April 2017 - 12:35 PM.

Doing stuff |||||||||||||||||||||||||||||||||||||||||||||||||| 5% done

 

2017 Hercules Install GUIDE By Habilis


#3 Ridley

Ridley

    Advanced Member

  • Script Developers
  • 355 posts
  • IRC Nickname:Ridley
  • LocationGermany
  • Emulator:Hercules
  • Github:ridley8819

Posted 19 April 2017 - 04:31 PM

*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"));
 


#4 jonel

jonel

    Member

  • Members
  • PipPip
  • 17 posts
  • Emulator:Hercules
  • Github:1990

Posted 20 April 2017 - 02:44 AM

:D GJ





#5 True Zeal

True Zeal

    Advanced Member

  • Members
  • PipPipPip
  • 411 posts
  • LocationAlberta
  • Emulator:Hercules

Posted 20 April 2017 - 07:35 AM   Best Answer

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, 20 April 2017 - 10:58 AM.

I ask a lot of questions. Prepare to be frustrated.


#6 Like it~*

Like it~*

    Advanced Member

  • Members
  • PipPipPip
  • 98 posts

Posted 22 April 2017 - 12:30 AM

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/...er-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.



#7 True Zeal

True Zeal

    Advanced Member

  • Members
  • PipPipPip
  • 411 posts
  • LocationAlberta
  • Emulator:Hercules

Posted 22 April 2017 - 01:40 PM

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/...er-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


I ask a lot of questions. Prepare to be frustrated.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


This topic has been visited by 35 user(s)