Jump to content
  • 0

SQL ERROR in my SCRIPT


Jin Freecs

Question


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  63
  • Reputation:   3
  • Joined:  12/22/11
  • Last Seen:  

i have my battle grounds and recently one of my friend added this script to my bg so that all players with level 1 gm can have +2 valor badge ( level 1 gm premium account ) but im having this kind of error in SQL and also the +2 valor badge didn't work how to fix this??

1231m2s.jpg

function HandOutPrizes { //<teamArray>, <numPlayers>, <itemID>, <qty>
while(.@i < getarg(1)) {
// Edit starts here
query_sql("select account_id,level from login where account_id = "+getd(getarg(0) + "[" + .@i + "]")+"order by level limit 1",.acc_id,.acc_lvl);
if(.acc_lvl == 1)
set .qty,2;
else
set .qty,0;
getitem getarg(2), getarg(3)+.qty, getd(getarg(0) + "[" + .@i + "]");
// Edit ends here
set .@i, .@i + 1;
}
return;
}

Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  82
  • Topics Per Day:  0.02
  • Content Count:  846
  • Reputation:   137
  • Joined:  02/26/14
  • Last Seen:  

Hm...Why not just use getgmlvl? instead of using query?

if(getgmlvl == 1){
set .qty,2;}
else {
set .qty,0;}
getitem getarg(2), getarg(3)+.qty, getd(getarg(0) + "[" + .@i + "]");

As for why the item cant be given is because in this script you've pasted; the Item ID is no where to be found so "getarg(2)" becomes 0. In terms; You must define the itemID and the quantity inorder for the "getitem" to beable to fully work

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


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

function HandOutPrizes { //<teamarray>, <numplayers>, <itemid>, <qty>
while(.@i < getarg(1)) {
// Edit starts here
query_sql("select account_id,level from login where account_id = "+getd(getarg(0) + "[" + .@i + "]")+"order by level limit 1",.acc_id,.acc_lvl);
if(.acc_lvl == 1)
set .qty,2;
else
set .qty,0;
getitem getarg(2), getarg(3)+.qty, getd(getarg(0) + "[" + .@i + "]");
// Edit ends here
set .@i, .@i + 1;
}
return;
}

Problem:

space between

where account_id = "+getd(getarg(0) + "[" + .@i + "]")+"order 

Try this:

function HandOutPrizes { //<teamarray>, <numplayers>, <itemid>, <qty>
while(.@i < getarg(1)) {
// Edit starts here
query_sql("select account_id,level from login where account_id = '"+getd(getarg(0) + "[" + .@i + "]")+"' order by level limit 1",.acc_id,.acc_lvl);
if(getarraysize(.acc_lvl) == 1)
set .qty,2;
else
set .qty,0;
getitem getarg(2), getarg(3)+.qty, getd(getarg(0) + "[" + .@i + "]");
// Edit ends here
set .@i, .@i + 1;
}
return;
}

I add also getarraysize in the if, since the query_sql returns array variables

Hope it work

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Is your rAthena version before or after 15572?

If it's after r15572, there's no `login`.`level` column which could be causing the error.

Also, as Skyrim mentioned, you could use the script command

  • getgmlevel() to check their level
  • getgroupid() to check their group.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  63
  • Reputation:   3
  • Joined:  12/22/11
  • Last Seen:  

@Skyrim

not working also

@JayPee

1h776o.jpg

Thanks for the help

Edited by Jin Freecs
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

Here, I dont know why it became &amp;lt;

function HandOutPrizes {
while(.@i < getarg(1)) {
// Edit starts here
query_sql("select account_id,level from login where account_id = "+getd(getarg(0) + "[" + .@i + "]")+"order by level limit 1",.acc_id,.acc_lvl);
if(.acc_lvl == 1)
set .qty,2;
else
set .qty,0;
getitem getarg(2), getarg(3)+.qty, getd(getarg(0) + "[" + .@i + "]");
// Edit ends here
set .@i, .@i + 1;
}
return;
}

try to use what Bryan posted that is more better

Is your rAthena version before or after 15572?

If it's after r15572, there's no `login`.`level` column which could be causing the error.

Also, as Skyrim mentioned, you could use the script command

  • getgmlevel() to check their level
  • getgroupid() to check their group.

Edited by JayPee
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

^ that error is different than the first.

while(.@i < getarg(1)) {

should be

while(.@i < getarg(1)) {

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  63
  • Reputation:   3
  • Joined:  12/22/11
  • Last Seen:  

@all

Thanks a lot its working fine now the solution is

^ that error is different than the first.

while(.@i < getarg(1)) {

should be

while(.@i < getarg(1)) {

Thanks a lot

Regards

  • Upvote 1
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...