Jump to content
MakeWebGames

Javascript Award system for Mccodes?


jcvenom

Recommended Posts

I was thinking of building this award system for mccodes which i have currently made for my engine what do yous think?

Features

  • Content loaded with js
  • Over 160 awards and honors to unlock
  • Easy installation
  • Provide support if needed(Updated due to Veramis question :) )
  • Award cron
  • Awards on profile
  • Staff log for awards

Cost

Im basing the price on the duration it took for me to make the mod so im selling this mod at 20 pounds

Includes full installation if needed

what do you guys think?

I will make mods like wordwar etc if this goes well

[ATTACH=CONFIG]2091[/ATTACH]

[ATTACH=CONFIG]2092[/ATTACH]

[ATTACH=CONFIG]2093[/ATTACH]

[ATTACH=CONFIG]2094[/ATTACH]

[ATTACH=CONFIG]2095[/ATTACH]

[ATTACH=CONFIG]2096[/ATTACH]

award1.thumb.png.dd7908b15f276d2c47b12958221b68fa.png

award2.thumb.png.4ac94e73c5271dccbc01eb15653f091f.png

award3.thumb.png.1f6ad88a1c82df4525d963bb750f66ab.png

award4.thumb.png.30a3dcf0b8e9708905cbd4d34e2ffbbf.png

award5.thumb.png.8330359ce4d4dec7ad83625e17f584c7.png

award6.thumb.png.c856e8aab10727aa4e2b7591002e633c.png

Edited by jcvenom
Link to comment
Share on other sites

i think the price is to high too 20 gbp per sale but looking nice

project price / expected amount of sales = sale price

i use this to work out a rough price for my modules

20GBP isn't too expensive for someones time.

[MENTION=69823]jcvenom[/MENTION] how flexible are the awards? Ie: Do you have to hardcode the criteria or can you put the awards into a database and they'll get given via cron logic?

Link to comment
Share on other sites

20GBP isn't too expensive for someones time.

[MENTION=69823]jcvenom[/MENTION] how flexible are the awards? Ie: Do you have to hardcode the criteria or can you put the awards into a database and they'll get given via cron logic?

The awards are not hard coded all they require is a class, in the staff panel you can create the award and add a class(the list of classes that come with the mod will be listed in a file, there are 17 default classes because ive already added 160 awards, so you can change them or add more if you want) for example the class for attack = 1; so if i wanted to create an award for attack i'd create the award and give it a class of 1, it then loads class one from memeber_awards and loads it into the file and so on. The only thing that is hard coded is how your awards work, e.g you attack a certain user it logs it into a table once a cron then runs and the user gains the award its a very workable system. Since im building it for v2 if any changes are wanted feel free to post here and i will look into adding or removing them, i hope that answers your question [MENTION=65371]sniko[/MENTION] :)

Edited by jcvenom
Link to comment
Share on other sites

If i were coding this i would first make a system to store and show stats, then once you have this then code the achievements on top. Something like

<?php

/*
	CREATE TABLE `statistics` (
		`user` int PRIMARY KEY, 
		`type` int PRIMARY KEY,
		`success` int, 
		`fail` int
	);

	CREATE TABLE `statisticTypes` (
		`id` int PRIMARY KEY AUTO_INCREMENT, 
		`name` varchar(255)
	);
*/

class Stats {

	public function __construct($uid = false) {

		//$database_connection = new PDO();
		$this->db = $database_connection;

		if ($uid) {
			$this->uid = $uid;
		} else {
			$this->uid = $_SESSION["uid"];
		}

	}

	private function addNewType($typeName) {

		$insertType = $this->db->prepare("INSERT INTO `statisticTypes` (`id`, `name`) VALUES (NULL, :name);");
		$insertType->bindParam(":name", $typeName);
		$insertType->execute();

		return $this->db->lastInsertId();

	}

	private function getTypeID($typeName) {

		$selectType = $this->db->prepare("SELECT `id` FROM `statisticTypes` WHERE `name` = :name");
		$selectType->bindParam(":name", $typeName);
		$selectType->execute();

		$type = $selectType->fetch(PDO::FETCH_ASSOC);

		if (!empty($type["id"]) {
			return $type["id"];
		} else {
			return $this->addNewType($typeName);
		}

	}

	private function insert($typeName, $success = false) {

		$typeID = $this->getTypeID($typeName);

		$col = ($success?"success":"fail");
		$altCol = ($success?"fail":"success");

		$updateStat = $this->db->prepare("UPDATE `statistics` SET `".$col."`=`".$col."`+1 WHERE `user` = :uid AND `type` = :type");
		$updateStat->bindParam(":uid", $this->uid);
		$updateStat->bindParam(":type", $typeID);

		if (!$updateStat->execute()) {
			$insertStat = $this->db->prepare("INSERT INTO `statistics` (`user`, `type`, `".$col."`, `".$altCol."`) VALUES (:user, :type, 1, 0);");
			$insertStat->bindParam(":uid", $this->uid);
			$insertStat->bindParam(":type", $typeID);
			$insertStat->execute();
		}
	}

	public function fail($typeName) {
		$this->insert($typeName, false);
	}

	public function success($typeName) {
		$this->insert($typeName, true);
	}

};

$attacker = new Stats($user1);
$defender = new Stats($user2);

$attacker->fail("attack");
$defender->success("defence");

Ive just thrown this together untested so will need some work. If you coded it like this module makers could implement it without doing anything in the database.

Link to comment
Share on other sites

If i were coding this i would first make a system to store and show stats, then once you have this then code the achievements on top. Something like

 

<?php

/*
	CREATE TABLE `statistics` (
		`user` int PRIMARY KEY, 
		`type` int PRIMARY KEY,
		`success` int, 
		`fail` int
	);

	CREATE TABLE `statisticTypes` (
		`id` int PRIMARY KEY AUTO_INCREMENT, 
		`name` varchar(255)
	);
*/

class Stats {

	public function __construct($uid = false) {

		//$database_connection = new PDO();
		$this->db = $database_connection;

		if ($uid) {
			$this->uid = $uid;
		} else {
			$this->uid = $_SESSION["uid"];
		}

	}

	private function addNewType($typeName) {

		$insertType = $this->db->prepare("INSERT INTO `statisticTypes` (`id`, `name`) VALUES (NULL, :name);");
		$insertType->bindParam(":name", $typeName);
		$insertType->execute();

		return $this->db->lastInsertId();

	}

	private function getTypeID($typeName) {

		$selectType = $this->db->prepare("SELECT `id` FROM `statisticTypes` WHERE `name` = :name");
		$selectType->bindParam(":name", $typeName);
		$selectType->execute();

		$type = $selectType->fetch(PDO::FETCH_ASSOC);

		if (!empty($type["id"]) {
			return $type["id"];
		} else {
			return $this->addNewType($typeName);
		}

	}

	private function insert($typeName, $success = false) {

		$typeID = $this->getTypeID($typeName);

		$col = ($success?"success":"fail");
		$altCol = ($success?"fail":"success");

		$updateStat = $this->db->prepare("UPDATE `statistics` SET `".$col."`=`".$col."`+1 WHERE `user` = :uid AND `type` = :type");
		$updateStat->bindParam(":uid", $this->uid);
		$updateStat->bindParam(":type", $typeID);

		if (!$updateStat->execute()) {
			$insertStat = $this->db->prepare("INSERT INTO `statistics` (`user`, `type`, `".$col."`, `".$altCol."`) VALUES (:user, :type, 1, 0);");
			$insertStat->bindParam(":uid", $this->uid);
			$insertStat->bindParam(":type", $typeID);
			$insertStat->execute();
		}
	}

	public function fail($typeName) {
		$this->insert($typeName, false);
	}

	public function success($typeName) {
		$this->insert($typeName, true);
	}

};

$attacker = new Stats($user1);
$defender = new Stats($user2);

$attacker->fail("attack");
$defender->success("defence");

 

Ive just thrown this together untested so will need some work. If you coded it like this module makers could implement it without doing anything in the database.

I havent coded it in OOP php, and im dont really have much experience in OOP php i never had time to learn it looks very complex

Link to comment
Share on other sites

It's a great way to create easily-extendible, organised applications involving the DRY principle.

Also, you can have some fun with it ;) https://eval.in/377301

I know most of the basics of OOP but when you get to things like the static operator ( :: ) and stuff like that and PDO i question why i bothered learning the original php in the first place, OOP looks like another long chapter of a book

Link to comment
Share on other sites

I know most of the basics of OOP but when you get to things like the static operator ( :: ) and stuff like that and PDO i question why i bothered learning the original php in the first place, OOP looks like another long chapter of a book

Static means you can call the property/method without instantiating the object. It's quite handy. See: http://verraes.net/2014/06/when-to-use-static-methods-in-php/

Link to comment
Share on other sites

20GBP isn't too expensive for someones time.

[MENTION=69823]jcvenom[/MENTION] how flexible are the awards? Ie: Do you have to hardcode the criteria or can you put the awards into a database and they'll get given via cron logic?

i just meant me in general i believe the price is to high for me but everyone has there own opinions and prices

Link to comment
Share on other sites

This is an estimate, when i complete the mod i may lower the price slightly

I wouldn't.

 

  • You will need to cover the cost of your investment (your time)
  • You will need to cover the cost of the "24/7 support"

 

But hey, it's up to you...

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
Reply to this topic...

×   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...