Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. int ServerGameLogic::Cmd_GiveItem(obj_ServerPlayer* plr, const char* cmd, bool toeveryone, bool topremium)
  2. {
  3. char buf[128];
  4. int itemid;
  5. int count = 1;
  6.  
  7.  
  8. if(2 > sscanf(cmd, "%s %d %d", buf, &itemid, &count))
  9. return 2;
  10.  
  11. if(g_pWeaponArmory->getConfig(itemid) == NULL) {
  12. r3dOutToLog("Cmd_GiveItem: no item %d\n", itemid);
  13. return 3;
  14.  
  15.  
  16.  
  17. }
  18.  
  19. bool logGiveItem=true;
  20.  
  21. #ifdef DISABLE_GI_ACCESS_ON_PTE_MAP
  22. if(ginfo_.channel==6) // don't care about PTE maps, as nothing there is saved
  23. logGiveItem=false;
  24. #endif
  25. #ifdef DISABLE_GI_ACCESS_ON_PTE_STRONGHOLD_MAP
  26. if(ginfo_.channel==6 && ginfo_.mapId==GBGameInfo::MAPID_WZ_Cliffside) // don't care about PTE maps, as nothing there is saved
  27. logGiveItem=false;
  28. #endif
  29. #ifdef DISABLE_GI_ACCESS_FOR_CALI_SERVER
  30. if(gServerLogic.ginfo_.mapId==GBGameInfo::MAPID_WZ_California)
  31. logGiveItem=false;
  32. #endif
  33.  
  34.  
  35. if(logGiveItem)
  36. LogCheat(plr->peerId_, PKT_S2C_CheatWarning_s::CHEAT_AdminGiveItem, 0, "Admin Spawn Item", "%d (%s) spawned %d with quantity %d on server %s\n", plr->profile_.CustomerID, plr->userName, itemid, count, ginfo_.name);
  37. char* itemname="";
  38.  
  39.  
  40. const BaseItemConfig* getitem = g_pWeaponArmory->getConfig(itemid);
  41.  
  42. if(getitem)
  43. itemname = getitem->m_StoreName;
  44.  
  45. if(toeveryone)
  46. {
  47. //give item to all players.
  48. for(int i=0; i<curPlayers_; i++) {
  49. obj_ServerPlayer* player = plrList_[i];
  50.  
  51. if(player->loadout_->Alive == 0) // do not give item to death players !
  52. continue;
  53.  
  54.  
  55. if(player->profile_.ProfileData.PremiumAcc < 0 && topremium ) // only give item if user is premium !
  56. continue;
  57.  
  58.  
  59. char msg[512]="";
  60.  
  61.  
  62. sprintf(msg,"Player: %s Rewarded with: %s ",player->loadout_->Gamertag, itemname);
  63. PKT_C2C_ChatMessage_s n;
  64. n.userFlag = 0;
  65. n.msgChannel = 1;
  66. r3dscpy(n.msg, msg);
  67. r3dscpy(n.gamertag, "[GiveItem]");
  68. gServerLogic.p2pBroadcastToAll(&n, sizeof(n), true);
  69.  
  70.  
  71. wiInventoryItem wi;
  72. wi.itemID = itemid;
  73. wi.quantity = count;
  74. player->BackpackAddItem(wi);
  75.  
  76. }
  77. }
  78. else
  79. {
  80.  
  81. wiInventoryItem wi;
  82. wi.itemID = itemid;
  83. wi.quantity = count;
  84. plr->BackpackAddItem(wi);
  85.  
  86. }
  87.  
  88.  
  89.  
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement