BTNX Posted June 17, 2013 Posted June 17, 2013 I'm not sure if this is the right section for this... I just don't know where to start I'm trying to create a usable item(ticket) that will add a value to an existing value on SQL For example... My table looks like this: acc_id c_points 2000000 0 2000010 250 2000005 150 If a player with account ID 2000010 used 3 usable item(ticket), it will add 100 per item and will result into this: acc_id c_points 2000000 0 2000010 550 2000005 150 also, if a player used the item for the first time, automatically insert a new line. Quote
DeadlySilence Posted June 17, 2013 Posted June 17, 2013 (edited) You can use an item script like this: query_sql("INSERT INTO `YOURTABLE` (`acc_id`, `c_points`) VALUES (" + getcharid(3) + ", 0) ON DUPLICATE KEY UPDATE `c_points` = `c_points` + 100"); It will try to create a new row in "YOURTABLE" with the acc_id and zero c_points. If there is already a row with the player's id, it will be updated. The acc_id column has to be either the primary key, or a unique key for it to work. Edited June 17, 2013 by DeadlySilence Quote
Question
BTNX
I'm not sure if this is the right section for this... I just don't know where to start
I'm trying to create a usable item(ticket) that will add a value to an existing value on SQL
For example... My table looks like this:
acc_id c_points
2000000 0
2000010 250
2000005 150
If a player with account ID 2000010 used 3 usable item(ticket), it will add 100 per item and will result into this:
acc_id c_points
2000000 0
2000010 550
2000005 150
also, if a player used the item for the first time, automatically insert a new line.
1 answer 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.