Alright so I recently installed pointshop on my Murder server and everything works fine. No errors or anything.
My question is, is it possible to only allow the Murderer to buy certain weapons?
Otherwise any Bystander could just buy a weapon and kill everyone. (lol)
I've tried googling it, but to no avail.
So is there a fix?
Yes, write an OnBuy function that checks to make sure the player's team is murderer. If not, don't give the player the item and notify them via chatprint (or other method of your choosing) that they need to be murderer.
You'll also probably want to edit the OnEquip functions so the murderer doesn't switch weapons right away.
Sorry, I don't completely understand how to implement that into the script.
Could you modify this so that I can get an idea of how to do it in the future?
ITEM.Name = 'Pistol'
ITEM.Price = 200
ITEM.Model = 'models/weapons/W_pistol.mdl'
ITEM.WeaponClass = 'weapon_pistol'
ITEM.SingleUse = true
function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
First off, delete ply:SelectWeapon
I don't know what murder does to check the murderer but that needs to be part of an if statement in 'OnBuy'
Alright, so..
ITEM.Name = 'Pistol'
ITEM.Price = 200
ITEM.Model = 'models/weapons/W_pistol.mdl'
ITEM.WeaponClass = 'weapon_pistol'
ITEM.SingleUse = true
function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
end
function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
Now what?
-------------------------------
[B]Edit:[/B]
Found this on the site, but i'm still not sure how to add it.
[url]http://pointshop.burt0n.net/items[/url]
[B]Just need it so that only the murder can buy certain items and that when he does buy said item, it doesn't automatically equip.[/B]
Function: CanPlayerBuy
Arguments: ply (Player)
Realm: Server
Required: No
Description: Called when the player tries to buy the item. Return true or false.
Example:
function ITEM:CanPlayerBuy(ply)
return ply:Alive() -- only if alive
end
Replace 'ply:Alive()' with something that checks for team murder
[QUOTE=Scratch.;43626693]
Replace 'ply:Alive()' with something that checks for team murder[/QUOTE]
that's the problem though.. i have no idea how to add something that checks for team murder..
BUT, thank you for your reply. I saved that bit of code!
ply:Team("Murderer") perhaps? I don't know how Murder handles teams/roles. I'll check tomorrow to verify?
Or ply:GetMurderer(), thanks BFG.
[QUOTE=code_gs;43627576]ply:Team("Murderer") perhaps? I don't know how Murder handles teams/roles. I'll check tomorrow to verify?[/QUOTE]
I'll try it out when my server dies down! Thanks!
And thanks for all the other replies as well!
I tried it out a bit ago and it didn't work.
Here's what I used:
ITEM.Name = 'Pistol'
ITEM.Price = 200
ITEM.Model = 'models/weapons/W_pistol.mdl'
ITEM.WeaponClass = 'weapon_pistol'
ITEM.SingleUse = true
function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
end
function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end
function ITEM:CanPlayerBuy(ply)
return ply:Team("Murderer")
end
I was able to make it so they don't automatically equip it, but everyone is still able to buy it instead of just the murderer.
try this instead
[code]
function ITEM:CanPlayerBuy(ply)
return ply:GetMurderer()
end
[/code]
[editline]22nd January 2014[/editline]
I checked it on Github and it appears that's how the gamemode checks for the murderer.
I'll give it a shot and post results shortly!
Thanks!
Sorry, you need to Log In to post a reply to this thread.