Jump to content
  • 0

Prize giver (vote points)


Question

Posted

Hi. I want the event npc to give a prize which is vote points but the problem is npc dont give me points.

here's the script

query_sql ("SELECT `points` FROM `v4p_voters_info` WHERE `accountid` = '"+getcharid(3)+"'", @vote);

set .@new, @vote +5;//
  if( .@new < 0 ) // safty first..
   set .@new, 0;
  dispbottom "Gained Reward Points. Current Reward Points:"+.@new+"";
  query_sql("UPDATE `v4p_voters_info` SET `points` = '"+.@new+"' WHERE `accountid` = '"+getcharid(3)+"'");

4 answers to this question

Recommended Posts

Posted (edited)

Hi. I want the event npc to give a prize which is vote points but the problem is npc dont give me points.

here's the script

query_sql ("SELECT `points` FROM `v4p_voters_info` WHERE `accountid` = '"+getcharid(3)+"'", @vote);

set .@new, @vote +5;//
  if( .@new < 0 ) // safty first..
set .@new, 0;
  dispbottom "Gained Reward Points. Current Reward Points:"+.@new+"";
  query_sql("UPDATE `v4p_voters_info` SET `points` = '"+.@new+"' WHERE `accountid` = '"+getcharid(3)+"'");

your if statement isnt closed that may be why, also u have alot of "" around the update and select statments use this http://www.eathena.ws/board/index.php?showtopic=279893&hl=hourly+rates as a refrence on how many quotes u should be using :X

Edited by lilcooldude69
Posted (edited)

May be that account haven't any row in table yet, Because I haven't seen any "Insert" in your code.so It can't UPDATE to the table that haven't any row yet.

I suggest you to use "REPLACE" instead of "UPDATE", It let you inset a new row if it haven't and replace it if it already have it.

(Make sure you set accountid to primary key).

query_sql("REPLACE INTO `v4p_voters_info` SET `accountid` = '"+getcharid(3)+"',`points` = '"+.@new+"'");

PS. IF you have other filed just set it to in replace, otherwise your data will lost T T

Or another way Is check that if he don't have the point,you insert it and if he already have it, you update it.

But i think use replace is more easy. By the way it's your choice

Edited by Magic-Maker
  • Upvote 1

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...