VGOEmulator.net

A Development Project for the Vanguard:Saga of Heroes MMO

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • Portal
  • Project Manager
  • Bug Tracker
  • Server List
  • Wiki
  • Donate
  • Login
  • Register
  • Board index Community Off-Topic
  • Search

A little LUA help, maybe

Random thoughts...

Moderator: Community Managers

Post Reply
  • Print view
Advanced search
3 posts • Page 1 of 1
User avatar
Cyrcle
Data Collector
Data Collector
Posts: 288
Joined: Fri Jan 31, 2014 1:51 pm
A little LUA help, maybe
  • Quote

Post by Cyrcle » Wed Mar 04, 2015 2:51 pm

Nothing related to Vanguard, but I am trying to get a plug-in working for a Rust server. I can't seem to figure out how or if it can be fixed. What is occurring is the equipment "Packs" are not equipping and coming back with an error that reads "Deathmatch: Error while giving [item name]: [item name] is not a valid item name."

I have attached the original LUA file to this post in hopes someone can figure out why it is returning the value. Here is some of the code in question:

Code: Select all

  local packData = self.Config.Packs[packNum]
  
  -- Equip player with armor
  if (packData.armor) then
    for i = 1, #packData.armor do
      str = packData.armor[i]
      giveitem, err = self:GiveItem(player.inventory,str,1,"wear")
	  if(not giveitem) then print("Deathmatch: Error while giving " .. str .. ": " .. err) end
    end
  end

  -- Equip player with items in their backpack
  if (packData.backpack) then
    for i = 1, #packData.backpack do
      if (packData.backpack[i][2]) then
        giveitem, err = self:GiveItem(player.inventory,packData.backpack[i][1],packData.backpack[i][2],"main")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.backpack[i][1] .. ": " .. err) end
      else
        giveitem, err = self:GiveItem(player.inventory,packData.backpack[i][1],1,"main")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.backpack[i][1] .. ": " .. err) end
      end
    end
  end

  -- Equip player with items on their belt
  if (packData.belt) then
    for i = 1, #packData.belt do
      if (packData.belt[i][2]) then
        giveitem, err = self:GiveItem(player.inventory,packData.belt[i][1],packData.belt[i][2],"belt")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.belt[i][1] .. ": " .. err) end
      else
        giveitem, err = self:GiveItem(player.inventory,packData.belt[i][1],1,"belt")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.belt[i][1] .. ": " .. err) end
      end
    end
  end
end

Code: Select all

function PLUGIN:GiveItem(inv,name,amount,type)
	local itemname = false
	name = string.lower(name)
	if(Table[name]) then
		itemname = Table[name]
	else
		itemname = name
	end
	if(tonumber(amount) == nil) then
		return false, "amount is not valid"
	end
	local container
	if(type == "belt") then
		container = inv.containerBelt
	elseif(type == "main") then
		container = inv.containerMain
	elseif(type == "wear") then
		container = inv.containerWear
	else
		return false, "wrong type: belt, main or wear"
	end
	local giveitem = global.ItemManager.CreateByName(itemname,amount)
	if(not giveitem) then
		return false, itemname .. " is not a valid item name"
	end
	inv:GiveItem(giveitem,container);
	return giveitem
end

Code: Select all

  self.Config.Packs =
  {
    {belt = {{"Thompson"},{"Medical Syringe", 1}}, armor = {"Hazmat Boots", "Hazmat Jacket", "Hazmat Gloves", "Hazmat Pants"}, backpack = {{"Pistol Bullet", 250}}},
    {belt = {{"Thompson"},{"Medical Syringe", 1}}, armor = {"Hazmat Boots", "Hazmat Jacket", "Hazmat Gloves", "Hazmat Pants"}, backpack = {{"Pistol Bullet", 250}}}
  }
Any help when someone has some spare time would be greatly appreciated.
Attachments
arena_deathmatch.zip
(3.8 KiB) Downloaded 267 times
Top

User avatar
Cyrcle
Data Collector
Data Collector
Posts: 288
Joined: Fri Jan 31, 2014 1:51 pm
Re: A little LUA help, maybe
  • Quote

Post by Cyrcle » Wed Mar 04, 2015 4:00 pm

I solved the issue. Disregard.

A recent patch caused all the names to use their short names such as "smg_thompson" instead of just "Thompson".
Top

User avatar
Cyrcle
Data Collector
Data Collector
Posts: 288
Joined: Fri Jan 31, 2014 1:51 pm
Re: A little LUA help, maybe
  • Quote

Post by Cyrcle » Mon Mar 09, 2015 10:21 am

Well, since this has so many views (but no answers). Here is a new issue:

First, a little background. This is a deathmatch plug-in for Rust. It is dependent on an arena plug-in. I am loading up players belts (hotbars) with 6 of the 6 maximum items. On the first spawn, it is loading the hotbar correctly with all 6 items. However, once the player dies and respawns, it is only equipping them with either one or three items on their hotbar, instead of the six. I can't seem to figure out if it is an issue with the plug-in or an issue with the game itself, as I do not have access to the console for the server to see what is going on. I can just keep trying to change things, but it is a complete crapshoot right now.

The code pertaining to equiping players:

Code: Select all

function PLUGIN:GiveItem(inv,name,amount,type)
	local itemname = true
	name = string.lower(name)
	if(Table[name]) then
		itemname = Table[name]
	else
		itemname = name
	end
	if(tonumber(amount) == nil) then
		return false, "amount is not valid"
	end
	local container
	if(type == "belt") then
		container = inv.containerBelt;
	elseif(type == "main") then
		container = inv.containerMain;
	elseif(type == "wear") then
		container = inv.containerWear;
	else
		return false, "wrong type: belt, main or wear"
	end
	local giveitem = global.ItemManager.CreateByName(itemname,amount)
	if(not giveitem) then
		return false, itemname .. " is not a valid item name"
	end
	inv:GiveItem(giveitem,container);
	return giveitem
end

function PLUGIN:EquipPlayer(player)
  if(not Table) then self:InitializeTable() end
  self:ClearInventory(player)

  local packNum = self.Config.DefaultPack
  if (self.DeathmatchData.CustomPack > 0) then
    packNum = self.DeathmatchData.CustomPack
  elseif (self.Config.RandomPack) then
    packNum = math.random(#self.Config.Packs)
  end

  local packData = self.Config.Packs[packNum]
  
  -- Equip player with armor
  if (packData.armor) then
    for i = 1, #packData.armor do
      str = packData.armor[i]
      giveitem, err = self:GiveItem(player.inventory,str,1,"wear")
	  if(not giveitem) then print("Deathmatch: Error while giving " .. str .. ": " .. err) end
    end
  end

  -- Equip player with items in their backpack
  if (packData.backpack) then
    for i = 1, #packData.backpack do
      if (packData.backpack[i][2]) then
        giveitem, err = self:GiveItem(player.inventory,packData.backpack[i][1],packData.backpack[i][2],"main")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.backpack[i][1] .. ": " .. err) end
      else
        giveitem, err = self:GiveItem(player.inventory,packData.backpack[i][1],1,"main")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.backpack[i][1] .. ": " .. err) end
      end
    end
  end

  -- Equip player with items on their belt
  if (packData.belt) then
    for i = 1, #packData.belt do
      if (packData.belt[i][3]) then
        giveitem, err = self:GiveItem(player.inventory,packData.belt[i][1],packData.belt[i][2],packData.belt[i][3],"belt")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.belt[i][1] .. ": " .. err) end
      else
        giveitem, err = self:GiveItem(player.inventory,packData.belt[i][1],1,"belt")
	    if(not giveitem) then print("Deathmatch: Error while giving " .. packData.belt[i][1] .. ": " .. err) end
      end
    end
  end
end
The code for the packs:

Code: Select all

self.Config.Packs =
  {
    {belt = {{"rifle_ak"},{"rifle_bolt"},{"shotgun_pump"},{"smg_thompson"},{"pistol_revolver"},{"largemedkit", 1}}, armor = {"urban_boots", "urban_jacket", "urban_pants"}, backpack = {{"ammo_rifle", 160},{"ammo_shotgun", 30},{"ammo_pistol", 160}}},
    {belt = {{"rifle_ak"},{"rifle_bolt"},{"shotgun_pump"},{"smg_thompson"},{"pistol_revolver"},{"largemedkit", 1}}, armor = {"attire.hide.boots", "attire.hide.vest", "attire.hide.pants"}, backpack = {{"ammo_rifle", 160},{"ammo_shotgun", 30},{"ammo_pistol", 160}}},
	{belt = {{"rifle_ak"},{"rifle_bolt"},{"shotgun_pump"},{"smg_thompson"},{"pistol_revolver"},{"largemedkit", 1}}, armor = {"urban_boots", "vagabond_jacket", "burlap_gloves", "urban_pants"}, backpack = {{"ammo_rifle", 160},{"ammo_shotgun", 30},{"ammo_pistol", 160}}}
Essentially, it should be equipping the player with an AK, Bolt Action, Pump Shotgun, Thompson, Revolver, and a Medkit on their hotbar. It does this the first time, but the second time and each time after it is either an AK, Bolt Action, and Shotgun or just an AK. It will instead put these in your backpack and need to be equipped, which is a hassle of course in a deathmatch setting. If anyone would be kind enough to at least let me know the code is okay, I would appreciate it. That way if worst comes to worst, I can just set it to three items for the belt and it will (hopefully) work.

Edit: I should specify that your "belt" (hotbar), "armor" (equipped attire), and "backpack" (general character inventory) are all separate inventories from one another.

Also, the spawning code:

Code: Select all

function PLUGIN:OnArenaSpawnPost(player)
  if (self.DeathmatchData.IsChosen) then
    self:EquipPlayer(player)
    self:GivePlayerImmunity(player)
    player.health = 100;
  end
end
Edit 2: Knocked it down to 4 items. Now appears that the belt is working correctly but armor is not. Puts the additional items in the backpack. I think it may be with the game itself, but not 100% on that.
Top


Post Reply
  • Print view

3 posts • Page 1 of 1

Return to “Off-Topic”

Jump to
  • Information
  • ↳   Announcements
  • ↳   Dev Chats
  • ↳   Events
  • Community
  • ↳   General Discussions
  • ↳   VGO Team Help Requests
  • ↳   Introductions
  • ↳   Game Features
  • ↳   Wish List
  • ↳   Off-Topic
  • Support
  • ↳   How-To's
  • ↳   General Support
  • ↳   Windows
  • ↳   Linux
  • Bugs
  • ↳   Server Bugs
  • ↳   Server Bugs (Closed)
  • ↳   Content Bugs
  • ↳   Content Bugs (Closed)
  • ↳   Database Bugs
  • ↳   Tools Bugs
  • Board index
  • All times are UTC-07:00
  • Delete cookies
  • Contact us
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD