I can not see anything wrong with what you have and I do not have time right now to test it. Here is what I do with my guards.
Code:
sub EVENT_SPAWN {
@races = (1..12);
@weapons = (10518, 10519, 10625, 10657, 10786);
$racesNum = @races;
$weaponsNum = @weapons;
quest::npcrace($races[int(rand($racesNum))]);
quest::npctexture(3);
quest::wearchange(7, $weapons[int(rand($weaponsNum))]);
quest::wearchange(8, $weapons[int(rand($weaponsNum))]);
}