I was hoping if you could help me, to have the below script work. What I want is create a random generator code "Transaction Code" temporarily, which means only transacting players can see the generated Transaction Code and even 100 players using the script it wont give the same Transaction Code.
prontera,155,155,3 script TESTSTE 92,{
setarray .coupon_code$[0],"A","B","C","D","E","F","G","H","I","J","K","L",
"M","N","O","P","Q","R","S","T","U","V","W","X",
"Y","Z","0","1","2","3","4","5","6","7","8","9";
set .@new_transaction$, "";
set .@code_exists$, 0;
mes "test";
while (@code_exists == 0) {
for (set @i, 0; @i < 6; set @i, @i+1) {
set .@random_char$, rand(0, (getarraysize(.coupon_code$) - 1));
set .@new_transaction$, .@new_transaction$ + .coupon_code$[.@random_char$];
}
query_sql("SELECT COUNT(*) FROM transaction_tbl WHERE transaction_code='" + .@new_transaction$ + "'", .@code_count);
if (.@code_count == 0) {
set .@code_exists$, 1;
query_sql("INSERT INTO transaction_tbl (transaction_code) VALUES ('" + .@new_transaction$ + "')");
mes "Transaction Code: " + .@new_transaction$ + " inserted into the database.";
} else {
set .@new_transaction$, "";
}
}
set .@new_transaction$, "";
close;
}
Question
Onairda
Hello Everyone,
I was hoping if you could help me, to have the below script work. What I want is create a random generator code "Transaction Code" temporarily, which means only transacting players can see the generated Transaction Code and even 100 players using the script it wont give the same Transaction Code.
prontera,155,155,3 script TESTSTE 92,{ setarray .coupon_code$[0],"A","B","C","D","E","F","G","H","I","J","K","L", "M","N","O","P","Q","R","S","T","U","V","W","X", "Y","Z","0","1","2","3","4","5","6","7","8","9"; set .@new_transaction$, ""; set .@code_exists$, 0; mes "test"; while (@code_exists == 0) { for (set @i, 0; @i < 6; set @i, @i+1) { set .@random_char$, rand(0, (getarraysize(.coupon_code$) - 1)); set .@new_transaction$, .@new_transaction$ + .coupon_code$[.@random_char$]; } query_sql("SELECT COUNT(*) FROM transaction_tbl WHERE transaction_code='" + .@new_transaction$ + "'", .@code_count); if (.@code_count == 0) { set .@code_exists$, 1; query_sql("INSERT INTO transaction_tbl (transaction_code) VALUES ('" + .@new_transaction$ + "')"); mes "Transaction Code: " + .@new_transaction$ + " inserted into the database."; } else { set .@new_transaction$, ""; } } set .@new_transaction$, ""; close; }
Thank you
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.