Hello,
I explain to you my problem, I would like to make sure that when a game starts instead of giving the basic magnum of the gamemode it gives the weapon which is in a slot "Magnum" in the pointshop 2 but if this one is empty it gives the base magnum (ie: weapon_mu_magnum)
Thanks in advance if anyone knows how to do it since I tried things but nothing works :(
Have a good day.
and WHAT have you actually tried?
You are supposed to tell us, you know?
I tried in sv_rounds.lua to use the function PS2_GetItemInSlot, in ps2 I saw this function to get item in slot (ie: Magnum).
if IsValid(magnum) then
magnum:Give(self:PS2_GetItemInSlot( "Magnum" ))
end
But when I use that in console it give me an error
[ERROR] gamemodes/murder/gamemode/sv_rounds.lua:342: attempt to call method 'PS2_GetItemInSlot' (a nil value)
1. StartNewRound - gamemodes/murder/gamemode/sv_rounds.lua:342
2. RoundThink - gamemodes/murder/gamemode/sv_rounds.lua:102
3. unknown - gamemodes/murder/gamemode/init.lua:95
so you tried 1 thing..
what you could probably do is strip the players weapon on round start, and then immidiatley give them your weapons by choice. Not sure if there is a way to do this before the rounds started
Not enough code is provided.
What is self, why you gave Magnum from PS2 to the magnum?
local noobs = table.Copy(players)
table.RemoveByValue(noobs, murderer)
local magnum = table.Random(noobs)
if IsValid(magnum) then
magnum:Give(self:PS2_GetItemInSlot( "Magnum" ))
end
It's the full code, and self is for guys who get the magnum. And I want to give the weapon in the pointshop 2 slot name "Magnum"
Maybe because Give() and not give()?
Thanks that worked but if the slot is empty the game don't give any gun but I want do if the slot is empty then the game give the vanilla magnum ""weapon_mu_magnum""
local noobs = table.Copy(players)
table.RemoveByValue(noobs, murderer)
local magnum = table.Random(noobs)
if IsValid(magnum) then
local item = magnum:PS2_GetItemInSlot( "Magnum" )
if item then
magnum:Give( item.weaponClass or "weapon_mu_magnum" )
end
end
I tried that and:
local noobs = table.Copy(players)
table.RemoveByValue(noobs, murderer)
local magnum = table.Random(noobs)
if IsValid(magnum) then
local item = magnum:PS2_GetItemInSlot( "Magnum" ) or "weapon_mu_magnum"
if item then
magnum:Give( item.weaponClass )
end
end
But the game don't want give any weapon if the slot is empty :/
Anyone know how can I solve it?
local item = magnum:PS2_GetItemInSlot( "Magnum" ) or "weapon_mu_magnum"
if item then
magnum:Give( item.weaponClass )
end
tbh that if statement is pretty useless. It only check is item is literally anything besides..well, nothing. Which it is. its either magnum:PS2_GetItemInSlot( "Magnum" ) or "weapon_mu_magnum"
So the magnum:Give( item.weaponClass ) will just always execute. So why even use the if statement?
Ok so what can you tell me to solve this? Because I will be honest I do not see how?
doyou even check anywhere if the slot is empty? All i see is a check if there is a magnum. unless i miss something
Sorry, you need to Log In to post a reply to this thread.