Skip to content

Commit 7ab1c11

Browse files
committed
* fixed saving custom vocations in admin panel (#36)
1 parent 792770e commit 7ab1c11

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

system/pages/admin/players.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ function verify_number($number, $name, $max_length) {
120120
verify_number($experience, 'Experience', 20);
121121

122122
$vocation = $_POST['vocation'];
123-
verify_number($vocation, 'Vocation id', 1);
123+
verify_number($vocation, 'Vocation id', 11);
124+
125+
if(!isset($config['vocations'][$vocation])) {
126+
echo_error("Vocation with this id doesn't exist.");
127+
}
124128

125129
// health
126130
$health = $_POST['health'];
@@ -357,14 +361,12 @@ function verify_number($number, $name, $max_length) {
357361
<td>
358362
<select name="vocation">
359363
<?php
360-
$i = 0;
361-
foreach($config['vocations'] as $voc)
364+
foreach($config['vocations'] as $id => $name)
362365
{
363-
echo '<option value=' . $i;
364-
if($i == $player->getVocation())
366+
echo '<option value=' . $id;
367+
if($id == $player->getVocation())
365368
echo ' selected="selected"';
366-
echo '>' . $voc . '</option>';
367-
$i++;
369+
echo '>' . $name . '</option>';
368370
}
369371

370372

0 commit comments

Comments
 (0)