Geralt Posted April 10, 2020 Share Posted April 10, 2020 (edited) Guys I had created another topic another section on voteforpoints. OKhttps://github.com/sanasol/FluxCP_Addons-VoteForPoints It worked fine but the npc does not record the points, example: I voted for topragnarok there inside the server it does not count the points is 0 prontera,150,150,4 script VFP Manager 62,{ function getPoints; set [email protected]$, "[VFP Manager]"; set [email protected], 1; // 0 = item, 1 = shop set [email protected], 501; // if settings is set to item set [email protected], 2; // 2 Vote Points for 1 Red Potion set .vp, getPoints(getcharid(3)); switch ([email protected]) { case 0: mes [email protected]$; mes "Would you like to convert your "+ .vp +" Vote Points?"; mes "^ff0000The current convert rate is "+ [email protected] +" Vote Points for 1 "+ getitemname([email protected]) +"."; next; menu "Yes", L_Convert, "No", -; mes [email protected]$; mes "Bye, then."; break; case 1: mes [email protected]$; mes "You have ^ff0000"+ .vp +"^000000 Vote Points."; mes "Would you like to go shopping?"; next; menu "Yes", -, "No", L_Goodbye; mes [email protected]$; mes "Have fun shopping!"; callshop "votepoints_shop",1; npcshopattach "votepoints_shop"; end; } L_Goodbye: mes [email protected]$; mes "Goodbye, then."; close; L_Convert: if (.vp < [email protected]) goto L_VotePointsTooLow; mes [email protected]$; mes "How much Vote Points would you like to convert?"; next; menu "All", L_ConvertAll, "Input Amount", L_ConvertAmount; L_ConvertAmount: input [email protected]; if ([email protected] > .vp) goto L_VotePointsTooLow; set .vp, ((.vp - [email protected]) + ([email protected] % [email protected])); set [email protected], ([email protected] / [email protected]); getitem [email protected], [email protected]; query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3)); mes [email protected]$; mes "You have received "+ [email protected] +"x "+ getitemname([email protected]) +"."; mes "Your current Vote Points is "+ .vp; close; L_ConvertAll: set [email protected], (.vp / [email protected]); set .vp, (.vp % [email protected]); getitem [email protected], [email protected]; query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3)); mes [email protected]$; mes "You have received "+ [email protected] +"x "+ getitemname([email protected]) +"."; mes "Your current Vote Points is "+ .vp; close; L_VotePointsTooLow: mes [email protected]$; mes "Your Vote Points is too low. Come back when you have the minimum amount of Vote Points."; close; function getPoints { set [email protected]_id, getarg(0); set [email protected], query_sql("SELECT votepoints FROM cp_createlog WHERE account_id = "+ [email protected]_id, [email protected]); return [email protected] ? [email protected] : 0; } OnBuyItem: set [email protected],0; for(set [email protected],0; [email protected]<getarraysize(@bought_nameid); set [email protected],[email protected]+1) for(set [email protected],0; [email protected]<getarraysize(.itemShop); set [email protected]j,[email protected]j+2) if (@bought_nameid[[email protected]i] == .itemShop[[email protected]j]) { set [email protected]cost, [email protected]cost+(.itemShop[[email protected]j+1]*@bought_quantity[[email protected]i]); break; } mes [email protected]n$; if ([email protected]cost > .vp) mes "You don't have enough Vote Points."; else { for(set [email protected],0; [email protected]<getarraysize(@bought_nameid); set [email protected],[email protected]+1) { getitem @bought_nameid[[email protected]], @bought_quantity[[email protected]]; dispbottom "Purchased "[email protected]_quantity[[email protected]]+"x "+getitemname(@bought_nameid[[email protected]])+"."; } set .vp, .vp - [email protected]; query_sql("UPDATE cp_createlog SET votepoints = votepoints - "+ [email protected] +" WHERE account_id = "+ getcharid(3)); mes [email protected]$; mes "Deal completed."; mes "You now have ^ff0000"+ .vp +"^000000 Vote Points."; emotion e_cash; } set [email protected],0; deletearray @bought_nameid[0], getarraysize(@bought_nameid); deletearray @bought_quantity[0], getarraysize(@bought_quantity); close; OnInit: setarray .itemShop[0], 501,2,607,5; // <ITEM_ID>,<PRICE>,... npcshopdelitem "votepoints_shop",512; for(set [email protected], 0; [email protected] < getarraysize(.itemShop); set [email protected], [email protected]+2) npcshopadditem "votepoints_shop", .itemShop[[email protected]], .itemShop[[email protected]+1]; end; } - shop votepoints_shop -1,512:-1 Edited April 10, 2020 by Akkarin Please use codebox for code instead of quotes /no1 Quote Link to comment Share on other sites More sharing options...
0 Akkarin Posted April 10, 2020 Share Posted April 10, 2020 Summoning @Sanasol 1 Quote Link to comment Share on other sites More sharing options...
0 Sanasol Posted April 14, 2020 Share Posted April 14, 2020 https://github.com/sanasol/FluxCP_Addons-VoteForPoints/blob/master/config/addon.php#L4 Do you use vote option here? NPC only works in this case i guess Quote Link to comment Share on other sites More sharing options...
0 darking123 Posted May 10, 2020 Share Posted May 10, 2020 On 4/14/2020 at 12:23 PM, Sanasol said: https://github.com/sanasol/FluxCP_Addons-VoteForPoints/blob/master/config/addon.php#L4 Do you use vote option here? NPC only works in this case i guess I used vote option. I tried to vote upon checking cp_createlog. It appears to still be empty. that is why the NPC doesn't retrieve anything so what I need was I tried to insert values manually making sure to populate the accound_id then i tried to vote again using the account_id. After checking votepoints has been added. I think the issue maybe due to the lack of insert function for vote? I'm really not sure Quote Link to comment Share on other sites More sharing options...
0 Royr Posted November 11, 2020 Share Posted November 11, 2020 (edited) On 5/10/2020 at 10:45 AM, darking123 said: I used vote option. I tried to vote upon checking cp_createlog. It appears to still be empty. that is why the NPC doesn't retrieve anything so what I need was I tried to insert values manually making sure to populate the accound_id then i tried to vote again using the account_id. After checking votepoints has been added. I think the issue maybe due to the lack of insert function for vote? I'm really not sure Alright! This is how i fixed the issue regarding not updating SQL. Make sure your using the "vote": Locate: addons\voteforpoints\config\addon.php 'PointsType' => "vote", // credit, vote, cash What i did was creating a new table, which is "cp_v4p_voters" SQL Table: (Execute this query) CREATE TABLE `cp_v4p_voters` ( `account_id` int(10) unsigned NOT NULL, `votepoints` int(10) unsigned NOT NULL, PRIMARY KEY (`account_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; First removed the existing one: case "vote": // update votepoints $sql = "UPDATE $server->loginDatabase.cp_createlog SET votepoints = votepoints + ? WHERE account_id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array((int) $res->votepoints, $account_id)); break; And Insert this: (Locate) addons\voteforpoints\modules\voteforpoints\index.php case "vote": // update votepoints $sql = "UPDATE $server->loginDatabase.cp_v4p_voters SET votepoints = votepoints + ? WHERE account_id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array((int) $res->votepoints, $account_id)); if ( ! $sth->rowCount()) { $sql = "INSERT INTO $server->loginDatabase.cp_v4p_voters VALUES (?, ?)"; $sth = $server->connection->getStatement($sql); $bind = array($account_id, $res->votepoints); $sth->execute($bind); if ( ! $sth->rowCount()) $errorMessage = sprintf(Flux::message("UnableToVote"), 3); } else { $sql = "UPDATE $server->loginDatabase.cp_v4p_voters SET `value` = `value` + ? WHERE `key` = ? AND account_id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array((int) $res->votepoints, $account_id)); } break; PROOF it works . Edited November 11, 2020 by Royr Quote Link to comment Share on other sites More sharing options...
0 Shadow Rebom Posted March 3, 2021 Share Posted March 3, 2021 (edited) this script good to use... but cant points in to player only to phpmyadmin.. cash points good use.. but vote points not work Edited March 3, 2021 by rizal84150 1 Quote Link to comment Share on other sites More sharing options...
0 Checkmate Posted May 5, 2021 Share Posted May 5, 2021 On 11/11/2020 at 9:27 PM, Royr said: Alright! This is how i fixed the issue regarding not updating SQL. Make sure your using the "vote": Locate: addons\voteforpoints\config\addon.php 'PointsType' => "vote", // credit, vote, cash What i did was creating a new table, which is "cp_v4p_voters" SQL Table: (Execute this query) CREATE TABLE `cp_v4p_voters` ( `account_id` int(10) unsigned NOT NULL, `votepoints` int(10) unsigned NOT NULL, PRIMARY KEY (`account_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; First removed the existing one: case "vote": // update votepoints $sql = "UPDATE $server->loginDatabase.cp_createlog SET votepoints = votepoints + ? WHERE account_id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array((int) $res->votepoints, $account_id)); break; And Insert this: (Locate) addons\voteforpoints\modules\voteforpoints\index.php case "vote": // update votepoints $sql = "UPDATE $server->loginDatabase.cp_v4p_voters SET votepoints = votepoints + ? WHERE account_id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array((int) $res->votepoints, $account_id)); if ( ! $sth->rowCount()) { $sql = "INSERT INTO $server->loginDatabase.cp_v4p_voters VALUES (?, ?)"; $sth = $server->connection->getStatement($sql); $bind = array($account_id, $res->votepoints); $sth->execute($bind); if ( ! $sth->rowCount()) $errorMessage = sprintf(Flux::message("UnableToVote"), 3); } else { $sql = "UPDATE $server->loginDatabase.cp_v4p_voters SET `value` = `value` + ? WHERE `key` = ? AND account_id = ?"; $sth = $server->connection->getStatement($sql); $sth->execute(array((int) $res->votepoints, $account_id)); } break; PROOF it works . Yeash this works flawlesly BUT it still did not work & still did not shown any point while in game. (Btw do you restart the whole server?) Quote Link to comment Share on other sites More sharing options...
0 Shadow Rebom Posted June 3, 2021 Share Posted June 3, 2021 Nice thx sir Quote Link to comment Share on other sites More sharing options...
0 powkda Posted December 21, 2021 Share Posted December 21, 2021 On 4/14/2020 at 1:23 AM, Sanasol said: https://github.com/sanasol/FluxCP_Addons-VoteForPoints/blob/master/config/addon.php#L4 Do you use vote option here? NPC only works in this case i guess when I buy the apple at the shop, it doesn't deduct the points, nor does it check if I have enough points. poring_c01,104,100,4 script VFP Manager 62,{ function getPoints; set .@n$, "[VFP Manager]"; set .@settings, 1; // 0 = item, 1 = shop set .@itemReward, 501; // if settings is set to item set .@convertRate, 2; // 2 Vote Points for 1 Red Potion set .vp, getPoints(getcharid(3)); switch (.@settings) { case 0: mes .@n$; mes "Would you like to convert your "+ .vp +" Vote Points?"; mes "^ff0000The current convert rate is "+ .@convertRate +" Vote Points for 1 "+ getitemname(.@itemReward) +"."; next; menu "Yes", L_Convert, "No", -; mes .@n$; mes "Bye, then."; break; case 1: mes .@n$; mes "You have ^ff0000"+ .vp +"^000000 Vote Points."; mes "Would you like to go shopping?"; next; menu "Yes", -, "No", L_Goodbye; mes .@n$; mes "Have fun shopping!"; callshop "votepoints_shop",1; npcshopattach "votepoints_shop"; end; } L_Goodbye: mes .@n$; mes "Goodbye, then."; close; L_Convert: if (.vp < .@convertRate) goto L_VotePointsTooLow; mes .@n$; mes "How much Vote Points would you like to convert?"; next; menu "All", L_ConvertAll, "Input Amount", L_ConvertAmount; L_ConvertAmount: input .@convert; if (.@convert > .vp) goto L_VotePointsTooLow; set .vp, ((.vp - .@convert) + (.@convert % .@convertRate)); set .@convert, (.@convert / .@convertRate); getitem .@itemReward, .@convert; query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3)); mes .@n$; mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +"."; mes "Your current Vote Points is "+ .vp; close; L_ConvertAll: set .@convert, (.vp / .@convertRate); set .vp, (.vp % .@convertRate); getitem .@itemReward, .@convert; query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3)); mes .@n$; mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +"."; mes "Your current Vote Points is "+ .vp; close; L_VotePointsTooLow: mes .@n$; mes "Your Vote Points is too low. Come back when you have the minimum amount of Vote Points."; close; function getPoints { set .@account_id, getarg(0); set .@count, query_sql("SELECT votepoints FROM cp_createlog WHERE account_id = "+ .@account_id, .@votepoints); return .@count ? .@votepoints : 0; } OnBuyItem: set .@cost,0; for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) for(set .@j,0; .@j<getarraysize(.itemShop); set .@j,.@j+2) if (@bought_nameid[.@i] == .itemShop[.@j]) { set .@cost, .@cost+(.itemShop[.@j+1]*@bought_quantity[.@i]); break; } mes .@n$; if (.@cost > .vp) mes "You don't have enough Vote Points."; else { for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) { getitem @bought_nameid[.@i], @bought_quantity[.@i]; dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+"."; } set .vp, .vp - .@cost; query_sql("UPDATE cp_createlog SET votepoints = votepoints - "+ .@cost +" WHERE account_id = "+ getcharid(3)); mes .@n$; mes "Deal completed."; mes "You now have ^ff0000"+ .vp +"^000000 Vote Points."; emotion e_cash; } set .@cost,0; deletearray @bought_nameid[0], getarraysize(@bought_nameid); deletearray @bought_quantity[0], getarraysize(@bought_quantity); close; OnInit: setarray .itemShop[0], 501,2,607,5; // <ITEM_ID>,<PRICE>,... npcshopdelitem "votepoints_shop",512; for(set .@i, 0; .@i < getarraysize(.itemShop); set .@i, .@i+2) npcshopadditem "votepoints_shop", .itemShop[.@i], .itemShop[.@i+1]; end; } - shop votepoints_shop -1,512:1 <?php if (!defined('FLUX_ROOT')) exit; return array( 'DefaultThemeName' => 'default', 'PointsType' => "vote", // credit, vote, cash 'DefaultIntervalVoting' => 12, 'DefaultVotePoints' => 0, 'VoteNameMax' => 15, 'VoteNameMin' => 6, 'VotePointsMin' => 0, 'VotePointsMax' => 999, 'VoteIntervalMin' => 1, 'VoteIntervalMax' => 24, 'AllowedImgType' => array('jpg', 'jpeg', 'png', 'gif'), 'MaxFileSize' => 500, // KB, 'ImageMaxWidth' => 150, 'ImageMaxHeight' => 150, 'ImageUploadPath' => "votes", // /themes/default/img/votes/ 'EnableIPVoteCheck' => true, 'AlphaNumSpaceRegex' => "/^[A-Za-z0-9_\s]+$/", 'MenuItems' => array( 'Other' => array( 'Vote for Points' => array( 'module' => 'voteforpoints' ) ) ), 'SubMenuItems' => array( 'voteforpoints' => array( 'index' => 'Vote', 'add' => 'Add Voting Site', 'list' => 'List Voting Sites', 'log' => 'Voters Log', ) ), 'FluxTables' => array( 'vfp_logs' => 'cp_vfp_logs', 'vfp_sites' => 'cp_vfp_sites', 'cashpoints' => 'acc_reg_num' ) ) ?> Can someone help me please Quote Link to comment Share on other sites More sharing options...
Guys I had created another topic another section on voteforpoints. OK
https://github.com/sanasol/FluxCP_Addons-VoteForPoints
It worked fine but the npc does not record the points,
example: I voted for topragnarok there
inside the server it does not count the points is 0
Edited by AkkarinPlease use codebox for code instead of quotes /no1
Link to comment
Share on other sites