Jump to content
  • 0

Points DB Error


Question

Posted

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.

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

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

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