[QUOTE=txbondboy;52292310]i was having trouble trying to get the table of the player with the class. i didn't know how to reference it and nobody helped me with it.[/QUOTE]
Quote the post where you asked for help and I will see what I can do for you.
[QUOTE=Revenge282;52292343]Quote the post where you asked for help and I will see what I can do for you.[/QUOTE]
[url]https://facepunch.com/showthread.php?t=1565550[/url]
-snip-
Is there a function similar to [URL="https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/cdll_int.h#L425"]IsTakingScreenshot[/URL]?
[QUOTE=Sean Bean;52295107]Is there a function similar to [URL="https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/cdll_int.h#L425"]IsTakingScreenshot[/URL]?[/QUOTE]
Probably not - what are you trying to do?
[QUOTE=MPan1;52295122]Probably not - what are you trying to do?[/QUOTE]
Check if a client is taking a screenshot.
I meant why do you want to check it? There may be a different way to do it without using that function, but some context may clear things up for why you want to check if they are taking a screenshot in the first place.
[QUOTE=MPan1;52295146]I meant why do you want to check it? There may be a different way to do it without using that function, but some context may clear things up for why you want to check if they are taking a screenshot in the first place.[/QUOTE]
So i can check if a client is taking a screenshot. I don't know how to make that any simpler for you.
[QUOTE=Sean Bean;52295204]So i can check if a client is taking a screenshot. I don't know how to make that any simpler for you.[/QUOTE]
There isn't a way. He was asking what you were needing this for so perhaps we could recommend a similar alternative based on the situation.
[QUOTE=Sean Bean;52295204]So i can check if a client is taking a screenshot. I don't know how to make that any simpler for you.[/QUOTE]
He asked [b]why you want to check this[/b]. I'm guessing you want to catch when your players take screenshots and inform the server of this so that you can... I dunno, ban them? If that's the case, please stop trying and don't be a jerk to your players. But if you have some other reason to do this, we may be able to help in some different out-of-the-box way. It's called the XY problem (shitty name), and MPan rightly assumes you're doing it. That's not an insult, I do it all the time as do all programmers.
[QUOTE=Sean Bean;52295204]So i can check if a client is taking a screenshot. I don't know how to make that any simpler for you.[/QUOTE]
You can [URL="https://github.com/ThatLing/hex-memorial/blob/master/hex/addons/hex's%20server%20plugins/lua/hsp/gfx/cl_screenlogger.lua"]use some[/URL] [URL="https://github.com/ThatLing/hex-memorial/blob/master/Repos/HAC-master/v13/HeX's%20AntiCheat/lua/HAC/cl_TakeSC.lua"]hacky methods[/URL] to detect screenshotting.
Anyone got a simple way to determine the correct value to give for an NPC's move_yaw pose parameter?
[QUOTE=Sean Bean;52295204]So i can check if a client is taking a screenshot. I don't know how to make that any simpler for you.[/QUOTE]
Sorry. I probably was not being clear enough either. This is the clearest that I can manage (and ignore the fact IsTakingScreenshot isn't a real thing yet):
[CODE]if ply:IsTakingScreenshot() then
-- WHAT ARE YOU DOING HERE
-- WHAT CODE DO YOU HAVE IN HERE
-- WHY DO YOU WANT TO CHECK IF THE PERSON IS TAKING A SCREENSHOT
-- I HAVE NO CONTEXT SO SOME CONTEXT WOULD HELP
-- SORRY FOR WRITING IN CAPS BUT I JUST WANT TO MAKE SURE
end
[/CODE]
Okay, so I took a rag doll and made it into an entity. The hit boxes/collision boxes are all sorts of fucked up. Anyone know why that would be? I'm sort of hoping there is a simple solution to this and I won't have to go and recompile the model or something like that. :/
This rag doll is just a model that has multiple body groups that you can move around and stuff.
[QUOTE=bosnian_cyco;52298609]Okay, so I took a rag doll and made it into an entity. The hit boxes/collision boxes are all sorts of fucked up. Anyone know why that would be? I'm sort of hoping there is a simple solution to this and I won't have to go and recompile the model or something like that. :/
This rag doll is just a model that has multiple body groups that you can move around and stuff.[/QUOTE]
Share your code. You're probably not initializing it properly.
[QUOTE=NeatNit;52298627]Share your code. You're probably not initializing it properly.[/QUOTE]
[code] function ENT:Initialize()
self:SetModel("models/kali/weapons/tow/m220 tow launcher.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
phys:EnableMotion(false)
end
end
[/code]
I tried messing with different SOLID_ENUMS with no success for both PhysicsInit and SetSolid. I figured MoveType didn't have anything to do with it.
[QUOTE=thejjokerr;52298640]Can you show the part where you spawn this entity as well?[/QUOTE]
Uhh, what? It's spawned in through the Q-menu when you're in game. There isn't any part of the code where I spawn the entity. Am I missing something?
How do i disable kill feed in custom gamemode?
npc wont drop anything anymore after i added this code
[lua]function GM:OnNPCKilled(npc, attacker, inflictor)
attacker:SetNWInt("playerMoney", attacker:GetNWInt("playerMoney") + 50)
attacker:SetNWInt("playerExp",attacker:GetNWInt("playerExp") + 100)
attacker:SetNWInt("playerLvl",attacker:GetNWInt("playerLvl") + 1)
end[/lua]
npc drop system
[lua]function GM:OnNPCKilled(victim, killer, weapon)
local Rand = math.random(1, 3)
local SpawnHeight = 100
local NpcPos = victim:GetPos()
local Drop
if Rand == 1 then
Drop = ents.Create("weapon_pistol")
Drop:SetPos(NpcPos+Vector(0, 0, SpawnHeight))
Drop:Spawn()
Drop:Activate()
elseif Rand == 2 then
Drop = ents.Create("item_ammo_pistol")
Drop:SetPos(NpcPos+Vector(0, 0, SpawnHeight))
Drop:Spawn()
Drop:Activate()
elseif Rand == 3 then
Drop = ents.Create("item_ammo_smg1_large")
Drop:SetPos(NpcPos+Vector(0, 0, SpawnHeight))
Drop:Spawn()
Drop:Activate()
end
end[/lua]
how to fix?
Only set the NWInt if the attacker is a player. Also, merge the two functions -- you are overriding one with the other. Lastly, your drop code can be heavily simplified by making a table of entity classes and running all the same methods on it.
[QUOTE=code_gs;52299676]Only set the NWInt if the attacker is a player. Also, merge the two functions -- you are overriding one with the other. Lastly, your drop code can be heavily simplified by making a table of entity classes and running all the same methods on it.[/QUOTE]
how can it be simplified?
[QUOTE=RasmusG5;52299728]how can it be simplified?[/QUOTE]
[code]local tClasses = {
"weapon_pistol",
"item_ammo_pistol",
"item_ammo_smg1_large"
}
local iChoices = #tClasses
local flSpawnHeight = 100
function GM:OnNPCKilled(pVictim)
local pDrop = ents.Create(tClasses[math.random(1, iChoices)])
if (pDrop:IsValid()) then
local vSpawnPos = pVictim:GetPos()
vSpawnPos[3] = vSpawnPos[3] + flSpawnHeight
pDrop:SetPos(vSpawnPos)
pDrop:Spawn()
end
end[/code]
[QUOTE=code_gs;52299951][code]local tClasses = {
"weapon_pistol",
"item_ammo_pistol",
"item_ammo_smg1_large"
}
local iChoices = #tClasses
local flSpawnHeight = 100
function GM:OnNPCKilled(pVictim)
local pDrop = ents.Create(tClasses[math.random(1, iChoices)])
if (pDrop:IsValid()) then
local vSpawnPos = pVictim:GetPos()
vSpawnPos[3] = vSpawnPos[3] + flSpawnHeight
pDrop:SetPos(vSpawnPos)
pDrop:Spawn()
end
end[/code][/QUOTE]
i got this error while merging 2 functions
[lua]
[ERROR] gamemodes/metro_online/gamemode/init.lua:274: attempt to index global 'attacker' (a nil value)
1. unknown - gamemodes/metro_online/gamemode/init.lua:274
[/lua]
[lua]local iChoices = #tClasses
local flSpawnHeight = 100
function GM:OnNPCKilled(pVictim)
local pDrop = ents.Create(tClasses[math.random(1, iChoices)])
if (pDrop:IsValid()) then
local vSpawnPos = pVictim:GetPos()
vSpawnPos[3] = vSpawnPos[3] + flSpawnHeight
pDrop:SetPos(vSpawnPos)
pDrop:Spawn()
attacker:SetNWInt("playerMoney", attacker:GetNWInt("playerMoney") + 50)
attacker:SetNWInt("playerExp",attacker:GetNWInt("playerExp") + 100)
attacker:SetNWInt("playerLvl",attacker:GetNWInt("playerLvl") + 1)
end
end
[/lua]
[QUOTE=NeatNit;52298627]Share your code. You're probably not initializing it properly.[/QUOTE]
Did I initialize that properly?
[QUOTE=bosnian_cyco;52300103]Did I initialize that properly?[/QUOTE]
No code to look at?
[editline]1st June 2017[/editline]
[QUOTE=RasmusG5;52300067]i got this error while merging 2 functions
[lua]
[ERROR] gamemodes/metro_online/gamemode/init.lua:274: attempt to index global 'attacker' (a nil value)
1. unknown - gamemodes/metro_online/gamemode/init.lua:274
[/lua]
[lua]local iChoices = #tClasses
local flSpawnHeight = 100
function GM:OnNPCKilled(pVictim)
local pDrop = ents.Create(tClasses[math.random(1, iChoices)])
if (pDrop:IsValid()) then
local vSpawnPos = pVictim:GetPos()
vSpawnPos[3] = vSpawnPos[3] + flSpawnHeight
pDrop:SetPos(vSpawnPos)
pDrop:Spawn()
attacker:SetNWInt("playerMoney", attacker:GetNWInt("playerMoney") + 50)
attacker:SetNWInt("playerExp",attacker:GetNWInt("playerExp") + 100)
attacker:SetNWInt("playerLvl",attacker:GetNWInt("playerLvl") + 1)
end
end
[/lua][/QUOTE]
Attacker isn't defined in the code you have supplied, is it defined somewhere above? Also, I suggest using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetPData]Player:SetPData[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetPData]Player:GetPData[/url] for something like player money and experience.
[QUOTE=MrRalgoman;52300144]No code to look at?
[editline]1st June 2017[/editline]
Attacker isn't defined in the code you have supplied, is it defined somewhere above? Also, I suggest using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetPData]Player:SetPData[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetPData]Player:GetPData[/url] for something like player money and experience.[/QUOTE]
Sorry it was on the other page, here -
[code] function ENT:Initialize()
self:SetModel("models/kali/weapons/tow/m220 tow launcher.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
phys:EnableMotion(false)
end
end [/code]
[QUOTE=RasmusG5;52300067]i got this error while merging 2 functions
:snip:[/QUOTE]
You didn't define `attacker` as an argument in your function, it's should be second argument.
[QUOTE=MrRalgoman;52300144]
Attacker isn't defined in the code you have supplied, is it defined somewhere above? Also, I suggest using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetPData]Player:SetPData[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetPData]Player:GetPData[/url] for something like player money and experience.[/QUOTE]
Neither of those network the value.
[QUOTE=bigdogmat;52300253]You didn't define `attacker` as an argument in your function, it's should be second argument.
Neither of those network the value.[/QUOTE]
Sure, but you could network the Player:GetPData. I just feel like it would be better practice to store that sort of data in a DB rather than just leaving it as a networked var.
Wouldn't it reset every time the server restarts anyway?
[QUOTE=MrRalgoman;52300368]Sure, but you could network the Player:GetPData. I just feel like it would be better practice to store that sort of data in a DB rather than just leaving it as a networked var.
Wouldn't it reset every time the server restarts anyway?[/QUOTE]
Yes it'd reset, but I imagine it's probably saved when the player leaves or the server shuts down. Though it'd be probably be better to have a common method that updates the nwvar as well as the wherever it's stored, that way crashes don't affect it.
[QUOTE=RasmusG5;52300067]i got this error while merging 2 functions
[lua]
[ERROR] gamemodes/metro_online/gamemode/init.lua:274: attempt to index global 'attacker' (a nil value)
1. unknown - gamemodes/metro_online/gamemode/init.lua:274
[/lua]
[lua]local iChoices = #tClasses
local flSpawnHeight = 100
function GM:OnNPCKilled(pVictim)
local pDrop = ents.Create(tClasses[math.random(1, iChoices)])
if (pDrop:IsValid()) then
local vSpawnPos = pVictim:GetPos()
vSpawnPos[3] = vSpawnPos[3] + flSpawnHeight
pDrop:SetPos(vSpawnPos)
pDrop:Spawn()
attacker:SetNWInt("playerMoney", attacker:GetNWInt("playerMoney") + 50)
attacker:SetNWInt("playerExp",attacker:GetNWInt("playerExp") + 100)
attacker:SetNWInt("playerLvl",attacker:GetNWInt("playerLvl") + 1)
end
end
[/lua][/QUOTE]
Define attacker in the arguments and put the NWVar calls outside of the IsValid check
Sorry, you need to Log In to post a reply to this thread.