Jump to content
  • 0

Question

Posted

Alright, I'm trying to work on a script that helps manage characters on an account. Part of that, involves resetting the look and unsticking. I got the unsticking part, and resetting the hair color, hair style, and cloth color.

However, when resetting the look, it should also unequip everything from the player. Normally this would do something like using " nude; ". But, like when doing it from a control panel, it doesn't work if the character is offline. So I'm trying to figure out where to physically unequip everything from a player in sql. Is anyone able to help or direct me so I can find out?

2 answers to this question

Recommended Posts

  • 0
Posted

There are 2 steps to "reset look":

	/**
 * Re-set the appearance of a character.
 *
 * @param int $charID
 * @return mixed
 */
public function resetLook($charID)
{
	// Return values:
	// -1 = Character is online, cannot reset.
	// -2 = Unknown character.
	// false = Failed to reset.
	// true  = Successfully reset.

	$char = $this->getCharacter($charID);

	if (!$char) {
		return -2;
	}
	if ($char->online) {
		return -1;
	}

	$sql  = "UPDATE {$this->charMapDatabase}.inventory SET ";
	$sql .= "equip = 0 WHERE char_id = ?";
	$sth  = $this->connection->getStatement($sql);

	if (!$sth->execute(array($charID))) {
		return false;
	}

	$sql  = "UPDATE {$this->charMapDatabase}.`char` SET ";
	$sql .= "hair = 0, hair_color = 0, clothes_color = 0, weapon = 0, shield = 0, ";
	$sql .= "head_top = 0, head_mid = 0, head_bottom = 0 ";
	$sql .= "WHERE char_id = ?";
	$sth  = $this->connection->getStatement($sql);

	if (!$sth->execute(array($charID))) {
		return false;
	}
	else {
		return true;
	}
}

(12345 = their char_id)

  1.  
    UPDATE INVENTORY SET equip = 0 WHERE char_id = 12345;


  2.  
    UPDATE `char` SET hair = 0, hair_color = 0, clothes_color = 0, 
    weapon = 0, shield = 0, head_top = 0, head_mid = 0, head_bottom = 0 
    WHERE char_id = 12345;

  • 0
Posted

Good to know :) Out of the two ways, I was looking for the 2nd way you posted about updating the inventory. It was exactly what I was looking for as I couldn't seem to find where the game recognized if something was equipped. Thanks for the help Brian.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...