• Give ranked players weapon on spawn (TTT)
    48 replies, posted
[QUOTE=ChrisKohly;42435235]Going to test right now, though mind you the server is SANDBOX, not TTT, but testing otherwise[/QUOTE] It's not going to work in sandbox, because of "plymeta:CanCarryWeapon(WepClass)". So you'll have to delete that condition check.
Well, would you know about how to make a script similar to the above posted, but to work in sandbox? For Multiple ranks, like client, respected and regular? I've been trying to get this working for weeks now, i'd really appreciate just a basic script that allows for customized weapons upon respawn..
[QUOTE=ChrisKohly;42435295]Well, would you know about how to make a script similar to the above posted, but to work in sandbox? For Multiple ranks, like client, respected and regular? I've been trying to get this working for weeks now, i'd really appreciate just a basic script that allows for customized weapons upon respawn..[/QUOTE] Refresh your page I told you how in my post.
I removed this line from above script: if ply:CanCarryWeapon(v) then should it be sandbox-friendly now..?
[QUOTE=ChrisKohly;42435363]I removed this line from above script: if ply:CanCarryWeapon(v) then should it be sandbox-friendly now..?[/QUOTE] You need to remove the "end" that closes that statement too. [lua] //lua/autorun/server local SBOX_WB = { ["servermanager"] = {"m9k_colt1911"}, ["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"} } hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply) local benefits = SBOX_WB[ply:GetNWString("usergroup")] if !benefits then return end for k,v in ipairs(benefits) do ply:Give(v) end end) [/lua]
[QUOTE=Handsome Matt;42435379]It should also be noted that different admin mods have different ways of dealing with usergroups, so if you're using Evolve for example that uses Player.EV_GetRank. [editline]6th October 2013[/editline] YES, the server uses EVOLVE, that's probably why it's not working. Last time I got any result, all player models were black, and upon death, you were non-existant. Scary scripting fails.. so, i need to be using [B]Player.EV_GetRank[/B] rather then what I was using before, okay got it. So now that its been determined the server's admin mod is EVOLVE,should I be using this format: //lua/autorun/server local SBOX_WB = { ["servermanager"] = {"m9k_colt1911"}, ["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"} } hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply) local benefits = SBOX_WB[ply:GetNWString("usergroup")] if !benefits then return end for k,v in ipairs(benefits) do ply:Give(v) end end) or this one if SERVER then // This is where the init.lua stuff goes. //This makes sure clients download the file AddCSLuaFile("weaponspawn.lua") end local function giveWeapon(ply) if ply:CheckGroup("regular") or ply:CheckGroup("moderator") or ply:CheckGroup("admin") or ply:IsUserGroup("janitor") then ply:Give("weapon_zm_revolver") end end hook.Add("PlayerLoadout", "giverankedWeapon", giveWeapon) [editline]6th October 2013[/editline] sorry that i'm not so sure on how to make the lua appear black backgrounded, hope its not too confusing to understand.. D: [editline]6th October 2013[/editline] here is what I have so far.. [CODE]//lua/autorun/server/test.lua local SBOX_WB = { ["servermanager"] = {"m9k_colt1911"}, ["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"} } hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply) local benefits = SBOX_WB[ply:GetNWString("Player.EV_GetRank")] if !benefits then return end for k,v in ipairs(benefits) do ply:Give(v) end end)[/CODE]
To get the black background use [.lua][/lua] tags. This should make it work with Evolve: [lua]//lua/autorun/server local SBOX_WB = { ["servermanager"] = {"m9k_colt1911"}, ["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"} } hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply) local benefits = ply:GetNWString("usergroup") if (ply.EV_GetRank) then benefits = ply:EV_GetRank() end benefits = SBOX_WB[benefits] if !benefits then return end for k,v in ipairs(benefits) do ply:Give(v) end end) [/lua]
[QUOTE=brandonj4;42435532]To get the black background use [.lua][/lua] tags. This should make it work with Evolve: [lua]//lua/autorun/server local SBOX_WB = { ["servermanager"] = {"m9k_colt1911"}, ["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"} } hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply) local benefits = ply:GetNWString("usergroup") if (ply.EV_GetRank) then benefits = ply:EV_GetRank() end benefits = SBOX_WB[benefits] if !benefits then return end for k,v in ipairs(benefits) do ply:Give(v) end end) [/lua][/QUOTE] I tested this script and servermanager didn't get a colt1911 upon spawn, nor did console mention anything of the script's existance.. what do? [editline]6th October 2013[/editline] help, anyone? :/
You could just debug it. [lua] //lua/autorun/server local SBOX_WB = { ["servermanager"] = {"m9k_colt1911"}, ["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"} } hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply) local benefits = ply:GetNWString("usergroup") if (ply.EV_GetRank) then benefits = ply:EV_GetRank() end print(benefits) benefits = SBOX_WB[benefits] PrintTable(benefits) if !benefits then return end for k,v in ipairs(benefits) do ply:Give(v) end end) [/lua] Post what it prints into the console.
Yes, the server runs all m9k weapons, of which, all ranks can use the colt 1911, and that the weapon name is m9k_colt1911 [editline]7th October 2013[/editline] [QUOTE=brandonj4;42436062]You could just debug it. [lua] //lua/autorun/server local SBOX_WB = { ["servermanager"] = {"m9k_colt1911"}, ["specialguest"] = {"weapon_zm_revolver", "weapon_ttt_m16"} } hook.Add("PlayerSpawn", "SBOX_WB.PlayerSpawn", function(ply) local benefits = ply:GetNWString("usergroup") if (ply.EV_GetRank) then benefits = ply:EV_GetRank() end print(benefits) benefits = SBOX_WB[benefits] PrintTable(benefits) if !benefits then return end for k,v in ipairs(benefits) do ply:Give(v) end end) [/lua] Post what it prints into the console.[/QUOTE] [url]http://www.lua.org/cgi-bin/demo[/url] Okay, I "debugged" it, what am I to do to correct it? I'm sorry I'm not the most experience in reading scripts/lua
[QUOTE=ChrisKohly;42436165]Yes, the server runs all m9k weapons, of which, all ranks can use the colt 1911, and that the weapon name is m9k_colt1911 [editline]7th October 2013[/editline] Debug it within Garry's Mod... [url]http://www.lua.org/cgi-bin/demo[/url] Okay, I "debugged" it, what am I to do to correct it? I'm sorry I'm not the most experience in reading scripts/lua[/QUOTE] You're supposed to run the code in Garry's Mod...
[QUOTE=centran;38891409]If you are running ULX use the following code otherwise replace ply:CheckGroup with ply:IsUserGroup("regular") [LUA] if SERVER then // This is where the init.lua stuff goes. //This makes sure clients download the file AddCSLuaFile("weaponspawn.lua") end local function giveWeapon(ply) if ply:CheckGroup("regular") or ply:CheckGroup("moderator") or ply:CheckGroup("admin") or ply:IsUserGroup("janitor") then ply:Give("weapon_zm_revolver") end end hook.Add("PlayerLoadout", "giverankedWeapon", giveWeapon) [/LUA] oh and if moderator, admin, and janitor inherit from regular all you need is the check for regular.[/QUOTE] where i put this?
[QUOTE=jeepingviini;46044806]where i put this?[/QUOTE] garrysmod/lua/autorun/ and make a lua file with a name like giverankedweapon.lua or something and copy paste the code. i would recommend using brandonj4 codes insteed (post #29).
[QUOTE=Tomelyr;46046001]giverankedweapon.lua[/QUOTE] [QUOTE=centran;38891409] AddCSLuaFile("weaponspawn.lua") [/QUOTE] name it weaponspawn.lua
[QUOTE=Sm63;46046603]name it weaponspawn.lua[/QUOTE] for what does it needs an CS Lua? The check is server imo.
[QUOTE=Tomelyr;46046766]for what does it needs an CS Lua? The check is server imo.[/QUOTE] x1 bad reading Im saying "Dont name it giverankedweapon.lua, name it weaponspawn.lua" because the AddCSLuaFile (by default) is adding 'weaponspawn.lua'
[QUOTE=zapha;38898045]Works like a charm, Thank you very much, and thank you to everyone else that have contributed! I still have 2 questions though. 1) if i want to add some ammo to the weapon of choice, should it then be like this? [lua] ply:Give("item_ammo_revolver_ttt") [/lua] after the functions "then" and with some sort of amount? number maybe? 2) if i want to change it so that for instance mods spawn with an AK, and regulars with a deagle can i then do this? [lua] if SERVER then AddCSLuaFile("weaponspawn.lua") end local function giveWeapon(ply) if ply:CheckGroup("moderator") then ply:Give("ttt_weapon_ak47") elseif ply:CheckGroup("regular") then ply:Give("weapon_zm_revolver") end end hook.Add("PlayerLoadout", "giverankedWeapon", giveWeapon) [/lua][/QUOTE] works create
Sorry, you need to Log In to post a reply to this thread.