How to allow one ip use on an NPC

bWolfie

I'm the man
Messages
850
Points
0
Location
Alberta, Midgard
Github
bWolfie
Emulator
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.

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

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

 
Last edited by a moderator:
*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"));

 
default_biggrin.png
 GJ

 
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.

 
Last edited by a moderator:
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.

 
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

 
Back
Top