Do anyone know how to script a code that link to a website with that i mean
take a prop like the newspaper prop then when you press e on that a motd thing will popup but its not link to a motd its link to a website so you can make a news paper to your server for like half life 2 rp or some other gamemode can some one script this mode and send back a replay?
i got an answer from kopimi when i ask about this and he send me this links
[url]http://wiki.garrysmod.com/?title=Gamemode.PlayerUse[/url]
[url]http://wiki.garrysmod.com/?title=P.HTML[/url]
and i wonder if someone can but this to a lua script and send me a script
[editline]3rd November 2011[/editline]
[QUOTE=n0mi;33103841]Do anyone know how to script a code that link to a website with that i mean
take a prop like the newspaper prop then when you press e on that a motd thing will popup but its not link to a motd its link to a website so you can make a news paper to your server for like half life 2 rp or some other gamemode can some one script this mode and send back a replay?
i got an answer from kopimi when i ask about this and he send me this links
[url]http://wiki.garrysmod.com/?title=Gamemode.PlayerUse[/url]
[url]http://wiki.garrysmod.com/?title=P.HTML[/url]
and i wonder if someone can but this to a lua script and send me a script because i suck at lua scripting[/QUOTE]
->"Can anyone script a lua code to me that when you press "E" on a news paper prop a window thing will popup in your screen and you will be send in to a website"<-
You'll most likely want a actual entity instead of using a prop.
if you know how to get the base code of a entity then this is what you need to do,
in init.lua find something called "function ENT:Use" and replace it with:
[lua]
function ENT:Use( activator )
umsg.Start("NewspaperInfo", activator)
umsg.End()
end
[/lua]
then go to cl.init.lua and post this inside of it
[lua]
local function NewPaperShit()
local Website = vgui.Create("HTML")
Website:SetPos(500,400)
Website:SetSize(ScrW(), ScrH())
Website:OpenURL("http://www.google.com") -- put your link here
end
usermessage.Hook("NewspaperInfo", NewPaperShit)
[/lua]
hopefully you understand.
That would make an infinite loop of windows you can't close. This will open the Steam browser one time.
[lua]function ENT:Initialize()
self:SetUseType(SIMPLE_USE)
end
function ENT:Use(activator, caller)
activator:SendLua([[gui.OpenURL("http://www.website.com/yoururlhere.html")]])
end[/lua]
Better method:
[Lua]
activator.NextUse = activator.NextUse or 0
function ENT:Use( activator )
if activator.NextUse < CurTime() then
activator.NextUse = CurTime() + 3
activator:SendLua([[gui.OpenURL("Website url")]])
end
end
[/Lua]
Or, if you want it for a every prop that is spawnable and looks like that:
[Lua]
hook.Add("PlayerUse", "Motdprop", function(pl, entity)
pl.NextUse = pl.NextUse or 0
if string.find(entity:GetClass(), "prop_physics") then
if entity:GetModel() == "Link To Your Model" then
pl.NextUse = CurTime() + 3
pl:SendLua([[gui.OpenURL("Website url")]])
end
end
end)
[/Lua]
[QUOTE=DarkRising;33117740]Better method:
[Lua]
activator.NextUse = activator.NextUse or 0
function ENT:Use( activator )
if activator.NextUse < CurTime() then
activator.NextUse = CurTime() + 3
activator:SendLua([[gui.OpenURL("Website url")]])
end
end
[/Lua]
Or, if you want it for a every prop that is spawnable and looks like that:
[Lua]
hook.Add("PlayerUse", "Motdprop", function(pl, entity)
pl.NextUse = pl.NextUse or 0
if string.find(entity:GetClass(), "prop_physics") then
if entity:GetModel() == "Link To Your Model" then
pl.NextUse = CurTime() + 3
pl:SendLua([[gui.OpenURL("Website url")]])
end
end
end)
[/Lua][/QUOTE]
i want a prop to spawn can't you put this together to me? and send a link to the file or just put the code back up with name over like int.lua and that
[QUOTE=DarkRising;33117740]Better method:[/QUOTE]
SIMPLE_USE means only once per key press.
Sorry, you need to Log In to post a reply to this thread.