Jump to content
  • 0

Points DB Error


Strand

Question


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  102
  • Reputation:   2
  • Joined:  07/01/13
  • Last Seen:  

Hello community,

I have a problem when I want to create a script that updates the points of a character in SQL when he dies. I want him to lose 12 points when he dies, but if he dies with 2 points for example, the emulator shows an error in the following way:


[SQL]: DB error - BIGINT UNSIGNED value is out of range in '(`myserver_ro`.`pvp_ranking`.`points` - 12)'
[Debug]: at script.c:17014 - insert into `pvp_ranking` value ( 150040, 'Junior', 12 , 0 ) on duplicate key update `points` = `points` -  12
[Debug]: Source (NPC): PvPoints (invisible/not on a map)

 

It would seem as if I could not do the subtraction of 2 - 12 and therefore give the number 0 as the final total since I believe it should be a "negative number".

Anyone can help?

Script:

query_sql "insert into `pvp_ranking` value ( "+ getcharid(0) +", '"+ escape_sql( strcharinfo(0) ) +"', "+ .@points +" , 0 ) on duplicate key update `points` = `points` -  "+ .@points +"";

Thank you in advance.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

Hi, You can try if this works for you:

INSERT INTO pvp_ranking (charid,points) VALUES(150013, 0) ON DUPLICATE KEY UPDATE points = CASE WHEN points >= 12 THEN points - 12 ELSE 0 END

Change the table column names to match yours.

Edited by Sehrentos
FixTypo
  • Love 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...