I think it depends on exactly what you are trying to do. But, if you just want a player to cast a buff on themselves, this command should work:
Code:
quest::selfcast(spellid);
I haven't tested this, but if you want to change a target, maybe something like this would work:
Code:
my $cname = $client->GetCleanName();
my $get_client = $entity_list->GetClientByName($cname);
$client->SetTarget($get_client);