Junior Spellweaver
- Joined
- Jan 5, 2015
- Messages
- 173
- Reaction score
- 194
What is this ?
Modified version of Cmd_GiveItem function for more features.
It also adds chat messages with given items and player names.
How to use it ?
/giveme itemidcount - Gives item to person who used this code.
/giveall itemidcount - Gives item to every alive player in server.
/givepremium itemidcount - Gives item to every alive and premium player in server.
Search for:
Change with:
Search for:
Change with:
Search for:
Now change the entire function with this one:
Pastebin for function:
Screenshot:
Modified version of Cmd_GiveItem function for more features.
It also adds chat messages with given items and player names.
How to use it ?
/giveme itemidcount - Gives item to person who used this code.
/giveall itemidcount - Gives item to every alive player in server.
/givepremium itemidcount - Gives item to every alive and premium player in server.
Search for:
Code:
if(strncmp(cmd, "/gi", 3) == 0 && (plr->profile_.ProfileData.isDevAccount & wiUserProfile::DAA_SPAWN_ITEM)) return Cmd_GiveItem(plr, cmd);
Change with:
Code:
if(strncmp(cmd, "/giveme", 7) == 0 && (plr->profile_.ProfileData.isDevAccount & wiUserProfile::DAA_SPAWN_ITEM)) return Cmd_GiveItem(plr, cmd, false, false); if(strncmp(cmd, "/giveall", 8) == 0 && (plr->profile_.ProfileData.isDevAccount & wiUserProfile::DAA_SPAWN_ITEM)) return Cmd_GiveItem(plr, cmd, true, false); if(strncmp(cmd, "/givepremium", 8) == 0 && (plr->profile_.ProfileData.isDevAccount & wiUserProfile::DAA_SPAWN_ITEM)) return Cmd_GiveItem(plr, cmd, true, true);
Search for:
Code:
int Cmd_GiveItem(obj_ServerPlayer* plr, const char* cmd);
Change with:
Code:
int Cmd_GiveItem(obj_ServerPlayer* plr, const char* cmd, bool toeveryone, bool topremium);
Search for:
Code:
int ServerGameLogic::Cmd_GiveItem(obj_ServerPlayer* plr, const char* cmd)
Now change the entire function with this one:
Code:
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;}
Pastebin for function:
You must be registered to see links
Screenshot:
Attachments
You must be registered for see attachments list
Last edited: