Skip to content

Instantly share code, notes, and snippets.

@ValentinFunk
ValentinFunk / SketchSystems.spec
Last active September 28, 2018 10:09
Draft Email Flow
Draft Email Flow
Clicked CTA
No action for one hour? -> Aborted Creation
Create Draft -> Initial Creation
Draft Created
Publish Trip -> Draft Published
Initial Creation*
Change Trip -> Initial Creation
No action for 1 hour? -> Active
Active
@ValentinFunk
ValentinFunk / Add New Button.md
Last active June 13, 2018 20:56
Pointshop 2 - Add external menu button

Adding a button to the PS2 Inventory section

It's easy to add a button that opens another menu. Here a report menu button was added:

img

Create a new file in garrysmod/lua/autorun/ps2_extrabuttons.lua with the following contents:

AddCSLuaFile()
Pointshop2:AddInventoryButton( "Report Menu", "pointshop2/warning8.png", function( )
 -- Run console command to open the report menu
@ValentinFunk
ValentinFunk / README.md
Last active June 20, 2018 17:10
Serve firebase functions efficiently through express. Doesn't make the PC die as the cloud functions emulator does but is less accurate.

Replacement for firebase functions:serve

Serve firebase functions efficiently through express. Doesn't make the PC die as the cloud functions emulator does but is a bit less closer to the real env they run in. Useful for dev.

This uses a simple express server to serve your functions. It's nice for developing as the restarting is much faster and it doesn't use as much of your CPU/Ram as the cloud functions emulator does.

Setup

  1. Make sure your firebase service account is saved to your functions config under the serviceacc key.
@ValentinFunk
ValentinFunk / 0Guide.MD
Last active March 24, 2018 16:51
Making Customizable Weaponry 2.0 Attachments work with Pointshop 2 Tutorial. Full Code: https://github.com/Kamshak/ps2-customizable-weaponry

Generating Pointshop 2 Items programatically

The goal here is to integrate an external system into Pointshop 2 by using items. Since they are already created we only need to map them to PS2 items. For this example Attachments for Customizable Weaponry 2 are used. CW2 offers a system where players can pick attachments in a menu. Players can only pick attachments that they own.

  1. Players should be able to buy attachments in Pointshop2
  2. Players should be given all attachments they own in Pointshop2 so that CW can pick them up
  3. It should be possible to set the price for the attachments individually
@ValentinFunk
ValentinFunk / action.lua
Created February 21, 2018 00:12
Prometheus Action for increasing player's pointshop 2 inventory size (slots)
Pointshop2.DB.DoQuery(Format("UPDATE inventories SET numSlots = numSlots + 40 WHERE ownerId = (SELECT id FROM libk_player WHERE player = %s)", Prometheus.Temp.SteamID))
Prometheus.Temp.Ply.fullyLoadedPromise:Then(function() Pointshop2Controller:initializeInventory(Prometheus.Temp.Ply))
@ValentinFunk
ValentinFunk / cl_myview.lua
Last active February 20, 2018 23:32
LibK Networking
MyView = class( "MyView" )
MyView:include( BaseView )
-- Set the controller to use
MyView.static.controller = "MyController"
function MyView:OnMapChanged(map)
hook.Run("ServerMapChanged", map)
-- This is a useful pattern for derma updating:
--[[
function PANEL:Init()
import sqlite3
from optparse import OptionParser
ps2Tables = [
"libk_player",
"ps2_itemexpiration",
"ps2_settings",
"ps2_plyjoinstreak",
"ps2_wallet",
"ps2_itempersistence",
@ValentinFunk
ValentinFunk / Guide.md
Last active June 13, 2018 20:58
Bind to F6. Put in lua/autorun

Binding Pointshop 2 to a key other than F1-F3

Put this script into lua/autorun. You can change KEY_F6 to any other key, for a list of keys look here: List of Keys - Gmod Wiki

@ValentinFunk
ValentinFunk / sv_ps2_knifepoints.lua
Last active February 12, 2018 15:48
Give extra points on knife kill (Pointshop 2). Create the file below in garrysmod/lua/autorun
local ptsMap = {
["csgo_bayonet"] = 10,
others = 5
}
hook.Add( "PlayerDeath", "ExtraPointsForKnifeKill", function( victim, inflictor, attacker )
if not IsValid( inflictor ) or not IsValid( attacker ) or not attacker:IsPlayer( ) then
return
end
@ValentinFunk
ValentinFunk / user.service.ts
Created February 2, 2018 09:24
Firebase Universal Example
@Injectable()
export class UserService {
constructor(private db: AngularFireDatabase, private zone: NgZone) {}
getUser(id: string | number): Observable<User> {
const user$ = this.database.object('profiles/' + id);
this.universalBlockUntilFirst(user$);
return user$;
}