Jump to content
  • 0

Is it possible to check onminute with this script? (SQL_Query)


mightyryan

Question


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  69
  • Reputation:   2
  • Joined:  10/03/12
  • Last Seen:  

Hi! is this possible to check onminute at the second script, I would like it to check every 15/30mins cause other players were able to bypass the first script.

(I don't want to use mac_ip)

 

I tried this script but it has an error of:

[Error]: script_rid2sd: fatal error ! player not attached!
[Debug]: Function: strcharinfo (1 parameter):
[Debug]: Data: number value=0
[Debug]: Source (NPC): Only2perIPs (invisible/not on a map)

 

Advance thanks

-	script	Only2perIP	-1,{

OnPCLoginEvent:

	if (getgmlevel() >= 99) end;
    set .@name$, strcharinfo(0);
    if (query_sql("SELECT login.account_id FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_ip=(SELECT last_ip FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1", .@account_id) > 2) {
        announce "Sorry, only 2 accounts per PC can be logged in at a time.", bc_self;
        sleep 1000;
        atcommand "@kick " + .@name$;
    }
    end;
}


-	script	Only2perIPs	-1,{

OnMinute15:
OnMinute30:
OnMinute40:
OnMinute55:
StartEvent:
    set .@name$, strcharinfo(0);
    if (query_sql("SELECT login.account_id FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_ip=(SELECT last_ip FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1", .@account_id) > 2) {
        announce "Sorry, only 2 accounts per PC can be logged in at a time.", bc_self;
        sleep 1000;
        atcommand "@kick " + .@name$;
    }
    end;
}
Edited by mightyryan
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

I think I know the problem:

Exchange

sleep 1000;

with

sleep2 1000;

 

Reason:

sleep detaches the players rid from the script while sleep2 keeps it.

 

You can read that at the doc/script_commands.txt at line 6093 :P

 

Well another problem is at the 2nd script, that there is no player attached.

One way I can think of is to search for the same IP's which are online (like you did in your script) and select the account of the 3rd one.

1. Option:

Then you attach that one by using attachrid(<account id>); and then your code.

2. Option:

Instead of "announce" you can use "message "<Character Name>","Message"; "

For the character name you can use "strcharinfo(0,<Char ID>);".

 

I hope I didn't miss anything and hope it works.

To be honest I'm still bad with that "LEFT JOIN" stuff at SQL, so I really can't follow that.

Well I know how it works, but never got to use it.

 

Regards,

Chris

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  69
  • Reputation:   2
  • Joined:  10/03/12
  • Last Seen:  

Hi! thank you for your reply, the first one actually works fine. The error shows from the 2nd script/last script.

 

I don't understand the first option, should I edit the whole  query_sql for the second script? can you please elaborate it. thanks

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

Hi! thank you for your reply, the first one actually works fine. The error shows from the 2nd script/last script.

I don't understand the first option, should I edit the whole query_sql for the second script? can you please elaborate it. thanks

Question why is the 2nd script even needed, if you login and it checks right then and kicks you if your already online, then no player can possibly be online 15 mins later right?

As for why it doesn't work, you never attached a character to the 2nd one. So its not going to be able to kick anyone.

After onstartevent you should attach a random character or something.

Edited by Stolao
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  69
  • Reputation:   2
  • Joined:  10/03/12
  • Last Seen:  

 

Hi! thank you for your reply, the first one actually works fine. The error shows from the 2nd script/last script.

I don't understand the first option, should I edit the whole query_sql for the second script? can you please elaborate it. thanks

Question why is the 2nd script even needed, if you login and it checks right then and kicks you if your already online, then no player can possibly be online 15 mins later right?

As for why it doesn't work, you never attached a character to the 2nd one. So its not going to be able to kick anyone.

After onstartevent you should attach a random character or something.

 

You a the point, maybe i'll just remove the 2nd script then. Thanks for all your help guys :)

Edited by mightyryan
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...