brunoshp Posted June 13, 2013 Group: Members Topic Count: 64 Topics Per Day: 0.01 Content Count: 180 Reputation: 7 Joined: 12/19/12 Last Seen: November 21, 2024 Share Posted June 13, 2013 (edited) how i do player buy item in npc for ponts in Sql? table: ALTER TABLE `char` ADD `pontos` INT NOT NULL ; i make this but no ok! when player buy decrease -1 ponto in table this char. query_sql "UPDATE `char` SET `pontos` = `pontos` -1"; Edited June 13, 2013 by brunoshp Quote Link to comment Share on other sites More sharing options...
Skorm Posted June 13, 2013 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted June 13, 2013 ALTER TABLE `char` ADD `pontos` int(11) unsigned NOT NULL default '0'; query_sql "UPDATE `char` SET `pontos` = `pontos` -1 WHERE `charid` = "+getcharid(0)+" AND `pontos` <> 0;";It's kind of hard for me to understand what you want exactly. Quote Link to comment Share on other sites More sharing options...
brunoshp Posted June 13, 2013 Group: Members Topic Count: 64 Topics Per Day: 0.01 Content Count: 180 Reputation: 7 Joined: 12/19/12 Last Seen: November 21, 2024 Author Share Posted June 13, 2013 i need buy item for pontos. ex: item 607 for 20 pontos item 678 for 15 pontos and other items Quote Link to comment Share on other sites More sharing options...
Skorm Posted June 13, 2013 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted June 13, 2013 (edited) - shop custom_seller1 -1,501:50 morocc,159,97,5 script SQL NPC Shop 60,{ mes "Welcome to my shop!"; callshop "custom_seller1",1; npcshopattach "custom_seller1"; end; OnBuyItem: for(set @i,0; .shop_list[@i]; set @i,@i+1) { for(set @d,0; @d<getarraysize(@bought_nameid); set @d,@d+1){ set .@shpl, .shop_list[@i]; set .@pril, .price_list[@i]; set .@boun, @bought_nameid[@d]; set .@bouq, @bought_quantity[@d]; if(.@boun==.@shpl) { if(checkweight(.@shpl,.@bouq)){ if(query_sql("UPDATE `char` SET `pontos` = `pontos` -"+( .@pril*.@bouq )+" WHERE `char_id` = "+getcharid(0)+" AND `pontos` -"+( .@pril*.@bouq )+" > 0;",.@a)){ getitem .@boun,.@bouq; } else { dispbottom "I'm sorry you don't have enough points for "+getitemname(.@shpl)+"s."; } } else { dispbottom "I'm sorry but you can't hold that many "+getitemname(.@shpl)+"s."; } } } } deletearray @bought_quantity, getarraysize(@bought_quantity); deletearray @bought_nameid, getarraysize(@bought_nameid); close; OnInit: //=================Configuration================ //Itemlist setarray .shop_list[0],607,678; setarray .price_list[0],20,15; //================================================= npcshopitem "custom_seller1",0,0; for(set .i,0; .shop_list[.i]; set .i,.i+1) npcshopadditem "custom_seller1",.shop_list[.i],.price_list[.i]; end; } Edited June 13, 2013 by Skorm Quote Link to comment Share on other sites More sharing options...
brunoshp Posted June 13, 2013 Group: Members Topic Count: 64 Topics Per Day: 0.01 Content Count: 180 Reputation: 7 Joined: 12/19/12 Last Seen: November 21, 2024 Author Share Posted June 13, 2013 (edited) when i go buy , he talk me not have point , but i have 300! http://imageshack.us/photo/my-images/189/error1d.png/ Edited June 13, 2013 by brunoshp Quote Link to comment Share on other sites More sharing options...
Skorm Posted June 13, 2013 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted June 13, 2013 Very sorry I have to go to school right now x.x. Maybe someone else can fix it? It looks like the variable for .@boun is mistaken somewhere O_O. You wouldn't be getting that warning had the transaction not gone through. If nobody has fixed by the time I get home. Will help more. tytyty! Quote Link to comment Share on other sites More sharing options...
brunoshp Posted June 13, 2013 Group: Members Topic Count: 64 Topics Per Day: 0.01 Content Count: 180 Reputation: 7 Joined: 12/19/12 Last Seen: November 21, 2024 Author Share Posted June 13, 2013 i will waiting you! ty Quote Link to comment Share on other sites More sharing options...
Capuche Posted June 14, 2013 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 616 Joined: 07/05/12 Last Seen: March 20 Share Posted June 14, 2013 - shop falseshop -1,909:-1 prontera,155,160,5 script dffddf 56,{ callshop "falseshop",1; npcshopattach "falseshop"; end; OnBuyItem: query_sql "select `pontos` from `char` where `char_id` = "+ getcharid(0), .@pontos; while( @bought_nameid[.@j] ) { for ( .@i = 0; .@i < .size_shop; .@i += 2 ) if ( .item_shop[.@i] == @bought_nameid[.@j] ) break; .@amount = .@amount + @bought_quantity[.@j] * .item_shop[.@i+1]; .@j++; } if ( .@amount > .@pontos ) { dispbottom "You need "+ .@amount +" point(s) and you have "+ .@pontos +" point(s)."; end; } query_sql "update `char` set `pontos` = ( `pontos` - "+ .@amount +" ) where `char_id` = "+ getcharid(0); for ( .@i = 0; .@i < getarraysize( @bought_nameid ); .@i++ ) getitem @bought_nameid[.@i], @bought_quantity[.@i]; dispbottom "You use "+ .@amount +" point(s). "+ .@pontos +" point(s) remains."; end; OnInit: setarray .item_shop, 7447,5, 7448,6; // <Item ID>, <amount points required> .size_shop = getarraysize( .item_shop ); npcshopdelitem "falseshop",909; while( .@i < .size_shop ) { npcshopadditem "falseshop", .item_shop[.@i], .item_shop[.@i+1] ; .@i += 2; } } 1 Quote Link to comment Share on other sites More sharing options...
Skorm Posted June 14, 2013 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted June 14, 2013 - shop custom_seller1 -1,501:50 morocc,159,97,5 script SQL NPC Shop 60,{ mes "Welcome to my shop!"; callshop "custom_seller1",1; npcshopattach "custom_seller1"; end; OnBuyItem: for(set @i,0; .shop_list[@i]; set @i,@i+1) { for(set @d,0; @d<getarraysize(@bought_nameid); set @d,@d+1){ set .@shpl, .shop_list[@i]; set .@pril, .price_list[@i]; set .@boun, @bought_nameid[@d]; set .@bouq, @bought_quantity[@d]; if(.@boun==.@shpl) { if(checkweight(.@shpl,.@bouq)){ if(query_sql("SELECT `pontos` FROM `char` WHERE `char_id` = "+getcharid(0)+" AND `pontos` -"+( .@pril*.@bouq )+" > 0 FOR UPDATE;",.@a)){ query_sql("UPDATE `char` SET `pontos` = `pontos` -"+( .@pril*.@bouq )+" WHERE `char_id` = "+getcharid(0)+";"); getitem .@shpl,.@bouq; dispbottom "Transaction complete you have "+(.@a-(.@pril*.@bouq))+" points left."; } else { dispbottom "I'm sorry you don't have enough points for "+getitemname(.@shpl)+"s."; } } else { dispbottom "I'm sorry but you can't hold that many "+getitemname(.@shpl)+"s."; } } } } deletearray @bought_quantity, getarraysize(@bought_quantity); deletearray @bought_nameid, getarraysize(@bought_nameid); close; OnInit: //=================Configuration================ //Itemlist setarray .shop_list,607,678; setarray .price_list,20,15; //================================================= npcshopdelitem "custom_seller1",501; for(set .i,0; .i<getarraysize(.shop_list); set .i,.i+1) npcshopadditem "custom_seller1",.shop_list[.i],.price_list[.i]; end; } LOL I didn't see your post Chapuche! Chapuche, you forgot to add a weight check. 1 Quote Link to comment Share on other sites More sharing options...
brunoshp Posted June 14, 2013 Group: Members Topic Count: 64 Topics Per Day: 0.01 Content Count: 180 Reputation: 7 Joined: 12/19/12 Last Seen: November 21, 2024 Author Share Posted June 14, 2013 Now is ok!!!! thz for alll! Quote Link to comment Share on other sites More sharing options...
Question
brunoshp
how i do player buy item in npc for ponts in Sql?
table:
i make this but no ok!
when player buy decrease -1 ponto in table this char.
Link to comment
Share on other sites
9 answers 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.