Script with Sql database

AdmCronus

New member
Messages
50
Points
0
i need to sell items for pont in databse see tabela:

ALTER TABLE `char` ADD `pontos` INT NOT NULL ;
i need player buy item for this pont.

how i do?

 
maybe edit jaypee's v4p
https://github.com/mandark022/VoteForPoints/blob/master/npc%20script/rAthena/voteforpoints.txt
 

function updatePoints {set .@char_id,getarg(0);set .@usedPoints,getarg(1);query_sql("UPDATE `chars` SET puntos=(puntos-"+.@usedPoints+") WHERE char_id='"+.@char_id+"'");return;}function getPoints {set .@char_id,getarg(0);query_sql("SELECT `puntos` FROM `char` WHERE charid_id="+.@char_id+" LIMIT 1",.@points);if(getarraysize(.@points)==0)return 0;return .@points[0];}
change also

updatePoints(getcharid(0),.@rpoints);

getPoints(getcharid(0);


Did not test mwahah

 
is good, but i need to sell :

exemple when player talk with npc for buy item per puntos.

getitem 608,50;
query_sql("UPDATE `chars` SET puntos=(puntos-100) WHERE char_id='"+.@char_id+"'");
 
 
how i do?
 
Last edited by a moderator:
You're gonna make 608 to be points?
 
set .@count, countitem(608);
if (.@count == 0) end;
delitem 608, .@count;
query_sql("UPDATE `chars` SET puntos=(puntos+" +.@count+ ") WHERE char_id="+.@char_id);
 
are invert, i need to make items for puntos.

ex:

607 x 20 for 10 pontos

678 x 50 for 15 pontos

need to count if player have punto  for get item. understand?

 
Last edited by a moderator:
the first post does it. its a configurable seller npc.

 

Code:
set .@charid, getcharid(0);query_sql("SELECT `puntos` FROM `char` WHERE `charid_id`=" +.@char_id, .@points);query_sql("UPDATE `char` SET puntos=(puntos-" +@points+ ") WHERE char_id="+.@char_id);getitem 502, @points; 
 
i will test, and for check if player have puntos or not for he buy.

npc check player have 5 pontos for buy item 607.

 
Last edited by a moderator:
Back
Top