Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 14 15 16 17 18 Next »
Playername in a secondary table
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
Playername in a secondary table
25-04-2015, 07:17 PM, (This post was last modified: 25-04-2015, 07:27 PM by Destiny's Player.)
#1
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
Playername in a secondary table
So, another one of my problem threads. I'm trying to make a table, which has a secondary table for each player on the server/in the faction, which then has two values on 1 and 2, which correspond to that player's cursor position on the screen.

The problem is...
"SFConfusedtarfall/Selena_AI.txt:290: attempt to index field 'The Next Decade' (a nil value)"

And I don't know what changed between now and before I relogged on the server, as it worked perfectly before I relogged.

Here's the code.

--@name Selena AI
--@author TheNextDecade
--@sharedscreen

AIname = "Selena"
Shipname = "Tzar"
Self = entsConfusedelf()
Owner = ents:owner()
OwnName = Owner:name()

if SERVER then

Players = {}
Players.All = find.allPlayers()
Players.Faction = faction.getOnlineMembers()
timer.create("PlayerUpd",5,0,function()
Players.All = find.allPlayers()
Players.Faction = faction.getOnlineMembers()
end)

timer.create("NetSlow",1,0,function()
--hook("think","Repeat",function()
if net.start() then
net.writeTable(Players)
net.broadcast()
end
--end)
end)

else
Basic = render.createFont("default",13,400,1,0,0,1,0)
Head = render.createFont("default",26,400,1,0,0,1,0)
Ancient = render.createFont("anquietas",13,400,1,0,0,1,0)

MenuCol = {235,210,120}
PlayersCl = {}
PlOn = {}
MemOn = {}

Sound = {}
Sound.beep = sounds.create(Self,"st/console/beep05.wav")

function Cursor(ply)
local CurPosX,CurPosY = render.cursorPos(ply)
render.setColor(255,255,255)
if CurPosX ~= nil and CurPosY ~= nil then
render.drawRectOutline(CurPosX-3,CurPosY-3,6,6)
render.drawRect(CurPosX-1,CurPosY-1,2,2)
return CurPosX,CurPosY
end
end

function FacCursor(fac)
facCurs = {}
for i=1,#fac do
facCurs[fac[i]:name()] = {}
facCurs[fac[i]:name()][1],facCurs[fac[i]:name()][2] = Cursor(fac[i])
end
return facCurs
end

function Press(ply)
return ply:keyDown(input.IN_USE)
end

function Mouse(num,butx,butxlen,buty,butylen,moux,mouy,ply)
if moux ~= nil and mouy ~= nil then
if mouy >= buty-butylen and mouy <= buty+butylen then
if moux >= butx-butxlen and moux <= butx+butxlen then
if Press(ply) then
Beeper()
--print(num)
Pg = num
end
end
end
end
end

function Background(col)
render.setColor(col[1]-200,col[2]-200,col[3]-200)
render.drawRect(0,0,512,512)
render.setColor(col[1]+70,col[2]+70,col[3]+70)
render.drawLine(5,5,5,507)
render.drawLine(5,5,507,5)
render.drawLine(507,5,507,507)
render.drawLine(5,507,507,507)
end
function Header(col)
local TLPoly = render.createPoly({
render.vertex(10,15),
render.vertex(80,15),
render.vertex(90,60),
render.vertex(25,60),
render.vertex(15,50)
})
local AINPoly = render.createPoly({
render.vertex(15,19),
render.vertex(75,19),
render.vertex(80,34),
render.vertex(20,34)
})
local SNPoly = render.createPoly({
render.vertex(19,35),
render.vertex(80,35),
render.vertex(84,50),
render.vertex(24,50)
})

local TRPoly = render.createPoly({
render.vertex(420,15),
render.vertex(480,15),
render.vertex(500,30),
render.vertex(500,50),
render.vertex(460,60),
render.vertex(430,60)
})
local OPPoly = render.createPoly({
render.vertex(430,28),
render.vertex(492,28),
render.vertex(497,44),
render.vertex(435,44)
})

render.setColor(col[1],col[2],col[3])
render.drawPoly(TLPoly)
render.drawPoly(TRPoly)
render.drawRect(70,15,360,5)
render.drawRect(80,35,350,5)
render.drawRect(85,55,350,5)

render.setColor(col[1]-200,col[2]-200,col[3]-200)
render.drawPoly(AINPoly)
render.drawPoly(SNPoly)
render.drawPoly(OPPoly)

render.setColor(col[1]+70,col[2]+70,col[3]+70)
--Top Left
--Main
render.drawLine(10,15,80,15)
render.drawLine(80,20,84,35)
render.drawLine(85,40,89,55)
render.drawLine(90,60,25,60)
render.drawLine(25,60,15,50)
render.drawLine(15,50,10,15)
--Inner
render.drawLine(19,34,80,34)
render.drawLine(15,19,23,50)
render.drawLine(15,19,75,19)
render.drawLine(76,19,84,50)
render.drawLine(24,50,84,50)

--Rects
--Top
render.drawLine(80,15,420,15)
render.drawLine(80,20,421,20)
--Middle
render.drawLine(84,35,424,35)
render.drawLine(85,40,426,40)
--Bottom
render.drawLine(89,55,428,55)
render.drawLine(90,60,431,60)

--Top Right
--Main
render.drawLine(420,15,480,15)
render.drawLine(480,15,500,30)
render.drawLine(500,30,500,50)
render.drawLine(500,50,460,60)
render.drawLine(460,60,430,60)
render.drawLine(428,54,426,40)
render.drawLine(424,35,421,20)
--Inner
render.drawLine(430,28,492,28)
render.drawLine(492,28,497,44)
render.drawLine(497,44,435,44)
render.drawLine(435,44,430,28)

end
function TopText(col,mess)
render.setColor(col[1]+70,col[2]+70,col[3]+70)
render.drawText(Ancient,253,23,mess,render.TEXT_ALIGN_CENTER)
render.drawText(Basic,20,20,"AI: " .. AIname,render.TEXT_ALIGN_LEFT)
render.drawText(Basic,25,35,"Ship: " .. Shipname,render.TEXT_ALIGN_LEFT)
OPs = 100/opsMax()*opsUsed()
render.drawText(Basic,490,30,"OP's: "..OPs.."%",render.TEXT_ALIGN_RIGHT)
end
function TopButton(col,leng,posx,posy,pname,press,page)
local partLeng = leng/8
if press == page then
render.setColor(col[1]-50,col[2]-50,col[3]-50)
else
render.setColor(col[1],col[2],col[3])
end
local But = render.createPoly({
render.vertex(posx-partLeng-4,posy-6),
render.vertex(posx+partLeng-3,posy-6),
render.vertex(posx+partLeng-1,posy+5),
render.vertex(posx-partLeng-2,posy+5)
})
render.drawPoly(But)

render.setColor(col[1]+70,col[2]+70,col[3]+70)
render.drawLine(posx-partLeng-4,posy-6,posx-partLeng-2,posy+6)
render.drawLine(posx+partLeng-3,posy-6,posx+partLeng-1,posy+6)
render.drawLine(posx-partLeng-3,posy-6,posx+partLeng-3,posy-6)
render.drawLine(posx-partLeng-1,posy+5,posx+partLeng-1,posy+5)

render.setColor(col[1]+120,col[2]+120,col[3]+120)
render.drawText(Basic,posx,posy-7,pname,render.TEXT_ALIGN_CENTER)
end

function Beeper()
Sound.beep:play()
timer.simple(0.2,function() Sound.beepConfusedtop() end)
end

function Page(col)
render.setColor(col[1],col[2],col[3])
render.drawRect(20,70,472,422)
end

function Greet(col)
Greet0 = render.createPoly({
render.vertex(40,170),
render.vertex(472,170),
render.vertex(482,180),
render.vertex(482,280),
render.vertex(472,290),
render.vertex(40,290),
render.vertex(30,280),
render.vertex(30,180)
})
render.setColor(col[1],col[2],col[3])
render.drawPoly(Greet0)
render.setColor(col[1]+70,col[2]+70,col[3]+70)
render.drawLine(40,170,472,170)
render.drawLine(472,170,482,180)
render.drawLine(482,180,482,280)
render.drawLine(481,280,471,290)
render.drawLine(471,290,40,290)
render.drawLine(40,290,30,280)
render.drawLine(30,280,30,179)
render.drawLine(30,179,40,169)
Greet1 = "Good time of the day to you, "..OwnName.."!"
Greet2 = "Everything's in prime condition\n and is awaiting your command."
render.drawText(Head,256,180,Greet1,render.TEXT_ALIGN_CENTER)
render.drawText(Head,256,220,Greet2,render.TEXT_ALIGN_CENTER)
end

hook("net","NetRec",function()
PlayersCl = net.readTable()
PlOn = PlayersCl.All
MemOn = PlayersCl.Faction
end)

timer.create("Slow",0.2,0,function()
hook("render","Rendering",function()
render.clear()
Background(MenuCol)
Header(MenuCol)
TopText(MenuCol,"The1Next2Decade3is4the5creator6of7this8AI9and10he11is12really13cool")
TopButton(MenuCol,328,133,48,"Status",Pg,1)
TopButton(MenuCol,327,218,48,"Tactical",Pg,2)
TopButton(MenuCol,328,302,48,"Engineering",Pg,3)
TopButton(MenuCol,327,387,48,"Warp",Pg,4)
Mouse(1,133,41,48,6,MePosX,MePosY,Owner)
Mouse(2,218,41,48,6,MePosX,MePosY,Owner)
Mouse(3,302,41,48,6,MePosX,MePosY,Owner)
Mouse(4,387,41,48,6,MePosX,MePosY,Owner)
--PageNum = 0
if Pg == 1 then
Page(MenuCol)
elseif Pg == 2 then
Page({100,100,100})
elseif Pg == 3 then
Page({100,150,100})
elseif Pg == 4 then
Page({100,100,150})
else
Greet(MenuCol)
end

MePosX,MePosY = Cursor(Owner)
FactionCursors = FacCursor(PlOn)
--for i=1,#FactionCursors do
-- render.drawText(Basic,50,300+i*20,tostring(FactionCursors[i]),render.TEXT_ALIGN_LEFT)
--end

Test1 = FactionCursors["The Next Decade"][1]
Test2 = FactionCursors["The Next Decade"][2]
render.drawText(Basic,50,300,tostring(Test1).."\n"..tostring(Test2),render.TEXT_ALIGN_LEFT)
--render.drawText(Basic,50,300,tostring(FactionCursors["The Next Decade"[1]]).."\n"..tostring(FactionCursors["The Next Decade"[2]]),render.TEXT_ALIGN_LEFT)

for i=1, #MemOn do
if MemOn[i]:isValid() then
if MemOn[i]:class() == "player" then
local WriteMem = MemOn[i]:name()
render.drawText(Basic,254,275+i*20,WriteMem,render.TEXT_ALIGN_RIGHT)
end
else
render.drawText(Basic,180,275+i*20,"DISCONNECTED",render.TEXT_ALIGN_RIGHT)
end
end

for i=1, #PlOn do
if PlOn[i]:isValid() then
if PlOn[i]:class() == "player" then
local WritePl = PlOn[i]:name()
render.drawText(Basic,258,275+i*20,WritePl,render.TEXT_ALIGN_LEFT)
end
else
render.drawText(Basic,180,275+i*20,"DISCONNECTED",render.TEXT_ALIGN_LEFT)
end
end

end)
end)
end
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
Playername in a secondary table - by Destiny's Player - 25-04-2015, 07:17 PM
RE: Playername in a secondary table - by Person8880 - 25-04-2015, 08:02 PM
RE: Playername in a secondary table - by Destiny's Player - 25-04-2015, 08:06 PM
RE: Playername in a secondary table - by Person8880 - 25-04-2015, 08:12 PM
RE: Playername in a secondary table - by Destiny's Player - 25-04-2015, 08:45 PM
RE: Playername in a secondary table - by Person8880 - 25-04-2015, 08:57 PM
RE: Playername in a secondary table - by Destiny's Player - 25-04-2015, 09:08 PM

  • View a Printable Version
Forum Jump:


Users browsing this thread:
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.