Jump to content
  • 0

How to set can't input same values in NPC?


Question

Posted

Hi rA community!

I want to ask how to set an input NPC that can't duplicate same values (number only) and write it on sql?

For example player A already input number 10, then when player B tries to input number 10, NPC can't proceed it.

Thank you!

2 answers to this question

Recommended Posts

  • 0
Posted (edited)
mes "Pick your number!";
next;
input(.@number);
.@rowCount = query_sql("SELECT `number` FROM numberdb WHERE `number` = " + .@number + ";");
if(.@rowCount == 1) {
    mes "This number is already used. Try again.";
    close;
}
query_sql("INSERT INTO numberdb (`number`) VALUES (" + .@number + ");");

 

Edited by Winterfox
  • Upvote 1
  • 0
Posted
On 7/29/2023 at 11:47 PM, Winterfox said:
mes "Pick your number!";
next;
input(.@number);
.@rowCount = query_sql("SELECT `number` FROM numberdb WHERE `number` = " + .@number + ";");
if(.@rowCount == 1) {
    mes "This number is already used. Try again.";
    close;
}
query_sql("INSERT INTO numberdb (`number`) VALUES (" + .@number + ");");

 

omg that's works like a charm! thank you! 😄

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...