Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ServerGameLogic::Cmd_GiveItem(obj_ServerPlayer* plr, const char* cmd, bool toeveryone, bool topremium)
- {
- char buf[128];
- int itemid;
- int count = 1;
- if(2 > sscanf(cmd, "%s %d %d", buf, &itemid, &count))
- return 2;
- if(g_pWeaponArmory->getConfig(itemid) == NULL)
- {
- r3dOutToLog("Cmd_GiveItem: no item %d\n", itemid);
- return 3;
- }
- bool logGiveItem=true;
- #ifdef DISABLE_GI_ACCESS_ON_PTE_MAP
- if(ginfo_.channel==6) // don't care about PTE maps, as nothing there is saved
- logGiveItem=false;
- #endif
- #ifdef DISABLE_GI_ACCESS_ON_PTE_STRONGHOLD_MAP
- if(ginfo_.channel==6 && ginfo_.mapId==GBGameInfo::MAPID_WZ_Cliffside) // don't care about PTE maps, as nothing there is saved
- logGiveItem=false;
- #endif
- #ifdef DISABLE_GI_ACCESS_FOR_CALI_SERVER
- if(gServerLogic.ginfo_.mapId==GBGameInfo::MAPID_WZ_California)
- logGiveItem=false;
- #endif
- if(logGiveItem)
- 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);
- char* itemname="";
- const BaseItemConfig* getitem = g_pWeaponArmory->getConfig(itemid);
- if(getitem)
- itemname = getitem->m_StoreName;
- if(toeveryone)
- {
- //give item to all players.
- for(int i=0; i<curPlayers_; i++)
- {
- obj_ServerPlayer* player = plrList_[i];
- if(player->loadout_->Alive == 0) // do not give item to death players !
- continue;
- if(player->profile_.ProfileData.PremiumAcc < 0 && topremium ) // only give item if user is premium !
- continue;
- char msg[512]="";
- sprintf(msg,"Player: %s Rewarded with: %s ",player->loadout_->Gamertag, itemname);
- PKT_C2C_ChatMessage_s n;
- n.userFlag = 0;
- n.msgChannel = 1;
- r3dscpy(n.msg, msg);
- r3dscpy(n.gamertag, "[GiveItem]");
- gServerLogic.p2pBroadcastToAll(&n, sizeof(n), true);
- wiInventoryItem wi;
- wi.itemID = itemid;
- wi.quantity = count;
- player->BackpackAddItem(wi);
- }
- }
- else
- {
- wiInventoryItem wi;
- wi.itemID = itemid;
- wi.quantity = count;
- plr->BackpackAddItem(wi);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment