• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Paying for help with this error!

Shanksera

New Member
Joined
Sep 23, 2008
Messages
379
Reaction score
1
Hello.I've using NICAW AAC v3.20 for my server (Avesta).I can make account and when i trying to maker player the error is:

Code:
Player::make() Cannot insert attributes:Error #1452
INSERT INTO `players` (`id`,`name`,`account_id`,`group_id`,`rank_id`,`vocation`,`sex`,`level`,`experience`,`health`,`healthmax`,`looktype`,`maglevel`,`mana`,`manamax`,`cap`,`town_id`,`posx`,`posy`,`posz`,`conditions`) VALUES (NULL,'Nicawtopedal',882171,1,0,1,1,10,9300,195,195,130,0,95,95,490,3,32369,32241,7,'');
Cannot add or update a child row: a foreign key constraint fails (`old`.`players`, CONSTRAINT `players_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`))
player.php on line: 192Script was terminated because something unexpected happened. You can report this, if you think it's a bug.

player.php

Code:
*/
class Player extends SQL
{
private $attrs, $skills, $storage;

public function __construct()
	{
		parent::__construct();
	}
	
public function find($name)
	{
		$player = $this->myRetrieve('players', array('name' => $name));
		if ($player === false) return false;
		$this->load($player['id']);
		return true;
	}

public function load($id)
	{
		//I don't load complete data like items etc, just the stuff I need
		$player = $this->myRetrieve('players', array('id' => $id));
		if ($player === false) return false;
		$group = $this->myRetrieve('groups', array('id' => (int) $player['group_id']));
		if ($group === false)
			$this->attrs['access'] = 0;
		else{
			$this->attrs['group'] = (int) $player['group_id'];
			$this->attrs['access'] = (int) $group['access'];
			$this->attrs['position'] = (string) $group['name'];
		}
		$this->attrs['id'] = (int) $player['id'];
		$this->attrs['name'] = (string) $player['name'];
		$this->attrs['account'] = (int) $player['account_id'];
		$this->attrs['level'] = (int) $player['level'];
		$this->attrs['vocation'] = (int) $player['vocation'];
		$this->attrs['experience'] = (int) $player['experience'];
		$this->attrs['promoted'] = 0;
		$this->attrs['maglevel'] = (int) $player['maglevel'];
		$this->attrs['city'] = (int) $player['town_id'];
		$this->attrs['sex'] = (int) $player['sex'];
		$this->attrs['lastlogin'] = (int) $player['lastlogin'];
		$this->attrs['redskulltime'] = (int) $player['redskulltime'];
		$this->attrs['spawn']['x'] = (int) $player['posx'];
		$this->attrs['spawn']['y'] = (int) $player['posy'];
		$this->attrs['spawn']['z'] = (int) $player['posz'];
		//get skills
		$this->myQuery('SELECT * FROM `player_skills` WHERE `player_id` = '.$this->attrs['id']);
		if ($this->failed()) throw new Exception('Cannot retrieve player skills<br/>'.$this->getError());
		while($a = $this->fetch_array()){
			$this->skills[$a['skillid']]['skill'] = (int)$a['value'];
			$this->skills[$a['skillid']]['tries'] = (int)$a['count'];
		}
		//get storage
		$this->myQuery('SELECT * FROM `player_storage` WHERE `player_id` = '.$this->attrs['id']);
		if ($this->failed()) throw new Exception('Cannot retrieve player storage<br/>'.$this->gerError());
		while($a = $this->fetch_array())
			$this->storage[$a['key']] = (int)$a['value'];
		//get guild stuff
		$this->myQuery("SELECT players.guildnick, guild_ranks.level, guild_ranks.name, guilds.id, guilds.name FROM guild_ranks, players, guilds WHERE guilds.id = guild_ranks.guild_id AND players.rank_id = guild_ranks.id AND players.id = ".$this->attrs['id']);
		if (!$this->failed() && $this->num_rows() == 1){
			$a = $this->fetch_array();
			$this->attrs['guild_nick'] = $a[0];
			$this->attrs['guild_level'] = $a[1];
			$this->attrs['guild_rank'] = $a[2];
			$this->attrs['guild_id'] = $a[3];
			$this->attrs['guild_name'] = $a[4];
		}
		return true;
	}

public function save()
	{
		$d['group_id'] = $this->attrs['group'];
		$d['name'] = $this->attrs['name'];
		$d['account_id'] = $this->attrs['account'];
		$d['level'] = $this->attrs['level'];
		$d['vocation'] = $this->attrs['vocation'];
		$d['experience'] = $this->attrs['experience'];
		$d['maglevel'] = $this->attrs['maglevel'];
		$d['town_id'] = $this->attrs['city'];
		$d['sex'] = $this->attrs['sex'];
		$d['redskulltime'] = (int) $player['redskulltime'];
		
		return $this->myUpdate('players', $d, array('id' => $this->attrs['id']));
	}

public function exists()
	{
		$this->myQuery('SELECT * FROM `players` WHERE `name` = '.$this->quote($this->attrs['name']));
		if ($this->failed()) throw new Exception('Player::exists() cannot determine whether player exists');
		if ($this->num_rows() > 0) return true;
		return false;
	}

public function getAttr($attr)
	{
		return $this->attrs[$attr];
	}

public function isAttr($attr)
	{
		return isset($this->attrs[$attr]);
	}

public function setAttr($attr,$value)
	{
		$this->attrs[$attr] = $value;
	}
	
public function getStorage($id)
	{
		return $this->storage[$id];
	}

public function getDeaths()
	{
		$query = "SELECT * FROM `player_deaths` WHERE (`player_id` = '".$this->escape_string($this->attrs['id'])."') ORDER BY time DESC LIMIT 10";
		$this->myQuery($query);
		if ($this->failed()) throw new Exception('Cannot retrieve deaths! This is only compatible with TFS.'.$this->getError());;
		$i = 0;
		while($a = $this->fetch_array()){
			$list[$i]['killer'] = $a['killed_by'];
			$list[$i]['level'] = $a['level'];
			$list[$i]['date'] = $a['time'];
			$i++;
		}
		return $list;
	}

public function getSkill($n)
	{
		return $this->skills[$n]['skill'];
	}

public function delete()
	{
			return $this->myDelete('players',array('id' => $this->attrs['id']),0)
			&& $this->myDelete('player_items',array('player_id' => $this->attrs['id']),0)
			&& $this->myDelete('player_depotitems',array('player_id' => $this->attrs['id']),0)
			&& $this->myDelete('player_skills',array('player_id' => $this->attrs['id']),0)
			&& $this->myDelete('player_storage',array('player_id' => $this->attrs['id']),0)
			&& $this->myDelete('player_viplist',array('player_id' => $this->attrs['id']),0);
	}

public function create()
	{global $cfg;

		if ($this->exists())
			throw new Exception('Player already exists');

		//make player
		$d['id']			= NULL;
		$d['name']			= $this->attrs['name'];
		$d['account_id']	= $this->attrs['account'];
		$d['group_id']		= $cfg['vocations'][$this->attrs['vocation']]['group'];
		$d['rank_id']		= 0;
		$d['vocation']		= $this->attrs['vocation'];
		$d['sex']			= $this->attrs['sex'];
		$d['level']			= getVocLvl($this->attrs['vocation']);
		$d['experience']	= getVocExp($this->attrs['vocation']);
		$d['health']		= $cfg['vocations'][$this->attrs['vocation']]['health'];
		$d['healthmax']		= $cfg['vocations'][$this->attrs['vocation']]['health'];
		$d['looktype']		= $cfg['vocations'][$this->attrs['vocation']]['look'][(int)$this->attrs['sex']];
		$d['maglevel']		= $cfg['vocations'][$this->attrs['vocation']]['maglevel'];
		$d['mana']			= $cfg['vocations'][$this->attrs['vocation']]['mana'];
		$d['manamax']		= $cfg['vocations'][$this->attrs['vocation']]['mana'];
		$d['cap']			= $cfg['vocations'][$this->attrs['vocation']]['cap'];
		$d['town_id']		= $this->attrs['city'];
		$d['posx']			= $cfg['temple'][$this->attrs['city']]['x'];
		$d['posy']			= $cfg['temple'][$this->attrs['city']]['y'];
		$d['posz']			= $cfg['temple'][$this->attrs['city']]['z'];
		$d['conditions']	= '';
		
		if (!$this->myInsert('players',$d)) throw new Exception('Player::make() Cannot insert attributes:<br/>'.$this->getError());
		$this->attrs['id'] = $this->insert_id();

		unset($d);

		//make items
		$sid = 100;
		while ($item = current($cfg['vocations'][$this->attrs['vocation']]['equipment'])){
			$sid++;
			$d['player_id']	= $this->attrs['id'];
			$d['pid']		= key($cfg['vocations'][$this->attrs['vocation']]['equipment']);
			$d['sid']		= $sid;
			$d['itemtype']	= $item;
			$d['attributes']= '';
			
			if (!$this->myInsert('player_items',$d)) throw new Exception('Player::make() Cannot insert items:<br/>'.$this->getError());
			unset($d);
			next($cfg['vocations'][$this->attrs['vocation']]['equipment']);
		}

		//make skills only if not created by trigger
		$this->myQuery('SELECT COUNT(player_skills.skillid) as count FROM player_skills WHERE player_id = '.$this->quote($this->attrs['id']));
		$a = $this->fetch_array();
		$i = 0;
		while ($skill = current($cfg['vocations'][(int)$this->attrs['vocation']]['skills'])){
			$skill_id	= key($cfg['vocations'][(int)$this->attrs['vocation']]['skills']);

			if ($a['count'] == 0){
				if (!$this->myInsert('player_skills',array('player_id' => $this->attrs['id'], 'skillid' => $skill_id, 'value' => $skill, 'count' => 0))) 
					throw new Exception('Player::make() Cannot insert skills:<br/>'.$this->getError());
			}else{
				if (!$this->myUpdate('player_skills',array('value' => $skill),array('player_id' => $this->attrs['id'], 'skillid' => $skill_id))) 
					throw new Exception('Player::make() Cannot update skills:<br/>'.$this->getError());
			}

			next($cfg['vocations'][$this->attrs['vocation']]['skills']);
		}
	return $this->load($this->attrs['id']);
	}

public function repair()
	{global $cfg;
		$lvl = $this->attrs['level'];
		$exp = AAC::getExperienceByLevel($lvl);
		if (!$this->myUpdate('players',array(
			'posx' => $cfg['temple'][$this->attrs['city']]['x'],
			'posy' => $cfg['temple'][$this->attrs['city']]['y'],
			'posz' => $cfg['temple'][$this->attrs['city']]['z']
			/*, 'experience' => $exp*/), array('id' => $this->attrs['id']))) throw new Exception($this->getError());
		return $this->load($this->attrs['id']);
	}
}
?>

Foreign key players.group_id.
- It must not be possible to create player with key of unexisting group.

Someone told me the bug is in my DB.I need table for groups , but which table?
 
Is the nicaw AAC you're using supported for avesta 7.6 distributions?

Otherwise, use the AAC (specifically made) for avesta distribution, you can find it in "Website Applications".
 
Yes that's nicaw aac its support Avesta.I works on my 7.6 , but on 7.4 doesn't work and which acc maker is specifically made for Avesta?
 
Nicaw says:
Group ID doesnt exists thus breaking data integrity. Create groups!

Schema.mysql -where to add group_id?
Code:
CREATE TABLE `groups` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(255) NOT NULL COMMENT 'group name',
    `flags` BIGINT UNSIGNED NOT NULL DEFAULT 0,
    `access` INT NOT NULL,
    `maxdepotitems` INT NOT NULL,
    `maxviplist` INT NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB;

CREATE TABLE `accounts` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `password` VARCHAR(255) NOT NULL/* VARCHAR(32) NOT NULL COMMENT 'MD5'*//* VARCHAR(40) NOT NULL COMMENT 'SHA1'*/,
    `email` VARCHAR(255) NOT NULL DEFAULT '',
    `premend` INT UNSIGNED NOT NULL DEFAULT 0,
    `blocked` TINYINT(1) NOT NULL DEFAULT FALSE,
    `deleted` TINYINT(1) NOT NULL DEFAULT FALSE,
    `warned` TINYINT(1) NOT NULL DEFAULT FALSE,
    `warnings` INT NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB;

CREATE TABLE `players` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(255) NOT NULL,
    `account_id` INT UNSIGNED NOT NULL,
    `group_id` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'users group',
    `sex` INT UNSIGNED NOT NULL DEFAULT 0,
    `vocation` INT UNSIGNED NOT NULL DEFAULT 0,
    `experience` BIGINT UNSIGNED NOT NULL DEFAULT 0,
    `level` INT UNSIGNED NOT NULL DEFAULT 1,
    `maglevel` INT UNSIGNED NOT NULL DEFAULT 0,
    `health` INT UNSIGNED NOT NULL DEFAULT 100,
    `healthmax` INT UNSIGNED NOT NULL DEFAULT 100,
    `mana` INT UNSIGNED NOT NULL DEFAULT 100,
    `manamax` INT UNSIGNED NOT NULL DEFAULT 100,
    `manaspent` INT UNSIGNED NOT NULL DEFAULT 0,
    `soul` INT UNSIGNED NOT NULL DEFAULT 0,
    `direction` INT UNSIGNED NOT NULL DEFAULT 0,
    `lookbody` INT UNSIGNED NOT NULL DEFAULT 10,
    `lookfeet` INT UNSIGNED NOT NULL DEFAULT 10,
    `lookhead` INT UNSIGNED NOT NULL DEFAULT 10,
    `looklegs` INT UNSIGNED NOT NULL DEFAULT 10,
    `looktype` INT UNSIGNED NOT NULL DEFAULT 136,
    `posx` INT NOT NULL DEFAULT 0,
    `posy` INT NOT NULL DEFAULT 0,
    `posz` INT NOT NULL DEFAULT 0,
    `cap` INT NOT NULL DEFAULT 0,
    `lastlogin` INT UNSIGNED NOT NULL DEFAULT 0,
    `lastlogout` INT UNSIGNED NOT NULL DEFAULT 0,
    `lastip` INT UNSIGNED NOT NULL DEFAULT 0,
    `save` TINYINT(1) NOT NULL DEFAULT TRUE,
    `conditions` BLOB NOT NULL COMMENT 'drunk, poisoned etc (maybe also food and redskull)',
    `redskulltime` INT UNSIGNED NOT NULL DEFAULT 0,
    `redskull` TINYINT(1) NOT NULL DEFAULT FALSE,
    `guildnick` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'additional nick in guild - mostly for web interfaces i think',
    `loss_experience` INT NOT NULL DEFAULT 10,
    `loss_mana` INT NOT NULL DEFAULT 10,
    `loss_skills` INT NOT NULL DEFAULT 10,
    `loss_items` INT NOT NULL DEFAULT 10,
    `rank_id` INT UNSIGNED NOT NULL COMMENT 'by this field everything with guilds is done - player has a rank which belongs to certain guild',
    `town_id` INT NOT NULL COMMENT 'old masterpos, temple spawn point position',
    `balance` INT NOT NULL DEFAULT 0 COMMENT 'money balance of the player for houses paying',
    `status` TINYINT(1) NOT NULL DEFAULT FALSE,
    PRIMARY KEY (`id`),
    UNIQUE (`name`),
    FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE,
    FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`)
) ENGINE = InnoDB;

CREATE TABLE `guilds` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(255) NOT NULL COMMENT 'guild name - nothing else needed here',
    `ownerid` INT NOT NULL,
    `creationdata` INT NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB;

CREATE TABLE `guild_ranks` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `guild_id` INT UNSIGNED NOT NULL COMMENT 'guild',
    `name` VARCHAR(255) NOT NULL COMMENT 'rank name',
    `level` INT NOT NULL COMMENT 'rank level - leader, vice, member, maybe something else',
    PRIMARY KEY (`id`),
    FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `player_viplist` (
    `player_id` INT UNSIGNED NOT NULL COMMENT 'id of player whose viplist entry it is',
    `vip_id` INT UNSIGNED NOT NULL COMMENT 'id of target player of viplist entry',
    FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE,
    FOREIGN KEY (`vip_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `player_spells` (
    `player_id` INT UNSIGNED NOT NULL,
    `name` VARCHAR(255) NOT NULL,
    FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `server_record` (
	`record` INT UNSIGNED NOT NULL,
      PRIMARY KEY(`record`)
) ENGINE = InnoDB;

INSERT INTO `server_record` VALUES (0);

CREATE TABLE `player_storage` (
    `player_id` INT UNSIGNED NOT NULL,
    `key` INT NOT NULL,
    `value` INT NOT NULL,
    FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `player_skills` (
    `player_id` INT UNSIGNED NOT NULL,
    `skillid` INT UNSIGNED NOT NULL,
    `value` INT UNSIGNED NOT NULL DEFAULT 0,
    `count` INT UNSIGNED NOT NULL DEFAULT 0,
    FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `player_items` (
    `player_id` INT UNSIGNED NOT NULL,
    `sid` INT NOT NULL,
    `pid` INT NOT NULL DEFAULT 0,
    `itemtype` INT NOT NULL,
    `count` INT NOT NULL DEFAULT 0,
    `attributes` BLOB COMMENT 'replaces unique_id, action_id, text, special_desc',
    FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE,
    UNIQUE (`player_id`, `sid`)
) ENGINE = InnoDB;

CREATE TABLE `houses` (
    `id` INT UNSIGNED NOT NULL,
    `owner` INT NOT NULL,
    `paid` INT UNSIGNED NOT NULL DEFAULT 0,
    `warnings` INT NOT NULL DEFAULT 0,
    `lastwarning` INT UNSIGNED NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB;

CREATE TABLE `house_lists` (
    `house_id` INT UNSIGNED NOT NULL,
    `listid` INT NOT NULL,
    `list` TEXT NOT NULL,
    FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `bans` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `type` INT NOT NULL COMMENT 'this field defines if its ip, account, player, or any else ban',
    `value` INT UNSIGNED NOT NULL COMMENT 'ip, player guid, account number',
    `param` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'mask',
    `active` TINYINT(1) NOT NULL DEFAULT TRUE,
    `expires` INT UNSIGNED NOT NULL,
    `added` INT UNSIGNED NOT NULL,
    `admin_id` INT UNSIGNED NOT NULL DEFAULT 0,
    `reason` VARCHAR(255) NOT NULL DEFAULT '',
    `comment` VARCHAR(255) NOT NULL DEFAULT '',
    PRIMARY KEY  (`id`),
    KEY (`type`, `value`),
    KEY (`expires`)
) ENGINE = InnoDB;

CREATE TABLE `tiles` (
    `id` INT UNSIGNED NOT NULL,
    `x` INT NOT NULL,
    `y` INT NOT NULL,
    `z` INT NOT NULL,
    PRIMARY KEY(`id`)
) ENGINE = InnoDB;

CREATE TABLE `tile_items` (
    `tile_id` INT UNSIGNED NOT NULL,
    `sid` INT NOT NULL,
    `pid` INT NOT NULL DEFAULT 0,
    `itemtype` INT NOT NULL,
    `count` INT NOT NULL DEFAULT 0,
    `attributes` BLOB NOT NULL,
    FOREIGN KEY (`tile_id`) REFERENCES `tiles` (`id`) ON DELETE CASCADE,
    INDEX (`sid`)
) ENGINE = InnoDB;

CREATE TABLE `map_store` (
    `house_id` INT UNSIGNED NOT NULL,
    `data` BLOB NOT NULL,
    KEY(`house_id`)
) ENGINE = InnoDB;

CREATE TABLE `player_depotitems` (
    `player_id` INT UNSIGNED NOT NULL,
    `depot_id` INT NOT NULL DEFAULT 0,
    `sid` INT NOT NULL COMMENT 'any given range eg 0-100 will be reserved for depot lockers and all > 100 will be then normal items inside depots',
    `pid` INT NOT NULL DEFAULT 0,
    `itemtype` INT NOT NULL,
    `count` INT NOT NULL DEFAULT 0,
    `attributes` BLOB NOT NULL,
    FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE,
    INDEX (`player_id`, `depot_id`),
    UNIQUE (`player_id`, `sid`)
) ENGINE = InnoDB;

CREATE TABLE `player_deaths` (
	`player_id` INT UNSIGNED NOT NULL,
	`time` BIGINT UNSIGNED NOT NULL DEFAULT 0,
	`level` INT UNSIGNED NOT NULL DEFAULT 1,
	`lasthit_killer` VARCHAR(255) NOT NULL,
	`mostdamage_killer` VARCHAR(255) NOT NULL,
	KEY (`player_id`),
	FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `global_storage` (
    `key` INT UNSIGNED NOT NULL,
    `value` INT NOT NULL,
    PRIMARY KEY(`key`)
) ENGINE = InnoDB;

CREATE TABLE `schema_info` (
    `name` VARCHAR(255) NOT NULL,
    `value` VARCHAR(255) NOT NULL,
    PRIMARY KEY (`name`)
);

INSERT INTO `schema_info` (`name`, `value`) VALUES ('version', 3);

DELIMITER |

CREATE TRIGGER `ondelete_accounts`
BEFORE DELETE
ON `accounts`
FOR EACH ROW
BEGIN
    DELETE FROM `bans` WHERE `type` = 3 AND `value` = OLD.`id`;
END|

CREATE TRIGGER `ondelete_guilds`
BEFORE DELETE
ON `guilds`
FOR EACH ROW
BEGIN
    UPDATE `players` SET `guildnick` = '', `rank_id` = 0 WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = OLD.`id`);
    DELETE FROM `guild_ranks` WHERE `guild_id` = OLD.`id`;
END|

CREATE TRIGGER `ondelete_players`
BEFORE DELETE
ON `players`
FOR EACH ROW
BEGIN
    DELETE FROM `bans` WHERE `type` = 2 AND `value` = OLD.`id`;
    UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
END|

CREATE TRIGGER `oncreate_guilds`
AFTER INSERT
ON `guilds`
FOR EACH ROW
BEGIN
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Leader', 3, NEW.`id`);
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Vice-Leader', 2, NEW.`id`);
    INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Member', 1, NEW.`id`);
END|

CREATE TRIGGER `oncreate_players`
AFTER INSERT
ON `players`
FOR EACH ROW
BEGIN
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 0, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 1, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 2, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 3, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 4, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 5, 10);
    INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 6, 10);
END|

DELIMITER ;
 
Back
Top