[QUOTE=Banana Lord.;39344175]because www. isn't a protocol[/QUOTE]
The library is called "http", it's for dealing with the HTTP protocol, why would it need the protocol name?
[editline]a[/editline]
V Care to correct me Banana Lord?
[QUOTE=Matt-;39344190]The library is called "http", it's for dealing with the HTTP protocol, why would it need the protocol name?[/QUOTE]
That's not just it.
[lua]] lua_run_cl http.Fetch("http://steamcommunity.com/profiles/76561197978153864?xml=true", print, print)
unsuccessful
[/lua]
If it redirects, shit doesn't work.
The link in above Lua snippet redirects to
[url]http://steamcommunity.com/id/FPtje/?xml=true&l=english[/url]
I need the full sized avatar by the way.
Trying to make the player enter the vehicle On Use:
[CODE]
function ENT:Use( activator, caller )
Player:EnterVehicle()
end
[/CODE]
What I get back:
[CODE][ERROR] lua/entities/heli/init.lua:36: attempt to index global 'Player' (a function value)
1. unknown - lua/entities/heli/init.lua:36
[/CODE]
Any fix would be appreciated. Thanks.
Hm, it seems [URL="http://wiki.garrysmod.com/page/Libraries/http/Fetch"]http.Fetch[/URL] is [b]supposed[/b] to give you an error code but that doesn't seem to be happening when I try it, just returns "unsuccessful".
If this code is private you'll be able to use Valve's Web API that exposes a very nice feature called [URL="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29"]GetPlayerSummaries[/URL], it requires an API key which are easily obtainable. Data can be returned as JSON, XML or VDF. You can request multiple Steam IDs at once too which may be useful for whatever you're doing.
The best part of using this API instead however, is if player's have a private profile, you're still able to obtain public information such as their persona name and avatar which isn't possible when using the method you posted previously.
[editline]24th January 2013[/editline]
[QUOTE=pilot;39344375][CODE]
function ENT:Use( activator, caller )
Player:EnterVehicle()
end
[/CODE][/QUOTE]
"Player" isn't a variable, I think you're looking for "activator".
[QUOTE=Matt-;39344387]Hm, it seems [URL="http://wiki.garrysmod.com/page/Libraries/http/Fetch"]http.Fetch[/URL] is [b]supposed[/b] to give you an error code but that doesn't seem to be happening when I try it, just returns "unsuccessful".
If this code is private you'll be able to use Valve's Web API that exposes a very nice feature called [URL="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29"]GetPlayerSummaries[/URL], it requires an API key which are easily obtainable. Data can be returned as JSON, XML or VDF. You can request multiple Steam IDs at once too which may be useful for whatever you're doing.
The best part of using this API instead however, is if player's have a private profile, you're still able to obtain public information such as their persona name and avatar which isn't possible when using the method you posted previously.
[editline]24th January 2013[/editline]
"Player" isn't a variable, I think you're looking for "activator".[/QUOTE]
Yeah fixed it to this:
[CODE]
function ENT:Use( activator, caller )
activator:EnterVehicle( vehicle )
end
[/CODE]
But I'm trying to define the entity as vehicle as you can see, but I can't figure it out.
Is the entity a vehicle? If so just use:
[lua]
function ENT:Use( activator, caller )
activator:EnterVehicle( self )
end
[/lua]
[QUOTE=Matt-;39344520]Is the entity a vehicle? If so just use:
[lua]
function ENT:Use( activator, caller )
activator:EnterVehicle( self )
end
[/lua][/QUOTE]
Yeah it worked thanks, but...how would I actually put the player in the vehicle?
Does it have to do with this?
[CODE]Vehicle:SetVehicleEntryAnim( string animName )[/CODE]
I can't really tell you much as I have no idea how your entity is setup, also what do you mean "put the player in the vehicle". Are you referring to controls or the player's world model drawing or something else?
[QUOTE=Matt-;39344616]I can't really tell you much as I have no idea how your entity is setup, also what do you mean "put the player in the vehicle". Are you referring to controls or the player's world model drawing or something else?[/QUOTE]
Boop:
[CODE]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
function ENT:SpawnFunction( ply, trace )
if!trace.Hit then return end
local h = ents.Create( ClassName || self.ClassName || "ent_base" )
if !(h && IsValid(h)) then
if h.Remove then h:Remove() end
return
end
h:SetPos( trace.HitPos + trace.HitNormal * 16 );
h.Owner = ply
h:Activate()
h:Spawn()
return h
end
function ENT:Initialize()
self:SetModel( "models/combine_helicopter.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
local ph = self:GetPhysicsObject()
if (ph:IsValid()) then
ph:Wake()
end
end
function ENT:Use( activator, caller )
activator:EnterVehicle( self )
end
function ENT:Think()
end
[/CODE]
Trying to get the player to actually get in the heli.
Holy shit, AvatarImageObj:SetPlayer(ply, size) takes a second int parameter.
Thanks Python1320!!!
Okay I just realized...entites and vehicles are differently coded :P anyone know how to script vehicles?
[QUOTE=M0dSe7en;39332931]Anyone have working code for a bare-bones SNPC? I have to make a simple one for my gamemode that's able to toggle following you on use.[/QUOTE]
bump for interest
I get this error in the server:
(name) expected near '('
And this my code:
[code]
function(ply)
if ply:CheckGroup("usergroup") == "owner" then
ply:SetTeam(4)
end
[/code]
[QUOTE=I Like Cereal;39346429]I get this error in the server:
(name) expected near '('
And this my code:
[code]
function(ply)
if ply:CheckGroup("usergroup") == "owner" then
ply:SetTeam(4)
end
[/code][/QUOTE]
You need to give the function a name when you do it this way.[lua]
function myFunc(ply)
--code
end
[/lua]
[QUOTE=I Like Cereal;39346429]I get this error in the server:
(name) expected near '('
And this my code:
[code]
function(ply)
if ply:CheckGroup("usergroup") == "owner" then
ply:SetTeam(4)
end
[/code][/QUOTE]
If you are using ULX, do something like this:
[code]function OwnerSet(ply)
if ply:IsUserGroup( "owner" ) then
ply:SetTeam( 4 )
end
end[/code]
[LUA]function ENT:High(activator,caller)
plymodel = activator:GetModel()
weps = activator:GetWeapons()
activator:StripWeapons()
self:Say(activator, "i feel like a tree man. check out my bark.")
activator:SetModel("models/player/police.mdl")
end
function ShroomsSober()
for id,pl in pairs(player.GetAll())do
if ( pl:GetNetworkedFloat("durgz_mushroom_high_start") && pl:GetNetworkedFloat("durgz_mushroom_high_end") > CurTime() ) then
pl:SetModel(plymodel)
for k,v in pairs(weps) do
pl:Give(k)
end
end
end
end
hook.Add("Think", "durgz_shrooms_end", ShroomsSober)[/LUA]
Here is the code i'm working with, i'm editing durgzmod and giving it some different effects.
Here is the error:
[ERROR] addons/durgzmod/lua/entities/durgz_mushroom/init.lua:22: bad argument #1 to 'SetModel' (string expected, got nil)
1. SetModel - [C]:-1
2. v - addons/durgzmod/lua/entities/durgz_mushroom/init.lua:22
3. unknown - lua/includes/modules/hook.lua:82
So naturally i assume that it probably doesn't like the fact that i initialized plymodel in the high function and tried to use it in the sober function....but my question is, if this is true, how would i go about transferring that variable over?
Variables can be assigned to players. So something like this will work:
[lua]
function ENT:High(activator,caller)
-- First we remember what the players model is and their weapons
activator._OldModel = activator:GetModel()
activator._OldWeps = activator:GetWeapons()
-- And then strip the weapons and set the model to something else.
activator:StripWeapons()
activator:SetModel("models/player/police.mdl")
-- not sure what the Say function is, I assume it works.
self:Say(activator, "i feel like a tree man. check out my bark.")
end
local function ShroomsSober()
for _, ply in pairs(player.GetAll()) do
local start = ply:GetNetworkedFloat("durgz_mushroom_high_start", 0)
local end = ply:GetNetworkedFloat("durgz_mushroom_high_end", 0)
if ( start != 0 and end > CurTime() ) then
ply:SetModel(ply._OldModel)
for k,v in pairs(ply._OldWeps) do
ply:Give(k)
end
end
end
end
hook.Add("Think", "durgz_shrooms_end", ShroomsSober)
[/lua]
[QUOTE=Matt-;39347333]Variables can be assigned to players. So something like this will work:
[lua]
function ENT:High(activator,caller)
-- First we remember what the players model is and their weapons
activator._OldModel = activator:GetModel()
activator._OldWeps = activator:GetWeapons()
-- And then strip the weapons and set the model to something else.
activator:StripWeapons()
activator:SetModel("models/player/police.mdl")
-- not sure what the Say function is, I assume it works.
self:Say(activator, "i feel like a tree man. check out my bark.")
end
local function ShroomsSober()
for _, ply in pairs(player.GetAll()) do
local start = ply:GetNetworkedFloat("durgz_mushroom_high_start", 0)
local end = ply:GetNetworkedFloat("durgz_mushroom_high_end", 0)
if ( start != 0 and end > CurTime() ) then
ply:SetModel(ply._OldModel)
for k,v in pairs(ply._OldWeps) do
ply:Give(k)
end
end
end
end
hook.Add("Think", "durgz_shrooms_end", ShroomsSober)
[/lua][/QUOTE]
Now when i try the drug, it doesn't change the playermodel and the sober effects never happen.
I've been struggling with the latter for a while, as i don't understand how durgzmod is coded in the way that it signifies the end of the high. But the previous was working before.
Also, looking at your code i'm even more confused, though it seems like it should work.... Any particular reason for the _s?
The error it spams my console with now is:
NULL Ent in GiveNamedItem!
Attempted to create unknown entity type 13!
Cept the 13 at the end scrolls through the numbers 1-13
I could really do with some help.. I'm having a big problem with custom weapon sweps. Well sweps work fine but the sound doesn't work 100%. The primary fire sound works fine when standing still but if you fire while moving it starts to like cut out.. It's hard to explain so I made a quick video.. I have tried loads of different sweps and even had a go at making my own and I still have the same problem. The sweps work 100% in singleplayer (sound is fine) just not working properly on my server (all gamemodes). [B]Any ideas?[/B] Thanks!
[video=youtube;M_dO--rpdM0]http://www.youtube.com/watch?v=M_dO--rpdM0[/video]
[QUOTE=FROZTYUK;39348001]I could really do with some help.. I'm having a big problem with custom weapon sweps. Well sweps work fine but the sound doesn't work 100%. The primary fire sound works fine when standing still but if you fire while moving it starts to like cut out.. It's hard to explain so I made a quick video.. I have tried loads of different sweps and even had a go at making my own and I still have the same problem. The sweps work 100% in singleplayer (sound is fine) just not working properly on my server (all gamemodes). [B]Any ideas?[/B] Thanks!
[video=youtube;M_dO--rpdM0]http://www.youtube.com/watch?v=M_dO--rpdM0[/video][/QUOTE]
what gamemode is this for?
How exactly can I stop a user from crashing the server this easy? Does anybody have any idea what causes it so I can fix it?
[code]
ServerLog: "Catheter Cat™<261><STEAM_0:1:40094882><Citizen>" say "/name Analbut Penistucher"
Catheter Cat™<STEAM_0:1:40094882> changed their name to Analbut Penistucher
ServerLog: "Analbut Penistucher<261><STEAM_0:1:40094882><Citizen>" say "// Is this roboku's server"
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_building_details/storefront_template001a_bars.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_building_details/storefront_template001a_bars.mdl
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
ServerLog: "Analbut Penistucher<261><STEAM_0:1:40094882><Citizen>" say "// crashin the server"
ServerLog: "Analbut Penistucher<261><STEAM_0:1:40094882><Citizen>" say "// bai"
[/code]
After that the server crashed. like 5 seconds after he said bai
Would it be the "creator" tool gun? or some constraint that he uses that crashes the server. I don't have any elevators on the map(just in case somebody would suggest that)
[QUOTE=Ozhar;39348214]what gamemode is this for?[/QUOTE]
I am currently making a zombie escape gamemode.. but I have this problem in all gamemodes (incl sandbox).. The sweps work fine in SP sandbox but not in MP sandbox.. I've spent days trying to figure it out and I'm close to just giving up on the whole lot. It *should* be working 100% but its not.. Someone must know why this is happening. I hope someone can enlighten me on this problem. Thanks!
[QUOTE=FROZTYUK;39348424]I am currently making a zombie escape gamemode.. but I have this problem in all gamemodes (incl sandbox).. The sweps work fine in SP sandbox but not in MP sandbox.. I've spent days trying to figure it out and I'm close to just giving up on the whole lot. It *should* be working 100% but its not.. Someone must know why this is happening. I hope someone can enlighten me on this problem. Thanks![/QUOTE]
can you put the code for in here
[editline]24th January 2013[/editline]
[QUOTE=J.R.;39348396]How exactly can I stop a user from crashing the server this easy? Does anybody have any idea what causes it so I can fix it?
[code]
ServerLog: "Catheter Cat™<261><STEAM_0:1:40094882><Citizen>" say "/name Analbut Penistucher"
Catheter Cat™<STEAM_0:1:40094882> changed their name to Analbut Penistucher
ServerLog: "Analbut Penistucher<261><STEAM_0:1:40094882><Citizen>" say "// Is this roboku's server"
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_building_details/storefront_template001a_bars.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_building_details/storefront_template001a_bars.mdl
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
ServerLog: [ULX] Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
Analbut Penistucher<STEAM_0:1:40094882> spawned model models/props_borealis/bluebarrel001.mdl
ServerLog: "Analbut Penistucher<261><STEAM_0:1:40094882><Citizen>" say "// crashin the server"
ServerLog: "Analbut Penistucher<261><STEAM_0:1:40094882><Citizen>" say "// bai"
[/code]
After that the server crashed. like 5 seconds after he said bai
Would it be the "creator" tool gun? or some constraint that he uses that crashes the server. I don't have any elevators on the map(just in case somebody would suggest that)[/QUOTE]
you have to ban the props. im assuming this is for darkrp so just download this [url]http://www.garrysmod.org/downloads/?a=view&id=83387[/url]
Extract bannedprops.lua to garrysmod\gamemodes\darkrp\gamemode
How would I make a 'setmoney' command. What I got so far:
[code]
function bw_setmoney()
end
[/code]
and
[code]
concommand.Add("bw_setmoney", bw_setmoney)
[/code]
[QUOTE=I Like Cereal;39348686]How would I make a 'setmoney' command. What I got so far:
[code]
function bw_setmoney()
end
[/code]
and
[code]
concommand.Add("bw_setmoney", bw_setmoney)
[/code][/QUOTE]
[CODE]
local meta = FindMetaTable("Player") --Get the meta table of player
function meta:AddMoney(amount)
local current_cash = self:GetMoney()
self:SetMoney( current_cash + amount )
end
function meta:SetMoney(amount)
self:SetNetworkedInt( "Money", amount )
self:SaveMoney()
end
function meta:SaveMoney()
local cash = self:GetMoney()
self:SetPData("money", cash)
end
function meta:SaveMoneyTXT()
file.Write(gmod.GetGamemode().Name .."/Money/".. string.gsub(self:SteamID(), ":", "_") ..".txt", self:GetMoneyString())
end
function meta:TakeMoney(amount)
--Add money function here
self:AddMoney(-amount)
end
function meta:GetMoney()
return self:GetNetworkedInt( "Money" )
end
[/CODE]
i think this will work correct me if i am wrong
[QUOTE=Ozhar;39348757][CODE]
local meta = FindMetaTable("Player") --Get the meta table of player
function meta:AddMoney(amount)
local current_cash = self:GetMoney()
self:SetMoney( current_cash + amount )
end
function meta:SetMoney(amount)
self:SetNetworkedInt( "Money", amount )
self:SaveMoney()
end
function meta:SaveMoney()
local cash = self:GetMoney()
self:SetPData("money", cash)
end
function meta:SaveMoneyTXT()
file.Write(gmod.GetGamemode().Name .."/Money/".. string.gsub(self:SteamID(), ":", "_") ..".txt", self:GetMoneyString())
end
function meta:TakeMoney(amount)
--Add money function here
self:AddMoney(-amount)
end
function meta:GetMoney()
return self:GetNetworkedInt( "Money" )
end
[/CODE]
i think this will work correct me if i am wrong[/QUOTE]
Do not use NW anything, use net messages or umsg to send data to the client.
[QUOTE=brandonj4;39349073]Do not use NW anything, use net messages or umsg to send data to the client.[/QUOTE]
k thanks for telling me
Is there a reliable way to get the kind of ammo in a gun (including HL2 weapons)? I'm talking about the types such as "smg1" and "pistol"
[QUOTE=Banana Lord.;39349296]Is there a reliable way to get the kind of ammo in a gun (including HL2 weapons)? I'm talking about the types such as "smg1" and "pistol"[/QUOTE]
What do you mean? To where it displays the ammo you're currently using in a weapon?
And also, I already have a money system. I need a command to set money, but I don't exactly know how to do that :/ so instead of giving me money systems, please just lead me in a direction for a command.
[QUOTE=I Like Cereal;39349350]What do you mean? To where it displays the ammo you're currently using in a weapon?[/QUOTE]
The type of it, so I can get how much the player has. Either I'm missing something or objPl:GetAmmoCount( "pistol" ) is returning 0 for me
Sorry, you need to Log In to post a reply to this thread.