Guest User

Untitled

a guest
Feb 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. bool Farming::hasFarmPoints(Player * player, bool IsPriced, uint32 addpoints, uint32 points)
  2. {
  3.     QueryResult result;
  4.     result = WorldDatabase.PQuery("SELECT points FROM farmer_points WHERE guid='%u' LIMIT 1", player->GetGUID());
  5.     if(!result)
  6.         return false;
  7.  
  8.     uint32 currentpoints;
  9.  
  10.     if(result)
  11.     {
  12.         do
  13.         {
  14.             Field * fields = result->Fetch();
  15.             currentpoints = fields[0].GetInt32();
  16.  
  17.             if(currentpoints > points)
  18.             {
  19.                 if(IsPriced == true)// Here if it is true we will add the points
  20.                     WorldDatabase.PQuery("UPDATE farmer_points SET points='%u' WHERE (guid='%u') LIMIT 1", currentpoints + addpoints, player->GetGUID());
  21.                 else// Else, we will take the points
  22.                     WorldDatabase.PQuery("UPDATE farmer_points SET points='%u' WHERE (guid='%u') LIMIT 1", currentpoints - points, player->GetGUID());
  23.             }
  24.             else
  25.             {
  26.                 Notice(player, "You don't have enough farm points!", MSG_COLOR_RED);
  27.                 return false;
  28.             }
  29.         }while(result->NextRow());
  30.     }
  31.     return true;
  32. }
Add Comment
Please, Sign In to add comment