Jump to content
MakeWebGames

Give Premium to user


Recommended Posts

I have made this little module, it will allow admins to give users premium for the amount of days the admin desire

you can find the module here

http://nw-engine.com/index.php?c=modules&m=153

if you have any idear to improvement just write it here or send me a pm.

/Sjobbe

And Thanks to Kyle for his expertise/help..

Congrats on your first submission. And no problem, it was my pleasure. I hope to see what you come up with next

Also what I would do is send some sort of notification to the player that you gave premium days to and let him/her know:

 
if (function_exists("SendMessage"))
   SendMessage($_POST["user"],"Look What You Got",Translate("You have just been givin %s Premium Days for being so awesome",$_POST["Days"]),1);

Something like that otherwise they have no idea what has happened

Edited by KyleMassacre
spelling error
Link to comment
Share on other sites

overwrite your content.php with this one..

 

<?php

if (! IsModerator())
{
   header("Location: index.php");
   return;
}
TableHeader("Add Days");
if (isset($_POST['user']))
{
if(!FindUser($_POST["user"]))
{
    ErrorMessage("Selected user is invalid");
           return;
}

   else if (!isset($_POST['Days']))
   {
       ErrorMessage("You must select the amount of days to give");
       return;
   }

   else
   {
 $currentMembership = GetUserVariable(premiumMember);
           // Initial value or old membership
           if ($currentMembership == null || $currentMembership + 0 < time())
               $currentMembership = time() + (GetConfigValue("premiumMembershipDuration", "premium") * $_POST["Days"] * 48 * 60);
               // Adding to the current membership
           else
               $currentMembership += (GetConfigValue("premiumMembershipDuration", "premium") * $_POST["Days"] * 48 * 60);
           SetUserVariable(premiumMember, $currentMembership);

		// REMOVED FOLLING LINES THESE ARE NOT NEEDED ANY MORE BUT WILL KEEP FOR FUTURE USE..
    //$newValue = (GetUserVariable(premiumMember,$_POST["user"]) + $_POST["Days"]) + 0;
    //SetUserVariable(premiumMember, $newValue, $_POST["user"]);


    ResultMessage(Translate("New value is % s", TimeInterval(time(), GetUserVariable(premiumMember,$_POST["user"]))));
}
}
echo "<form method='post' name='AddPremiumdays'>";
echo "<table class='plainTable'>";
echo "<tr><td width='1%' valign='top'><b>" . str_replace(" "," ",Translate("User:")) . "</b></td><td>" . SmartSelection("select id,username from users where id <> 1", "user", $userId) . "</td></tr>";
echo "<tr><td width='1%' valign='top'><b>" . str_replace(" "," ",Translate("Days:")) . "</b></td><td><input type='text' name='Days' placeholder='Amount of days'></td></tr>";

// leave below lines unedited this will come in useful for a later addition if needed..

/*if (GetUserVariable(premiumMember) == 0) {
echo Translate("User has no days left");
}
else
echo Translate("user has %s.", TimeInterval(time(), GetUserVariable(premiumMember))) ."<br>";*/

echo "</table>";
echo "</form>";
TableFooter();
ButtonArea();
SubmitButton("Add Days", "AddPremiumdays");
EndButtonArea();
Link to comment
Share on other sites

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...