BTNX Posted June 17, 2013 Group: Members Topic Count: 13 Topics Per Day: 0.00 Content Count: 55 Reputation: 3 Joined: 04/02/12 Last Seen: October 22, 2022 Share 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 Link to comment Share on other sites More sharing options...
DeadlySilence Posted June 17, 2013 Group: Members Topic Count: 7 Topics Per Day: 0.00 Content Count: 181 Reputation: 53 Joined: 04/07/13 Last Seen: August 23, 2014 Share 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 Link to comment Share on other sites More sharing options...
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.
Link to comment
Share on other sites
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.