(Quick) PointShop Help!

Hey Everyone!

I wanted to do a very simple function for the pointshop that would say when a person bought a item.


[OpenBottle has purched "Bob" from the point shop]  (BOX)      

I would like to know what file i would make this function in, and the command to get the persons steam name. If you really amazing and would like to tell me if there is any hooks i would need to use, soo i dont overwrite anything, even more appricated! :slight_smile:
(Sorry my for noobish Lua)

Have a nice day!

Code soo far:

function ITEM:OnBuy(ply)

Well, if buying is serverside (which I believe it is) then you can network to everyone using net.Broadcast() and send your message.

ok soo something like

 function ITEM:OnBuy(ply)
    net.Broadcast() SteamId() .. "Bought" .. Model

also, how would i make it to grab the persons name?

That’s not how you use the net library. Here’s an example of what you want to do: http://wiki.garrysmod.com/page/Net_Library_Usage

Why not just use ChatPrint?

Ty for the examples i understand how to use net.Broadcast. also i would like to know what is the code to grab the persons steamid? also how would i say what model they bought? or would i have to go to every model and paste the code.(Onbuy…)

thank you guys!

You could edit it and add in a check to see if it’s yours (such as ITEM.DisplayPurchase) and if that’s true, then it does the print of who bought what.

If it’s from the client to server, then the second argument of net.Receive function is Player. Just use Player:SteamID( );

If it’s from the server to client, then there is no player sending the message.

is that possible to use that? i dont see it on the pointshop commands and functions

[editline]18th March 2014[/editline]

It would be like when any person gets an item from the pointshop it would say 'Example bought Example from the pointshop"

Either I’m misinterpreting what this guy wants or you guys are convoluting this beyond what it needs to be.

local ItemName = "Name of your item" -- I don't think items work the same as other 'entities' so you'll have to copy the name here I guess

function ITEM:OnBuy(ply)
    BroadcastLua("local ItemName = " .. ItemName .. " local player = " .. ply:Nick() .. " chat.AddText( player, 'bought', Color(0,200,0), ItemName, Color(255,255,255), 'from the Pointshop!')")

Untested, And if that fucks up for some reason I guarantee this to work:

local ItemName = "Acecool of the pure Master Ace"

function ITEM:OnBuy(ply)
for k, player in pairs( player.GetAll() ) do
	player:ChatPrint( ply:Nick() .. "Bought " .. ItemName .. "from the Pointshop!" )

Edit: fix’d

That wouldn’t like to work, so do this

local ItemName = "acecool pls"

function ITEM:OnBuy(ply)
for k, players in pairs( player.GetAll() ) do
	players:ChatPrint( ply:Nick() .. "Bought " .. ItemName .. "from the Pointshop!" )

Shit just realized that I used ply as the keyvalue

Updated with fixed code

Ty you guys!

i would put that in all the lua files for the models

pointshop>lua>item>playermodels>_____.lua right?