So ist es
Hier kannst du noch ein sehr gutes Tutorial von Scarecrow/Comodofox finden!
Dort ist es in etwa genau so gemacht,
nur das halt kein Entity gespawnt wird,
sondern dem Spieler 10 Lebenspunkte hinzugefügt werden.
So ist es
Hier kannst du noch ein sehr gutes Tutorial von Scarecrow/Comodofox finden!
Dort ist es in etwa genau so gemacht,
nur das halt kein Entity gespawnt wird,
sondern dem Spieler 10 Lebenspunkte hinzugefügt werden.
Der Fehler ist beim concommand.Add("spawnTable", spawnTable); und nicht concommand.Add("spawnTable", spawnFirstTable);
Die Funktion heist nämlcih SpawnFirstTable deshalb hat es nicht funktioniert.
Gehts jetzt?
Ähm ... nein aber... es ist doch:
concommand.Add("CONSOLENBEFEHL", FUNKTIONSNAME) oder? weil dann wäre
concommand.Add("spawnTable", spawnFirstTable) doch richtig?
zitiere:
Funktion heißt somit "SpawnFirstTable"Code:function SpawnFirstTable(ply, cmd, args)
JAWOLL und mit SpawnFirstTable gehts nun auch...keine Ahnung warum es vorher nicht ging!
Zu guter letzt:
wie ignoriere ich bei "wohin der tisch gespawnt wird" die maus im derma und verwende das crosshair? =D
Weil nun spawne ich mit klicken auf die schaltfläche und dort wo die schlatfläche war spawnt dann der tisch![]()
Geändert von Santo (24.06.2008 um 21:24 Uhr)
Vielleicht funktioniert das: http://wiki.garrysmod.com/wiki/?title=Util.TraceLine
Das Code Stück dort unten mein ich.
Lua Code:
function spawnFirstTable(ply, cmd, args) local pos = ply:GetShootPos() local ang = ply:GetAimVector() local tracedata = {}tracedata.start = pos tracedata.endpos = pos+(ang*80)tracedata.filter = ply local trace = util.TraceLine(tracedata) local Table = ents.Create( "prop_physics" ) Table:SetModel ("models/props_c17/FurnitureTable002a.mdl" ) Table:SetPos( trace.HitPos ) Table:Spawn()end concommand.Add("spawnTable", spawnFirstTable);
Geändert von SMILIE (25.06.2008 um 16:08 Uhr)
das wäre dann server?
wenn ja dann:
SantoRP/gamemode/init.lua:2: attempt to index global 'self' (a nil value)
Holy **** es geht!
Für alle die wissen wollen wie:
Client:
Server:Lua Code:
function DermaFurniture() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50,150 ) DermaPanel:SetSize( 700, 500 ) DermaPanel:SetTitle( "Spawn Furnitures" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaButton1 = vgui.Create( "DImageButton", DermaPanel ) DermaButton1:SetImage( "derma/FurnitureTable002a.vtf" ) DermaButton1:SetParent( DermaPanel ) DermaButton1:SetText( "Table" ) DermaButton1:SetPos( 25, 50 ) DermaButton1:SetSize( 64, 64 ) DermaButton1.DoClick = function () RunConsoleCommand("spawnTable");endend concommand.Add("da_furniture_derma", DermaFurniture);
Lua Code:
function spawnFirstTable(ply, cmd, args) local pos = ply:GetShootPos() local ang = ply:GetAimVector() local tracedata = {}tracedata.start = pos tracedata.endpos = pos+(ang*80)tracedata.filter = ply.Owner local trace = util.TraceLine(tracedata) local Table = ents.Create( "prop_physics" ) Table:SetModel ("models/props_c17/FurnitureTable002a.mdl" ) Table:SetPos( trace.HitPos ) Table:Spawn()end concommand.Add("spawnTable", spawnFirstTable);
Geändert von Santo (24.06.2008 um 23:37 Uhr)