1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

NightAngel's Development Thread

Discussion in 'Development' started by NightAngel, Jul 20, 2014.

  1. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    Alrighty, here's another post explaining my logic and crying out for someone to save me.

    So I'm coding a perk framework for something, but I'm having trouble with getting the derma to use the datastream and transfer the selected perk name and player name to the server so that it can add it to the player's table of perks in their characterdata.

    Here's what I've got for the path that the variables travel, but for some reason, it gets to the server as nil.

    This is the code in the icon click function that sends the data to the server from the client.

    Code:
    	-- Called when the spawn icon is clicked.
    	function self.spawnIcon.DoClick(spawnIcon)	
    		local transmitTable = {}
    			transmitTable.name = self.perk.name;
    			transmitTable.player = LocalPlayer():GetName();
    			print(transmitTable.name)
    			print(transmitTable.player)
    		Clockwork.datastream:Start("PerkGive", transmitTable);
    	end;
    and this is the code on the server side that receives the data and gives the player the perk, but the data returns as nil atm, and I have no idea why.

    Code:
    Clockwork.datastream:Hook("PerkGive", function(data)
    		local perkTable = Schema.perk:FindByID(data.name);
    		print(data.player)
    		print(data.name)
    		if (type(data.player) == string) then
    			local player = Clockwork.player:FindByID(data.player)
    			local perks = player:GetCharacterData("perkInfo");
    			if (!perkTable or !player) then return; end;
    			
    			Schema.perk:GivePlayerPerk(data.player, data.name)
    		end;
    	end)
    This is what the derma prints client-side before it sends the data through the datastream.

    [​IMG]

    And this is what it prints server-side when it receives the data.

    [​IMG]

    Please help me!

    [member=5522]Atebite[/member]
    [member=5495]Polis[/member]
    [member=1476]Gr4Ss[/member]
    [member=1314]Arbiter329[/member]
    [member=5482]duck[/member]

    <3
     
  2. Re: NightAngel's Development Thead

    I can never be asked to use the datastream, probably because I'm more used to the net library (and I cba to learn it), so try using that instead. First pool your network message string with util.AddNetworkString("PerkGive") serverside.

    After that you're ready to use it all.

    Client
    Code:
    local transmitTable = {}
    transmitTable.name = self.perk.name
    transmitTable.player = LocalPlayer():GetName()
    
    net.Start("PerkGive")
    	net.WriteTable(transmitTable)
    net.SendToServer()
    
    Server
    Code:
    util.AddNetworkString("PerkGive")
    
    -- Basically the same as adding a hook to whenever you receive the net message.
    net.Receive("PerkGive", function()
    	local data = net.ReadTable()
    
    	local perkTable = Schema.perk:FindByID(data.name)
    	if (type(data.player) == string) then
    		local player = Clockwork.player:FindByID(data.player)
    		local perks = player:GetCharacterData("perkInfo")
    		if (!perkTable or !player) then return end
    		
    		Schema.perk:GivePlayerPerk(data.player, data.name)
    	end
    end)
    
     
  3. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    I'll try this, danke. <3
     
  4. Re: NightAngel's Development Thead

    Serverside the Hook function is function(player, data) which is why it doesn't work. And CW datastreams > net
     
  5. Re: NightAngel's Development Thead

    Net > datastreams because datastreams uses net.
     
  6. duck

    duck Phant0m Legend

    Re: NightAngel's Development Thead

    Codewise, DS does use net, but I like DS just because it's simplified and does all the work in the background, so you can have easier communication between the server and client.

    Of course, it's all preference, though.
     
  7. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    Worked, love you. <3
     
  8. NFPD

    NFPD Plums!

    Re: NightAngel's Development Thead

    There's two addons that add more zombie skins for all of the zombie models, and they all have bodygroups, I don't see a need for the zombie headcrab bodygroup, they already have them don't they? All though it would be cool if you could make it so when the zombie char dies then the body ragdolls and if the headcrab dies as well an NPC would spawn, and then have it immeadtly die and ragdoll, I don't know...
     
  9. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    http://youtu.be/MtkGM-dCFHk

    This is a very early alpha of a schema I'm making, demonstrating the work in progress NPC battle system for the zombies, as well as the auto-spawning zombie system.
     
  10. Sophia

    Sophia Guest

    Re: NightAngel's Development Thead

    :O That looks so cool!
     
  11. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    It's really buggy atm, but danke. <3
     
  12. Lev

    Lev certified honorable guy

    Re: NightAngel's Development Thead

    I'm disliking you more and more, because you're so much better than me! :O

    (joking about the disliking part)
     
  13. Tomo742

    Tomo742 Guest

    Re: NightAngel's Development Thead

    I love it, can I marry your plugins?
     
  14. Re: NightAngel's Development Thead

    How are you doing the zombie spawns? Grab random positions from an area around the player which is x amount away from the player yet y amount close to him/her, then just spawn it there and drop it to the ground?

    I'm just curious, I never really bothered to brain strain myself trying to come up with a good autospawner.
     
  15. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    You put zombie spawners down, just like how itemspawners work. Then it picks a random spawner and spawns zombies up to a limit which is equal to the number of zombie spawners.
     
  16. Re: NightAngel's Development Thead

    I guess that works too.
     
  17. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    I asked them, they said no. Sorry. :p
     
  18. Tomo742

    Tomo742 Guest

    Re: NightAngel's Development Thead

    Damn, your plugins are so nice. Would they prefer if I asked them out for a meal first? It will be a real nice candle lit dinner with champagne/wine and a fully expensive meal in a fully expensive restaurant, then I'll make sure I actually call them the day after and ask how they are and how their day was. Just generally being a nice guy for them.

    Just kidding, but seriously. Keep up the good work NightAngel, I look forward to seeing more plugins and hopefully of equal or even better quality.
     
  19. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    Yus, love them. Still looking for other possible weapon packs though, even making my junior coder apprentice code some with some workshop SWEP packs. :p
     
  20. NightAngel

    NightAngel Fuck off Lev

    Re: NightAngel's Development Thead

    Fixed up a few bugs, and added a fun little feature to the battle system. (It's not permanent) :p

    http://youtu.be/EgG5ykljVOg
     

Previous Readers (Total: 0)