TTT Pointshop Help :)

Hi,

I am basically almost done with my server but am stuck on 2 things.

  1. What’s a line of code I can put in a weapon file in the pointshop to only let them buy a weapon once per round: Ex

ITEM.Name = ‘AK47’
ITEM.Price = 0
ITEM.Model = ‘models/weapons/w_rif_ak47.mdl’
ITEM.WeaponClass = ‘weapon_ttt_ak47’
ITEM.SingleUse = true
ITEM.AllowedUserGroups = { “donator”, “owner”, “superadmin” }

function ITEM:OnBuy(ply)
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end

  1. How would I make a !donate command to sned the person to the steam browser and go to my specified page, I have tryed using this command beofre from diffrent codes and none worked for me :confused:

Thanks!


(User was banned for this post ("wrong section" - postal))

  1. ITEM.SingleUse = true
  2. http://wiki.garrysmod.com/page/gui/OpenURL

Thanks for the second answer but for the first it is already true I want to make it where they can only spawn one per round.

One per player?

Yeah basically each donator can buy one, it’s already set for each donator but they can buy unlimated

Check if the player has the weapon using ply.HasWeapon, and if they do, don’t allow them to buy it.

If that worked, I’d hurry and delete this thread before something bad happens. :\

So let me get this straight you want it so they can only buy the item once a round?

You could use NWBools. When the player buys it for the round it is set, then if it is set to true they can not buy another. I can’t recall which file, but if you dig around the TTT code a little you can find where to have it reset each round.
Think it is player_ext.lua

function ITEM:OnBuy( ply )

function ITEM:CanPlayerBuy( ply )

This code below what it does is it only allows them to buy it if they currently don’t have it in their inventory. So basically they could just drop it and buy a new one. You would need to store purchases in order to full check. Also this will charge the player even if they attempt to buy it again and they can’t. So like if you have ak and buy it again, you wont get an ak but it will still charge you. A text will appear in chat saying, “You already have this weapon”. May I suggest posting a job on CoderHire :slight_smile: But hope this helps and enjoy!

[lua]

ITEM.Name = ‘AK47’
ITEM.Price = 0
ITEM.Model = ‘models/weapons/w_rif_ak47.mdl’
ITEM.WeaponClass = ‘weapon_ak47’
ITEM.SingleUse = true
ITEM.AllowedUserGroups = { “donator”, “owner”, “superadmin” }

function ITEM:OnBuy(ply)
if ply:HasWeapon( “weapon_ak47” ) then
ply:ChatPrint(“You already have this weapon!”)
else
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
end

function ITEM:OnSell(ply)
ply:StripWeapon(self.WeaponClass)
end

[/lua]