Help on 'rand' in Query SQL

Jedzkie

The Master of White Spaces
Messages
632
Points
0
Age
33
Location
Philippines
Discord
✪ Jedzkie#0662
IRC Nickname
Jedzkie
Github
Jedzkie
Emulator
Client Version
2016-03-16 RE
hi how can I randomly set cash point to my account using query_sql?

example:

query_sql ("UPDATE `cash` SET `cash_point` = cash_point + rand(100,1000) WHERE `account_id` = '"+getcharid(3)+"'");

if i use the item, this is the error. DB error - Operand should contain 1 column(s)

Thanks!

 
Code:
query_sql ("UPDATE `cash` SET `cash_point` = " + rand(100,1000) + " WHERE `account_id` = " + getcharid(3));
 
query_sql ("UPDATE `cash` SET `cash_point` = " + rand(100,1000) + " WHERE `account_id` = " + getcharid(3));
please note that it will just change the current (entire) value to a random amount, instead of increasing it

 
Well, he did say "randomly set", not "randomly increase", thus I changed it accordingly
default_ohmy.png


 
query_sql ("UPDATE `cash` SET `cash_point` = " + rand(100,1000) + " WHERE `account_id` = " + getcharid(3));
please note that it will just change the current (entire) value to a random amount, instead of increasing it
actually you're right, i forgot to say that randomly increase, but i already fixed it. Thanks BTW

Well, he did say "randomly set", not "randomly increase", thus I changed it accordingly
default_ohmy.png
Hi Garr! thanks for the quick response, how about a message to tell how much Points you get?

Edit:

NvM I figured it out the message of how many points you get, but I want to add another message that tells what is the total points in your account.

example: query_sql("SELECT `cash_point` FROM `cash` WHERE `account_id` = "+getcharid(3));

is this right? i have a error message after executing this script. 'script:query_sql: Too many columns. discarding last 1 columns.'

 
Last edited by a moderator:
@@Frost When you run a SELECT query, you must pass variables to store the returned data.

Code:
query_sql("SELECT `cash_point` FROM `cash` WHERE `account_id` = "+getcharid(3), .@newCash);dispbottom "Now you have " + .@newCash;
 
@@Frost When you run a SELECT query, you must pass variables to store the returned data.

query_sql("SELECT `cash_point` FROM `cash` WHERE `account_id` = "+getcharid(3), .@newCash);dispbottom "Now you have " + .@newCash;
Thanks!

 
Back
Top