Ok, I have an issue here. I am trying to create a module that will award people for winning something. The thing is that some of the wizard actions I can not allow like adding a stat to a user if I want to be able to add an item to a users inventory or the other way around. The reason being is because of the $userId variable which you cant set in the table editor and because that is a global variable for the current logged in user it tends to muck things up.
Here is my function I am trying to create:
Code: Select all
function RewardEventWinner($eventId,$user)
{
global $db,$userId;
$userId = $user;
$award = $db->Execute("select event_prize from koth_events where id = ?",$eventId);
if(!$award->EOF)
{
$userStats = UserStat::LoadStats($user);
NWEval($award->fields[0]);
UserStat::SaveStats(NULL,$user);
$db->Execute("update users set stats_modified = 'yes' where id = ?", $user);
}
}
If I take out the global for the $userId and what is on line 4 I wont be able to award an Item and can only award a stat change. And If I keep those lines in I can add an Item but when it comes to a stats change it gives that user my amount of that stat.
Is there anyone here who can maybe think of a work around?