Jump to content
MakeWebGames

Recommended Posts

Posted

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.

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...