PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Addon: (drehender) Text über Bank Automat



Garry32
31.05.2011, 04:47
Hallo,

Ich würde gern wissen ob und wie die Möglichkeit
besteht das man Text über den DarkRP Bank ATM bekommt.

Dafür habe ich diesen Code aus der darkrp/entities/entities/drug_lab/cl_init.lua
genommen:


function ENT:Draw()
self.Entity:DrawModel()

local Pos = self:GetPos()
local Ang = self:GetAngles()

local owner = self.dt.owning_ent
owner = (ValidEntity(owner) and owner:Nick()) or "Unknown"

surface.SetFont("HUDNumber5")
local TextWidth = surface.GetTextSize("Druglab!")
local TextWidth2 = surface.GetTextSize("Price: $"..self.dt.price)

Ang:RotateAroundAxis(Ang:Forward(), 90)
local TextAng = Ang

TextAng:RotateAroundAxis(TextAng:Right(), CurTime() * -180)

cam.Start3D2D(Pos + Ang:Right() * -39, TextAng, 0.2)
draw.WordBox(2, -TextWidth*0.5 + 5, -30, "Druglab!", "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth2*0.5 + 5, 18, "Price: $"..self.dt.price, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
cam.End3D2D()

Nun habe ich diesen in die darkrp/entities/entities/bank_atm/cl_init.lua
eingefügt nur funktioniert dieser nicht:


//////////////////////////////////////////////////////////////////////////////////////
//////// BANK SYSTEM MADE BY GUSTAVGR/BLOWN25 ////////
//////// IF YOU HAVE ANY QUESTIONS PLEASE ASK ME ON FACEPUNCH ////////
//////// ////////
//////////////////////////////////////////////////////////////////////////////////////
include('shared.lua')
surface.CreateFont( "MenuItem", 10, 25, true, true, "stid" )
local tidd = "TargetID"
function seebank()
local BZ = vgui.Create( "DFrame" )
BZ:SetSize( 300, 325 )
BZ:SetTitle( "Your Roleplay Bank Account" )
BZ:SetVisible( true )
BZ:SetDraggable( false )
BZ:ShowCloseButton( false )
BZ:Center()
BZ:MakePopup()
BZ:SetSkin("DarkRP")
local SZ = vgui.Create( "DPropertySheet", BZ )
SZ:SetPos( 5, 20 )
SZ:SetSize( 290, 300 )
SZ.Paint = function() -- The paint function
surface.SetDrawColor( 125, 37, 49, 125 ) -- What color ( R, B, G, A )
surface.DrawRect( 0, 0, 290, 300 ) -- How big is it (cords)
end
local CLZ = vgui.Create( "DButton", BZ )
CLZ:SetSize( 20, 20 )
CLZ:SetPos( 275, 1 )
CLZ:SetText( "X" )
CLZ.DoClick = function( button )
datastream.StreamToServer("bankclose")
BZ:Close()
end
t1 = vgui.Create("DLabel", BZ)
t1:SetText(LocalPlayer():Nick().."'s Bank".."\n\n Bank Ballance: "..CUR..tonumber(LocalPlayer():GetNetworkedInt("bank")))
t1:SetColor(Color(15,255,15))
t1:SetPos(45,30)
t1:SetFont("MenuLarge")
t1:SizeToContents()
t2 = vgui.Create("DLabel", BZ)
t2:SetText("Deposit")
t2:SetColor(Color(155,185,112))
t2:SetPos(114,110)
t2:SetFont(tidd)
t2:SizeToContents()
t3 = vgui.Create("DLabel", BZ)
t3:SetText("Withdraw")
t3:SetColor(Color(155,185,112))
t3:SetPos(108,180)
t3:SetFont(tidd)
t3:SizeToContents()
local pout = vgui.Create("TextEntry", BZ)
pout:SetMultiline(false)
pout:SetSize(150,17)
pout:SetPos(65,157)
local BINS = vgui.Create( "DButton", BZ )
BINS:SetSize( 80, 20 )
BINS:SetPos( 100, 135 )
BINS:SetText( "Deposit" )
BINS.DoClick = function( button )
if not tonumber(pout:GetValue()) then LocalPlayer():ChatPrint("You can only enter numbers."); surface.PlaySound( "buttons/button10.wav" ); return end
if LocalPlayer().DarkRPVars.money >= tonumber(pout:GetValue()) then
datastream.StreamToServer("bankclose")
LocalPlayer():ConCommand( "p_1 " .. pout:GetValue() )
surface.PlaySound( "buttons/button14.wav" )
BZ:Close()
else
LocalPlayer():ChatPrint("You can't afford this."); surface.PlaySound( "buttons/button10.wav" );
end
end
phcr = vgui.Create("DLabel", BZ)
phcr:SetText("")
phcr:SetColor(Color(155,185,112))
phcr:SetPos(5,307)
phcr:SetFont("stid")
phcr:SizeToContents()
cor1 = vgui.Create("DLabel", BZ)
cor1:SetText(CUR)
cor1:SetColor(Color(1,255,1))
cor1:SetPos(220,153)
cor1:SetFont("TargetID")
cor1:SizeToContents()
cor2 = vgui.Create("DLabel", BZ)
cor2:SetText(CUR)
cor2:SetColor(Color(1,255,1))
cor2:SetPos(220,223)
cor2:SetFont("TargetID")
cor2:SizeToContents()
local pin = vgui.Create("TextEntry", BZ)
pin:SetMultiline(false)
pin:SetSize(150,17)
pin:SetPos(65,227)
local BANS = vgui.Create( "DButton", BZ )
BANS:SetSize( 80, 20 )
BANS:SetPos( 100, 205 )
BANS:SetText( "Withdraw" )
BANS.DoClick = function( button )
if not tonumber(pin:GetValue()) then LocalPlayer():ChatPrint("You can only enter numbers."); surface.PlaySound( "buttons/button10.wav" ); return end
if tonumber(LocalPlayer():GetNetworkedInt("bank")) >= tonumber(pin:GetValue()) then
datastream.StreamToServer("bankclose")
LocalPlayer():ConCommand( "p_2 " .. pin:GetValue() )
surface.PlaySound( "buttons/button14.wav" )
BZ:Close()
else
LocalPlayer():ChatPrint("You can't afford this."); surface.PlaySound( "buttons/button10.wav" );

function ENT:Draw()
self.Entity:DrawModel()

local Pos = self:GetPos()
local Ang = self:GetAngles()

local owner = self.dt.owning_ent
owner = (ValidEntity(owner) and owner:Nick()) or "Unknown"

surface.SetFont("HUDNumber5")
local TextWidth = surface.GetTextSize("Druglab!")
local TextWidth2 = surface.GetTextSize("Price: $"..self.dt.price)

Ang:RotateAroundAxis(Ang:Forward(), 90)
local TextAng = Ang

TextAng:RotateAroundAxis(TextAng:Right(), CurTime() * -180)

cam.Start3D2D(Pos + Ang:Right() * -39, TextAng, 0.2)
draw.WordBox(2, -TextWidth*0.5 + 5, -30, "Druglab!", "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
draw.WordBox(2, -TextWidth2*0.5 + 5, 18, "Price: $"..self.dt.price, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
cam.End3D2D()
end
end
end
end
usermessage.Hook("seemybank", seebank)


Habt ihr da vielleicht eine Idee was man machen könnte ?

MFG, Garry32

P.S: Link zum Addon: http://www.garrysmod.org/downloads/?a=view&id=117562

kartoffel
31.05.2011, 19:14
Oooha, du hast da aber ziemlichen Unfug veranstaltet.
Ich würd mal stark behaupten, dass die Funktion ENT:Draw() schon irgendwo existiert.
Arbeite dich erstmal etwas in die Materie ein und füge entsprechend angepassten Code in die bereits vorhandene Funktion ein.

Außerdem scheint mir, dass du die Funktion in eine andere bereits vorhandene Funktion reinstopfst. Wie gesagt, arbeite dich ein oder poste Quellcode den man lesen kann.
Sobald der Code entsprechend eingerückt und formatiert hier im Forum erscheint wird dir das sicher gern jemand machen.

Garry32
02.06.2011, 08:53
Thema kann geschlossen werden.

Fighter_Zero
02.06.2011, 10:57
Du weißt, dass wir hier nicht prinzipiell dazu da sind Support zu geben?

Garry32
02.06.2011, 21:10
Das ist aber der Sinn eines Forums

gogokiller
02.06.2011, 21:17
Wir machen das hier in unserer Freizeit das ist keine Hilfe Hotline...

don-banane
02.06.2011, 22:21
Es ist blöd wenn wir jemanden helfen sollen, der keine Ahnung von irgendetwas hat, und unüberlegt ein Stück Code in ein anderes Stück Code kopiert und uns dann fragt, warum das nicht funktioniert. Bekommst du denn keinen LUA-Fehler? Ich sehe nämlich nicht, woher "self.dt.price" kommen soll. Zweite Vermutung: Der Text wird im 3D-Model angezeigt, weil er nicht hoch genug ist. (Möglicherweise Ang:Right verlängern)