1. Post #601
    zzaacckk's Avatar
    June 2009
    2,153 Posts
    Simple and straight to the point question- can you run a mysqloo query when there is no active player on the server?

    Some people tell me you can, some people tell me you can't.. the tests I did say you can't but I might be doing something wrong.

    Edited:

    Note thats for mysqloo not tmysql.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  2. Post #602
    Gold Member
    Alex_grist's Avatar
    January 2007
    1,076 Posts
    Simple and straight to the point question- can you run a mysqloo query when there is no active player on the server?

    Some people tell me you can, some people tell me you can't.. the tests I did say you can't but I might be doing something wrong.

    Edited:

    Note thats for mysqloo not tmysql.
    Yes, just run it on the Database:OnConnected function.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  3. Post #603
    zzaacckk's Avatar
    June 2009
    2,153 Posts
    Yes, just run it on the Database:OnConnected function.
    I've tried, would you like to see the code?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  4. Post #604
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    Simple and straight to the point question- can you run a mysqloo query when there is no active player on the server?

    Some people tell me you can, some people tell me you can't.. the tests I did say you can't but I might be doing something wrong.

    Edited:

    Note thats for mysqloo not tmysql.
    You can't until the first player has joined, if a player joins and then leaves you can still run queries with no players, but you can't run any queries between the server starting up and the first player joining.

    Edited:

    But it will save the queries you try and run and run them all when the first player joins.
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  5. Post #605
    zzaacckk's Avatar
    June 2009
    2,153 Posts
    You can't until the first player has joined, if a player joins and then leaves you can still run queries with no players, but you can't run any queries between the server starting up and the first player joining.

    Edited:

    But it will save the queries you try and run and run them all when the first player joins.
    Actually, I just found out I am wrong. If you synchronize the queries in the main thread it will work (but it dosent matter because no players are in the server).
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  6. Post #606
    kp3
    Gold Member
    kp3's Avatar
    January 2008
    2,988 Posts
    I'm having issues with getting the players current team in a clientside script.
    I'm using LocalPlayer():Team() for a derma panel in cl_init.

    I get this:
    Code:
    [gamemodes\kush\gamemode\cl_init.lua:78] attempt to call method 'Team' (a nil value)
    Is there another way I should be doing this?
    I'm basically doing "if LocalPlayer():Team() == 1 then".
    I saw it being used here: http://maurits.tv/data/garrysmod/wik...ta_Derma_Panel
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  7. Post #607
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    I'm having issues with getting the players current team in a clientside script.
    I'm using LocalPlayer():Team() for a derma panel in cl_init.

    I get this:
    Code:
    [gamemodes\kush\gamemode\cl_init.lua:78] attempt to call method 'Team' (a nil value)
    Is there another way I should be doing this?
    I'm basically doing "if LocalPlayer():Team() == 1 then".
    I saw it being used here: http://maurits.tv/data/garrysmod/wik...ta_Derma_Panel
    Team shouldn't be nil, that would mean the thing you're calling it on isn't a player, which would be LocalPlayer(). You'll have to post more code if you want any more help.
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  8. Post #608
    EthanTheGreat's Avatar
    September 2010
    310 Posts
    Seems like something is conflicting with your code, it should work just fine. Maybe you can share the code and we could take a look; if not, there isn't much help we can do :l
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #609
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    You can't until the first player has joined, if a player joins and then leaves you can still run queries with no players, but you can't run any queries between the server starting up and the first player joining.
    hook.Add("InitPostEntity", "Enable Queries", function()
        game.ConsoleCommand("bot\n");
        timer.Simple(0, game.ConsoleCommand, "kick bot01\n");
    end);
    Reply With Quote Edit / Delete Mac United Kingdom Show Events

  10. Post #610
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    hook.Add("InitPostEntity", "Enable Queries", function()
        game.ConsoleCommand("bot\n");
        timer.Simple(0, game.ConsoleCommand, "kick bot01\n");
    end);
    You shouldn't really even need to do that, any queries you try and run should be ran properly when the first player does join.
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  11. Post #611
    kp3
    Gold Member
    kp3's Avatar
    January 2008
    2,988 Posts
    Team shouldn't be nil, that would mean the thing you're calling it on isn't a player, which would be LocalPlayer(). You'll have to post more code if you want any more help.
    There isn't much to post.
    if LocalPlayer():Team() == 0 then
    	for Icon, Entity in pairs (RegularBuyList) do
    		Icon = vgui.Create( "Spawnicon" )
    		Icon:SetModel( ModelList[Entity] )
    		Icon:SetToolTip (Entity)
    		Icon.OnMousePressed = function()
    		RunConsoleCommand ("RP_Buy", Entity)
    		LocalPlayer():EmitSound( "ambient/levels/canals/drip1.wav", 150, 50 );
    		end
    		Icon.OnCursorEntered = function()
    			Hover[Icon] = true
    		end
    		Icon.OnCursorExited = function()
    			Hover[Icon] = false
    		end
    		Icon.Paint = function()
    			if Hover[Icon] == true then
    				draw.RoundedBox( 8, 0, 0, 64, 64, Color( 100, 0, 0, 200 ) )
    			else
    				draw.RoundedBox( 8, 0, 0, 64, 64, Color( 0, 0, 0, 200 ) )
    			end
    		end
    		DermaList:AddItem( Icon )
    	end
    end

    It's basically right there. All I can think of is that it's allways Nil because this is called before the players team is set, but if that's the case should i just set it to if LocalPlayer():Team() == nil || LocalPlayer():Team() == 0 ?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  12. Post #612
    Gold Member
    Lexic's Avatar
    March 2009
    6,123 Posts
    You shouldn't really even need to do that, any queries you try and run should be ran properly when the first player does join.
    It might not be strictly speaking necessary, but it's still an option he might want to take.
    Reply With Quote Edit / Delete Mac United Kingdom Show Events

  13. Post #613
    Gold Member
    ralle105's Avatar
    October 2005
    4,648 Posts
    I'm having issues with getting the players current team in a clientside script.
    I'm using LocalPlayer():Team() for a derma panel in cl_init.

    I get this:
    Code:
    [gamemodes\kush\gamemode\cl_init.lua:78] attempt to call method 'Team' (a nil value)
    Is there another way I should be doing this?
    I'm basically doing "if LocalPlayer():Team() == 1 then".
    I saw it being used here: http://maurits.tv/data/garrysmod/wik...ta_Derma_Panel
    The only thing I can think if is that your code is running before the InitPostEntity hook has been called.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  14. Post #614
    kp3
    Gold Member
    kp3's Avatar
    January 2008
    2,988 Posts
    The only thing I can think if is that your code is running before the InitPostEntity hook has been called.
    It's in cl_init for my gamemode. LocalPlayer():Health() works fine so shouldn't this?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  15. Post #615
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    It's in cl_init for my gamemode. LocalPlayer():Health() works fine so shouldn't this?
    cl_init would be ran before the player exists I think, and before the team is even set, making checking the team completely redundant. If this is for a menu you probably want to be doing this in the function that opens the menu, rather than in the file itself.
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  16. Post #616
    PLEASE DON'T EAT ME!
    Doritos_Man's Avatar
    June 2009
    2,944 Posts
    I have this ATM Cracker I'm working on that I based off the keypad cracker.
    It's supposed to have a 3 minute delay between each crack it just says "You must wait 3 minutes inbetween cracking ATM's!" x3 and it starts to crack without showing the progress bar.
    It still says how much you stole and gives you the money.

    And after you crack it spams "You must wait 3 minutes inbetween cracking ATM's" x4 and it stops you from cracking.

    Code: http://pastebin.com/kMqsNBBC
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  17. Post #617
    kp3
    Gold Member
    kp3's Avatar
    January 2008
    2,988 Posts
    cl_init would be ran before the player exists I think, and before the team is even set, making checking the team completely redundant. If this is for a menu you probably want to be doing this in the function that opens the menu, rather than in the file itself.
    Made it update the icons every time you open it instead, Which makes more sense because I'll be having different teams that can buy different things. Thanks.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  18. Post #618

    January 2012
    11 Posts
    I was wondering if anyone would be able to tell/help me make it so that in DarkRP only a certain ulx group (VIP and above) will be able to have certain weapons/entities.

    For example i only want VIPs to have access to fists, on all jobs. Is there an easy way to do this?
    Also i want so only VIPs can have/use the tazer when cop/swat... etc.

    Reply back on here or message me on steam if needed :)
    Thanks
    Toby

    Steam http://steamcommunity.com/profiles/76561198005643722/
    Reply With Quote Edit / Delete Windows 7 Isle of Man Show Events

  19. Post #619
    Gold Member
    Feihc's Avatar
    October 2006
    1,080 Posts
    So some crazy math shit I need help with. No idea where to start, if anyone has done anything like this please let me know.

    I'm recreating the Aerial Faith Plate for GMod. I have the base of it working and now I have a Stool that I'm going to use to set the landing location and the jump height.
    Location will be set by right click on the STool and the height with a CPanel Slider.

    The things we know:
    -Where the landing pad position is
    -Angle between the pad and the landing position
    -The jump height
    -Launching objects mass
    -Gravity (sv_gravity)

    Things we dont know:
    -Required force to push to correct location
    -Required angle to push at


    I haven't taken enough physics to know where to really start with this.
    I know we're going to need some kind of trajectory nonsense but again, no idea where to start.

    Thoughts?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #620
    whitespace's Avatar
    November 2008
    869 Posts
    As far as I know, the trajectory path is a parabel.

    You have to know how Source engine handles applying gravity to an object to correctly calculate the path. The required force you need is, again, as far as I know, calculated with the potential energy and kinetic energy formulas.

    Goes like this: in a gravitational field, the potential energy an object has at a certain height, is calculated with the formula E = mgh, and the kinetic energy of an object is calculated with the formula E = (1/2)*mv^2. ( m = mass, g = gravitational pull( 9,81m/s^2 on Earth ), h = height )
    ---> mgh = (1/2)*mv^2 <=> gh = (1/2)*v^2 <=> v = sqrt( 2gh )

    So the velocity you need to apply for the object to reach the highest point of the parabel( from that moment it will just fall to the desired position by itself ), is calculated with v = sqrt( 2gh ).

    I think the tangent of the parabel at the launching point has something to do with this too, but can't think of anything right now. I haven't even tested this, but I think this would be a good start for you.

    If anything in this is wrong please do correct me.
    Reply With Quote Edit / Delete Windows XP Finland Show Events Useful Useful x 1 (list)

  21. Post #621

    January 2012
    11 Posts
    I am wondering if anyone can fix this code so that it only opens up one reason box when you right click. At the moment when you right click whilst looking at a player it opens 3 or 4 reason boxes when im looking for it to just open one. Here is the code.

    function SWEP:SecondaryAttack()
    local trace = self.Owner:GetEyeTrace()
    	if trace.Entity:IsPlayer() then
    			Derma_StringRequest("wanted reason", "Enter the reason to arrest this player", "", function(Reason)
    				LocalPlayer():ConCommand("say /wanted ".. trace.Entity:UserID().." ".. Reason)
    			end)
    	end
    end
    

    Post a reply here or add me on steam if you need more information. Steam = http://steamcommunity.com/profiles/76561198005643722/

    Thanks Toby
    Reply With Quote Edit / Delete Windows 7 Isle of Man Show Events

  22. Post #622
    Gold Member
    Feihc's Avatar
    October 2006
    1,080 Posts
    I am wondering if anyone can fix this code so that it only opens up one reason box when you right click. At the moment when you right click whilst looking at a player it opens 3 or 4 reason boxes when im looking for it to just open one. Here is the code.

    function SWEP:SecondaryAttack()
    local trace = self.Owner:GetEyeTrace()
    	if trace.Entity:IsPlayer() then
    			Derma_StringRequest("wanted reason", "Enter the reason to arrest this player", "", function(Reason)
    				LocalPlayer():ConCommand("say /wanted ".. trace.Entity:UserID().." ".. Reason)
    			end)
    	end
    end
    

    Post a reply here or add me on steam if you need more information. Steam = http://steamcommunity.com/profiles/76561198005643722/

    Thanks Toby
    Because it's calling SecondaryFire more than once.
    Your best bet is to make the secondary fire not automatic.

    Either change or put in the line that says

    SWEP.Secondary.Automatic = true

    In your SWEP to

    SWEP.Secondary.Automatic = false

    That way it will only call once when you click

    Edited:

    As far as I know, the trajectory path is a parabel.

    You have to know how Source engine handles applying gravity to an object to correctly calculate the path. The required force you need is, again, as far as I know, calculated with the potential energy and kinetic energy formulas.

    Goes like this: in a gravitational field, the potential energy an object has at a certain height, is calculated with the formula E = mgh, and the kinetic energy of an object is calculated with the formula E = (1/2)*mv^2. ( m = mass, g = gravitational pull( 9,81m/s^2 on Earth ), h = height )
    ---> mgh = (1/2)*mv^2 <=> gh = (1/2)*v^2 <=> v = sqrt( 2gh )

    So the velocity you need to apply for the object to reach the highest point of the parabel( from that moment it will just fall to the desired position by itself ), is calculated with v = sqrt( 2gh ).

    I think the tangent of the parabel at the launching point has something to do with this too, but can't think of anything right now. I haven't even tested this, but I think this would be a good start for you.

    If anything in this is wrong please do correct me.
    Thanks! I think that will help in a way with finding the force required, but need to find the appropriate angle as well. The yaw will be easy, its just finding the pitch that will be a bitch.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  23. Post #623
    Title

    August 2009
    301 Posts
    I'm creating some train sort of system however I have the spawning and all working but I cannot figure out the collision of the trains here is a screenshot:
    http://cloud.steampowered.com/ugc/57...D66B2DD7F77CE/

    Ignore the bad positioning of the train but basically even when pulled out of the ground it just floats in the air here is the code:

    function starttrain()
    SpawnTrain( Vector(683.428162, -2151.920166, 91.897896), 0 )
    end
    concommand.Add( "trololol", starttrain )
    function SpawnTrain( Pos, Direction )
    	local train = ents.Create( "prop_physics" )
    	train:SetModel("models/props_trainstation/train001.mdl")
    	train:SetAngles(Angle(0,0,0))
    	train:SetPos( Pos )
    	train:Spawn()
    	train:SetMoveType( MOVETYPE_FLY )
    	//train:Activate()
    	train:EmitSound( "ambient/alarms/train_horn2.wav", 100, 100 )
    	train:GetPhysicsObject():SetVelocity( Vector(0,3000,0) )
    	
    	//constraint.NoCollide(train,GetWorldEntity(),0,0)
    	timer.Create( "TrainRemove_"..CurTime(), 5, 1, function( train ) train:Remove() end, train )
    end
    

    Now I know train:SetMoveType( MOVETYPE_FLY ) is causing that however I cant seem to find one that basically freezes the train however it can move when Velocity is added to it (It also collides with the player but won't be stopped by them either).

    I'm also probably not doing this the best way either.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  24. Post #624
    Gold Member
    Hyper Iguana's Avatar
    March 2011
    700 Posts
    table.SortByMember(wr, "time", function(a, b) return a < b end)

    After populating my table "wr" (I am positive it is populated, check image at bottom) and trying to sort the members by their time, it does not affect the table at all in my for loops.

    for _,v in ipairs(wr) do
    		if v["name"] and v["time"] and v["steamid"] then
    			records:AddLine(v["name"], string.ToMinutesSeconds(v["time"]))
    		end
    	end

    Anyone got any theories?

    Reply With Quote Edit / Delete Windows 7 United States Show Events

  25. Post #625
    Gold Member
    Alex_grist's Avatar
    January 2007
    1,076 Posts
    Try table.sort.

    table.sort(wr, function(a, b) return a.time < b.time end)
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Lua Helper Lua Helper x 1 (list)

  26. Post #626
    Gold Member
    thejjokerr's Avatar
    December 2007
    2,146 Posts
    Does anyone know if there's a proper way to set the GWEN skin already? And how do I change the colour of text in a textentry? I've tried modifying the the GWEN skin image and using SetTextColor on the textentry panel neither worked.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  27. Post #627

    January 2012
    11 Posts
    Because it's calling SecondaryFire more than once.
    Your best bet is to make the secondary fire not automatic.

    Either change or put in the line that says

    SWEP.Secondary.Automatic = true

    In your SWEP to

    SWEP.Secondary.Automatic = false

    That way it will only call once when you click
    This doesn't work. Still calls it 3/4 times even with it set to false
    Reply With Quote Edit / Delete Windows 7 Isle of Man Show Events

  28. Post #628
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,558 Posts
    Does anyone know if there's a proper way to set the GWEN skin already? And how do I change the colour of text in a textentry? I've tried modifying the the GWEN skin image and using SetTextColor on the textentry panel neither worked.
    Garry's adding that in Update 20.

    Toby, add this:

    self:SetNextPrimaryFire(CurTime() + 1);
    
    Reply With Quote Edit / Delete United States Show Events Informative Informative x 1 (list)

  29. Post #629
    G-Enigma's Avatar
    June 2011
    326 Posts
    Hello, I'm a bit new to lua, but thought I'd take a crack at the using sound.Add(table) function to script sounds for the Gmod 13 Beta, is there any way to fix this:
    Code:
    function sound.Add(soundtest)
    local soundtest = {};
    channel = CHAN_RELOAD;
    level = SNDLVL_NORM;
    sound = "uzi/clin.wav"
    name = "Weapon_imuzi.Clipin"
    end
    giving an "attempt to index global 'sound' (a string value)" error?
    I put it in an autorun file and it does nothing (no lua errors, no scripted sound playing), so I ran it through LuaPad (In-game lua editor/script runner) and got the above error.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #630
    Gold Member
    Hyper Iguana's Avatar
    March 2011
    700 Posts
    Try table.sort.

    table.sort(wr, function(a, b) return a.time < b.time end)
    Worked flawlessly, thank you.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  31. Post #631

    January 2012
    11 Posts

    Toby, add this:

    self:SetNextPrimaryFire(CurTime() + 1);
    
    Where about do i add this?
    Reply With Quote Edit / Delete Windows 7 Isle of Man Show Events

  32. Post #632
    Gold Member
    I Fail At Lua's Avatar
    December 2009
    717 Posts
    Sorry if this is the wrong place to ask but, does anyone happen to have a link to a mirror of the wiki?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  33. Post #633
    pennerlord's Avatar
    February 2011
    504 Posts
    Sorry if this is the wrong place to ask but, does anyone happen to have a link to a mirror of the wiki?
    http://maurits.tv/data/garrysmod/wik...itle=Main_Page (seems to be down for some reason)

    http://bananatree.im/wiki/wiki.garry...itle=Main_Page
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  34. Post #634
    Gold Member
    I Fail At Lua's Avatar
    December 2009
    717 Posts
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  35. Post #635
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    my copy (bananatree.im) will search my wiki now instead of maur's (thanks for pointing that out Capsadmin/Drake), but you can only search from the main page - I'm not updating a couple thousand files, sorry.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #636
    Gold Member
    Hyper Iguana's Avatar
    March 2011
    700 Posts
    I have a table made up in this format:
    mytable = {
    	["map_one"] = {},
    	["map_two"] = {},
    	["map_three"] = {},
    }

    And I am trying to get 5 random keys from the table (The actual table has more than 5 keys) so I can start a map vote. How would I go by grabbing 5 random keys from that type of table?

    edit:

    Ended up being lazy:

    local maps = maplocs
    function StartVote()
    	local tovote = {}
    	local mapscopy = {}
    	for k,v in pairs(maps) do
    		table.insert(mapscopy, k)
    	end
    	
    	while table.Count(tovote) < 4 do
    		local newentry = table.Random(mapscopy)
    		if !table.HasValue(tovote, newentry) then
    			table.insert(tovote, newentry)
    		end
    	end
    	PrintTable(tovote)
    	
    end
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  37. Post #637
    I'm living in the Best Korea. 사랑해요 김치맨!
    rebel1324's Avatar
    December 2008
    1,904 Posts
    local temp_maplist = {}
    local temp_map
    local pickingmaps = 5
    
    for i = 1, 5 do
    
    if temp_maplist then
      if mytable then
       
         for i = 1, 5 do
             temp_map = table.Random( mytable )
             
             if not table.HasValue( temp_maplist, temp_map ) then
                  table.insert( temp_maplist, temp_map )
                  break
             end
    
         end
    
      else
       print('No Maplist')
      end
    end
    
    end
    

    Maybe like this?
    Reply With Quote Edit / Delete Windows 7 Korea, Republic of Show Events

  38. Post #638
    Gold Member
    Hyper Iguana's Avatar
    March 2011
    700 Posts
    lotsa cod
    

    Maybe like this?
    You should be using a while loop. If your table happens to get duplicates, it won't be added to the table. And the method I posted in my edit worked fine.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  39. Post #639
    Gold Member
    I Fail At Lua's Avatar
    December 2009
    717 Posts
    I'm trying to make a little weapon saving script.

    I got it to save the weapon but now I need to strip the active weapon and I can't seem to get it to work.
                    self:StripWeapon( self:GetActiveWeapon():GetClass() )
                    -- Error: attempt to call method 'StripWeapon' (a nil value)
    
    Does anyone have any ideas?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  40. Post #640
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts
    Reply With Quote Edit / Delete Windows 7 United States Show Events Zing Zing x 1 (list)