Jump to content
  • 0

R> ItemShop Currency (Instead of Donation Credits lookup for Vote For Points or Cashpoints Table)


Cianna Fernandez

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   1
  • Joined:  06/21/17
  • Last Seen:  

Hi,

My FluxCP is working just fine, however can I request some few changes regarding to my Item Shop current currency instead of "Donation Credits" can someone taught me how to make it lookup with my clients "Vote Credits" or "Cashpoints"

I'm adding Rare or Custom Items to my Control panel to sell it for "Vote Credits" or "Cash Points" that's all nothing else, because we do not support a Donation Feature this server is no money involve.

 

59824a6f4d1a0_Request-ItemShop.thumb.png.3b4fb7789e7205491eeba35a3498ba0b.png

 

 

We highly appreciate whoever quickly response and should you wish to be added to one of our contributors list.

 

Cianna Fernandez

Ragnarok Online Philippines (Manila Server)
https://www.ragnarokphilippines.ml/

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   4
  • Joined:  11/15/11
  • Last Seen:  

@Cianna Fernandez

This is easy go to your vote for point php script, Edit the PHP so that every time they vote values are added on the table:

cp_credits

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   1
  • Joined:  06/21/17
  • Last Seen:  

1 hour ago, randell1993 said:

@Cianna Fernandez

This is easy go to your vote for point php script, Edit the PHP so that every time they vote values are added on the table:

cp_credits

Hi there randell1993

As of now our clients are able to exchange their Vote Points using our "Points Manager" because we have lots of NPC Seller which sells Items that Involves CashPoints,

however I want my clients to have options If they want to avail our for sale Rare Items located at our Item Shop in our website,

1st Option: they have to exchange their Vote Points into CashPoints currency to buy In-Game Items that Involves CashPoints.

2nd Option: they have to exchange their Vote Points into "Donation Credits which is related to cp_credits table" in order to buy Items in our Website Item Shop.

Also I really have no Idea how to modify the vote for points addons, Can you help us if you think this was easy for you?

Thank you randell1993

Edited by Cianna Fernandez
correction of "but" to "buy"
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   4
  • Joined:  11/15/11
  • Last Seen:  

2 minutes ago, Cianna Fernandez said:

Hi there randell1993

As of now our clients are able to exchange their Vote Points using our "Points Manager" because we have lots of NPC Seller which sells Items that Involves CashPoints,

however I want my clients to have options If they want to avail our for sale Rare Items located at our Item Shop in our website,

1st Option: they have to exchange their Vote Points into CashPoints currency to buy In-Game Items that Involves CashPoints.

2nd Option: they have to exchange their Vote Points into "Donation Credits which is related to cp_credits table" in order to but Items in our Website Item Shop.

Also I really have no Idea how to modify the vote for points addons, Can you help us if you think this was easy for you?

Thank you randell1993

You can atleast link me to the vote point addons.

Please do note that by going to 2nd option route you will need to change how your Points manager query SQL Database

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   1
  • Joined:  06/21/17
  • Last Seen:  

Is there a way to change the table of 'donation credits' which is currently pointed to 'cp_credits' table,

because I have a vote for points addon and I want to use my 'cp_v4p_voters' table where column 'points' instead of using 'cp_credits' table where column 'balance

when purchasing an item to our Online Item Shop, so that every time my clients vote for our server they earn credits to buy to our Item Shop.

 

Please Help.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  76
  • Reputation:   4
  • Joined:  11/15/11
  • Last Seen:  

2 hours ago, Cianna Fernandez said:

Is there a way to change the table of 'donation credits' which is currently pointed to 'cp_credits' table,

because I have a vote for points addon and I want to use my 'cp_v4p_voters' table where column 'points' instead of using 'cp_credits' table where column 'balance

when purchasing an item to our Online Item Shop, so that every time my clients vote for our server they earn credits to buy to our Item Shop.

 

Please Help.

<?php 

/*
FluxCP Vote For Points
Developed By: JayPee Mateo
Email: [email protected]
*/

//A login is required
$this->loginRequired();
$site_id = $params->get('sid');
if(preg_match("/^[0-9]{1,}$/",$site_id))
{

	//Somewhat Prevent of using Proxy Servers
	$xforward= $_SERVER["HTTP_X_FORWARDED_FOR"];
	if (!empty($xforward)) {
		$error = Flux::message('PROXY_NOT_ALLOWED');
	}
	else
	{
	//User Account_ID and IP Address
	$account_id = $session->account->account_id;
	$ip_address = 0;
	if(Flux::config('IP_BLOCKING'))
		$ip_address = $_SERVER['REMOTE_ADDR'];
		
	$current_time= date("Y-m-d G:i:s",time());

	//This will list the sites
	$vp_site = Flux::config('FluxTables.Sites'); 
	$vp_voter = Flux::config('FluxTables.Voters'); 
	$vp_logs = Flux::config('FluxTables.Logs'); 


	$check = null;
	if($ip_address!=0)
	{
		/*
			IP BLOCKING SYSTEM IS ON/ENABLED
			This will check if the IP is unblocked for the specified site
		*/
		$sql = "SELECT `rtid`,`unblock_time`,`ip_address` FROM {$server->loginDatabase}.{$vp_logs} WHERE f_site_id=? AND unblock_time>? AND ip_address=? ORDER BY unblock_time ASC";
		$sth = $server->connection->getStatement($sql);
		$sth->execute(array($site_id,$current_time,$ip_address));
		$check = $sth->fetchAll();
	}
		
	if(empty($check))
	{
		$sql = "SELECT `address`,`points`,`blocking_time` FROM {$server->loginDatabase}.{$vp_site} WHERE site_id=? LIMIT 1";
		$sth = $server->connection->getStatement($sql);
		$sth->execute(array($site_id));
		$vp_site = $sth->fetch();
			
	//Incase the user tamper the siteid
	if(!empty($vp_site))
	{
		//Site Information
		$address 		= $vp_site->address;
		$blocking_time 	= $vp_site->blocking_time;
		$points 		= $vp_site->points;


		//Calculate the Unblocking Time
		$unblock_time = date("Y-m-d G:i:s",time()+$blocking_time);

		//Check if the User has an existing voter's Record

		//In Vote Logs

			$sql = "SELECT `rtid`,`ip_address`,`unblock_time` FROM {$server->loginDatabase}.{$vp_logs} WHERE account_id=? AND f_site_id=? ";
			$sth = $server->connection->getStatement($sql);
			$sth->execute(array($account_id,$site_id));
			$check = $sth->fetch();
			
		if(!empty($check))
			$diff_time = strtotime($check->unblock_time)-strtotime(date("Y-m-d G:i:s",time()));
		else
			$diff_time = 0;
		
		if($diff_time<=0)
		{
			//Can Vote
			if(empty($check)){
				//If Not Voters Record For the specific site make an Insertion
				$sql = "INSERT INTO {$server->loginDatabase}.{$vp_logs} (f_site_id,unblock_time,account_id,ip_address) VALUES(?,?,?,?)";
				$sth = $server->connection->getStatement($sql);
				$sth->execute(array($site_id,$unblock_time,$account_id,$ip_address));
			}
			else{
				//If the voter has an existing log
					$sql = "UPDATE {$server->loginDatabase}.{$vp_logs} SET unblock_time=?, ip_address=? WHERE rtid=?";
					$sth = $server->connection->getStatement($sql);
					$sth->execute(array($unblock_time,$ip_address,$check->rtid));	
			}

			//In Voters Records
			$sql = "SELECT `account_id`,`points` FROM {$server->loginDatabase}.{$vp_voter} WHERE account_id=?";
			$sth = $server->connection->getStatement($sql);
			$sth->execute(array($account_id));
			$check = $sth->fetch();

			if(empty($check)){
				//If Not Voters Record For the specific site make an Insertion
				$sql = "INSERT INTO {$server->loginDatabase}.{$vp_voter}(account_id,points) VALUES(?,?)";
				$sth = $server->connection->getStatement($sql);
				$sth->execute(array($account_id,$points));
			}
			else{
				//If the voter is has an existing record
					$sql = "UPDATE {$server->loginDatabase}.{$vp_voter} SET points=? WHERE account_id=?";
					$sth = $server->connection->getStatement($sql);
					$points = $vp_site->points+$check->points;
					$sth->execute(array($points,$account_id));
			}
			$address = str_replace("http://","",$address);
			$address = str_replace("www.","",$address);
			$this->redirect("http://www.".$address);
		}
		else
			$error = Flux::message('BLOCK_VOTING_SITE').$check->unblock_time;						
	}
	else
		$error = Flux::message('VOTING_SITE_NOT_FOUND');
	}//--End
	else
		$error = Flux::message('BLOCK_VOTING_SITE').$check[0]->unblock_time;						
	}
}
else
	$error = Flux::message('INVALID_VOTING_SITE');

?>

I don't know if this is the same but this will be easier to edit than editing the core modules which might affect updating the flux cp in future

Here's what you need to change:

First upon looking on cp_credits you find the following tables

account_id balance last_donation_date last_donation_amount

and on cp_v4p_voters i found in the download section are the following

account_id points

Now looking at this, we can see that there isn't much difference in how they are structured so it will be quite a bit easy to change on the script
Now we look on the code above they access the cp_v4p_voters on this line 

$vp_voter = Flux::config('FluxTables.Voters'); 

we can then change values to

$vp_voter = Flux::config('FluxTables.CreditsTable');

Now this will make the PHP script to look into the cp_credits table instead on cp_v4p_voters

This time as you can see, the difference between the two tables is that the points value are inside the points column and now we need to change the script to place the variables inside the balance column.

Those commands can be seen here in this part of the code

//In Voters Records
			$sql = "SELECT `account_id`,`points` FROM {$server->loginDatabase}.{$vp_voter} WHERE account_id=?";
			$sth = $server->connection->getStatement($sql);
			$sth->execute(array($account_id));
			$check = $sth->fetch();

			if(empty($check)){
				//If Not Voters Record For the specific site make an Insertion
				$sql = "INSERT INTO {$server->loginDatabase}.{$vp_voter}(account_id,points) VALUES(?,?)";
				$sth = $server->connection->getStatement($sql);
				$sth->execute(array($account_id,$points));
			}
			else{
				//If the voter is has an existing record
					$sql = "UPDATE {$server->loginDatabase}.{$vp_voter} SET points=? WHERE account_id=?";
					$sth = $server->connection->getStatement($sql);
					$points = $vp_site->points+$check->points;
					$sth->execute(array($points,$account_id));
			}

In this you can see that on this line they access the cp_v4p_voters and selects account_id and points column

$sql = "SELECT `account_id`,`points` FROM {$server->loginDatabase}.{$vp_voter} WHERE account_id=?";

And since we are now using the credits table which has the balance column instead of points we change this line into this.

$sql = "SELECT `account_id`,`balance` FROM {$server->loginDatabase}.{$vp_voter} WHERE account_id=?";

heading to the other parts, on this chunk of lines we instruct the script to add the points everytime someone votes:

if(empty($check)){
				//If Not Voters Record For the specific site make an Insertion
				$sql = "INSERT INTO {$server->loginDatabase}.{$vp_voter}(account_id,points) VALUES(?,?)";
				$sth = $server->connection->getStatement($sql);
				$sth->execute(array($account_id,$points));
			}
			else{
				//If the voter is has an existing record
					$sql = "UPDATE {$server->loginDatabase}.{$vp_voter} SET points=? WHERE account_id=?";
					$sth = $server->connection->getStatement($sql);
					$points = $vp_site->points+$check->points;
					$sth->execute(array($points,$account_id));
			}

now we change the following lines to insert the points earned to balance column

$sql = "INSERT INTO {$server->loginDatabase}.{$vp_voter}(account_id,points) VALUES(?,?)";

to

$sql = "INSERT INTO {$server->loginDatabase}.{$vp_voter}(account_id,balance) VALUES(?,?)";

and this line

$sql = "UPDATE {$server->loginDatabase}.{$vp_voter} SET points=? WHERE account_id=?";

to

$sql = "UPDATE {$server->loginDatabase}.{$vp_voter} SET balance=? WHERE account_id=?";

 

I do hope this help you learn as just providing you with simple just replace this and that will just give you a hard time editing it in the future

Edited by randell1993
added more lines/grammar
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   1
  • Joined:  06/21/17
  • Last Seen:  

On 8/3/2017 at 5:56 AM, Cianna Fernandez said:

Hi,

My FluxCP is working just fine, however can I request some few changes regarding to my Item Shop current currency instead of "Donation Credits" can someone taught me how to make it lookup with my clients "Vote Credits" or "Cashpoints"

I'm adding Rare or Custom Items to my Control panel to sell it for "Vote Credits" or "Cash Points" that's all nothing else, because we do not support a Donation Feature this server is no money involve.

 

59824a6f4d1a0_Request-ItemShop.thumb.png.3b4fb7789e7205491eeba35a3498ba0b.png

 

 

We highly appreciate whoever quickly response and should you wish to be added to one of our contributors list.

 

Cianna Fernandez

Ragnarok Online Philippines (Manila Server)
https://www.ragnarokphilippines.ml/

 

Hi thank you for your help guys, actually I already made a solution with this concern, and I'm sorry If I made a spammed post, This request is solved.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...