Jump to content

Welcome to NulledBlog
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!
Photo

Chat commands


  • Please log in to reply
1 reply to this topic

#1
BL4CKL4W

  • Offline
  • kewl dude.

  • Posts:
    214
    Reputation:
    8
    Joined:
    05 Oct, 2015

I just created a small piece of code for chat commands. You could implement it in your roulette site.

A /send command for sending coins is already implemented.

/* If first char of message is a forward slash */
	if ($message[0] == '/') {
		
		/* Split command after space */
		$args = explode(" ", $message);
		
		/* Select command to execute */
		switch ($args[0]) {
			
			/* Send coins */
			case '/send':
			if (!isset($args[1]) || !isset($args[2])) {
				// display error message to user
			}	
			
			/* Get coins from sending user */
			$query1 = "SELECT coins FROM users WHERE steamid='".$steamid."'";
			$result1 = $conn->query($query1);
			$coinrow1 = $result1->fetch_array(MYSQLI_ASSOC);
			$coins1 = $coinrow1['coins'];
			
			/* Get coins from receiving user */
			$query2 = "SELECT coins FROM users WHERE steamid='".$args[1]."'";
			$result2 = $conn->query($query2);
			$coinrow2 = $result2->fetch_array(MYSQLI_ASSOC);
			$coins2 = $coinrow2['coins'];
			
			/* Check if coins being sent are larger or equal to the coins owned */
			if ($coins1 < $args[2]) {
				
				/* Remove coins from sender */
				$sqlrem = "UPDATE users SET coins = '".bcsub($coins1, $args[2])."' WHERE steamid = '".$steamid."'";
				$result1 = $conn->query($sqlrem);	
				
				/* Add coins to receiver */
				$sqladd = "UPDATE users SET coins = '".bcadd($coins2, $args[2])."' WHERE steamid = '".$args[1]."'";
				$result2 = $conn->query($sqladd);
				
				} else {
				
				// Display error message for not having enough coins
			}
			break;
			
			/* Example command */
			case '/test':
			// do stuff
			break;
			
			/* If unknown command is entered */
			default:
			// display message to user
		}
		} else {
		
		// do message stuff as ususal
		
	}

Edited by BL4CKL4W, 08 April 2016 - 03:56 PM.

  • 0

#2
LOOKREVENGE

  • Offline
  • Member

  • PipPipPip
  • Posts:
    38
    Reputation:
    0
    Joined:
    19 Mar, 2016

thanks man


  • 0


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users