Hey Guys,
im currently working on a Holocron Spawn Script and im almost done with the table.txt storage and an sqlite Storing function for the HP bonus.
What i need to do is something special and im at the end of my knowledge.
First of all:
I have a Holocron Place SWEP and a Derma (working over PANEL register)
On the DERMA (extra Lua file) I select a type of holocron p.e. holocron_green and the swep have on the primary attack function the tr.Entity ents.Create(...) function.
I need to make it so that the self.Owner of the Weapon select on the Derma the Entity the SWEP should registered it to place it.
Now the code segments:
HolocronConfig.HoloTypes = {
["Holocron: Green"] = {
EntString = "holocron_green",
Icon = Material("holocronsys_mats/holocron_green.png"),
},
["Holocron: Blue"] = {
EntString = "holocron_blue",
Icon = Material("holocronsys_mats/holocron_blue.png"),
},
------------------------------------------------------------
for k, v in SortedPairs(HolocronConfig.HoloTypes) do
LButton.DoClick = function()
local ply = LocalPlayer()
MainMenu:MoveTo( -MainMenu:GetWide(),ScrH()/2 - MainMenu:GetTall()/2, .1, 0, .5 )
MainMenu:NewAnimation( 0, .1, .5, function()
MainMenu:Hide()
end)
gui.EnableScreenClicker( false )
net.Start("GetTheHolocron")
net.WriteString(v.EntString)
net.SendToServer()
end
end
This was the part from the derma Now the SWEP Part:
if SERVER then
util.AddNetworkString("GetTheHolocron")
util.AddNetworkString("HolocronSelectorMenu")
SelectedHolocron = "holocron_green"
net.Receive( "GetTheHolocron", function(len, ply)
SelectedHolocron = net.ReadString()
end)
end
function SWEP:PrimaryAttack()
local tr = self.Owner:GetEyeTrace();
if( tr && tr.Entity ) then
local _e = tr.Entity;
if( tr.Entity == game.GetWorld() ) then
if( CLIENT ) then return; end
local _e = ents.Create(SelectedHolocron );
_e:SetPos( tr.HitPos + Vector( 0, 0, 10 ) );
_e:Spawn();
end
end
end
i want that the derma select string gets to the SWEP but if i do it like i wrote another derma player could overwrite my selection from derma.. (i guess)
Sry for my bad english.
thanks alot
If you need some more things i can upload the rest of the code on pastebin or we could work in codeshare.
Ok here are the both pastes i need for this net.receive part. Its better than the cutted code from Post#1
DermaPanel
Weapon
For better reading i changed the first post with full code and i describe hopefully more clear what i need.
Ok i guess i got it now...
if SERVER then
util.AddNetworkString("GetTheHolocron")
util.AddNetworkString("HolocronSelectorMenu")
net.Receive("GetTheHolocron", function(len)
local Target = net.ReadEntity()
local EntType = net.ReadString()
SaveHolocronSelection(Target,EntType)
end)
function SaveHolocronSelection(Target,EntType)
ply = Target
ply:SetNWString("HolocronType",EntType)
end
function SpawnHolocron(Target)
if IsValid(Target) and Target:IsPlayer() then
local HolocronType = Target:GetNWString("HolocronType")
if HolocronType == "" then
else
local tr = Target:GetEyeTrace();
if( tr && tr.Entity ) then
local _e = tr.Entity;
if( tr.Entity == game.GetWorld() ) then
local _e = ents.Create(HolocronType);
_e:SetPos( tr.HitPos + Vector( 0, 0, 10 ) );
_e:Spawn();
_e:SetOwner( Target );
end
end
end
end
end
end
Now the SWEP:Primary Function amnd the derma code
function SWEP:PrimaryAttack()if( CLIENT ) thenreturnendlocal Target = self.Owner
SpawnHolocron(Target)
end--CLIENT
LButton.DoClick = function()local ply = LocalPlayer()
MainMenu:MoveTo( -MainMenu:GetWide(),ScrH()/2 - MainMenu:GetTall()/2, .1, 0, .5 )
MainMenu:NewAnimation( 0, .1, .5, function()
MainMenu:Hide()
end)
gui.EnableScreenClicker( false )
net.Start("GetTheHolocron")
net.WriteEntity(ply)
net.WriteString(v.EntString)
net.SendToServer()
endend
Sorry, you need to Log In to post a reply to this thread.