• (Quick) PointShop Help!
    13 replies, posted
Hey Everyone! I wanted to do a very simple function for the pointshop that would say when a person bought a item. E.g __________________________________________ [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! :) (Sorry my for noobish Lua) Have a nice day! Code soo far: [code]function ITEM:OnBuy(ply) ply:Kill() end[/code]
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 [code] function ITEM:OnBuy(ply) net.Broadcast() SteamId() .. "Bought" .. Model end[/code] 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: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
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.
[QUOTE]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.[/QUOTE] is that possible to use that? i dont see it on the pointshop commands and functions [editline]18th March 2014[/editline] [QUOTE]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.[/QUOTE] 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. [code] 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!')") end[/code] Untested, And if that fucks up for some reason I guarantee this to work: [code] 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!" ) end end [/code] Edit: fix'd
[QUOTE=BFG9000;44285204] [code] local ItemName = "Bleh" function ITEM:OnBuy(ply) for k, pl in pairs( player.GetAll() ) do ply:ChatPrint( ply:Nick() .. "Bought " .. ItemName .. "from the Pointshop!" ) end end [/code][/QUOTE] That wouldn't like to work, so do this [code] 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!" ) end end [/code]
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?
[QUOTE=JewishZebra;44291196]Ty you guys! i would put that in all the lua files for the models pointshop>lua>item>playermodels>_____.lua right?[/QUOTE] Yes.
Sorry, you need to Log In to post a reply to this thread.