CHAMAVELI Posted July 8, 2008 Share Posted July 8, 2008 Hey guys i've got a modified leveling system and I wanted a mail to send once someone can upgrade. Could someone please give me the PHP code and the MySQL queries i need for this. I am using Mccodes V2 and want to do this through the global_func.php check_level function. Thanks. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted July 8, 2008 Share Posted July 8, 2008 Re: PHP Code to send a mail when something happens Another idea for you, create a mail_add function (like stafflog_add, or event_add). Once that's done, you can just put mail_add(UserID, "Message"); Simplified for you :P And if you have a look at the check_level() function (I haven't looked at that for a while so this purely from memory) Add in there somewhere if($ir['exp'] == $ir['exp_needed']) { $newlevel = $ir['level']+1; $sql = sprintf("INSERT INTO mail VALUES ('', %u, '%s', %u, %u, '%s', '%s')", 0, "Upgrade", $r['userid'], "unix_timestamp()", "Level Upgrade", "You can upgrade your level! Click on the Upgrade link found wherever to become level $newlevel"); $db->query($sql); } Or something like that NOT tested Quote Link to comment Share on other sites More sharing options...
CHAMAVELI Posted July 9, 2008 Author Share Posted July 9, 2008 Re: PHP Code to send a mail when something happens I did one using events and it just keeps happening, is there a way to make it only send one event? Quote Link to comment Share on other sites More sharing options...
Floydian Posted July 9, 2008 Share Posted July 9, 2008 Re: PHP Code to send a mail when something happens well, it sounds like you need to put in a flag. something like, 0 you haven't sent the mail, or 1 you have sent the mail the flag is initially set to 0 once the Upgrade link is available, have it set this flag to 1 then, send the mail, if and only if, setting that flag to 1 was successful ie, if(mysql_affected_rows() > 0) {send mail} in other words, if the flag was already set, setting it to one results in 0 affected rows, and the mail is not sent again. when they actually click the upgrade link, make sure to set the flag to 0 Quote Link to comment Share on other sites More sharing options...
CHAMAVELI Posted July 9, 2008 Author Share Posted July 9, 2008 Re: PHP Code to send a mail when something happens I've given up on this, I've found a different solution to my upgrade system. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.