• Spawning entities and vehicles using pointshop
    4 replies, posted
I would like to use pointshop to spawn vehicles and entities. For example, You buy a bouncy ball for 200 points and it spawns right in front of you. Samething with a jeep. Can somebody who is better at lua coding give me the hook/script required to do this? example of file: ITEM.Name = 'Jeep' ITEM.Price = 200 ITEM.Model = 'JEEP MODEL HERE' ITEM.SingleUse = true function ITEM:OnBuy(ply) -Code I need here- Thanks in advance!
You'll need to use [URL="http://wiki.garrysmod.com/page/ents/Create"]ents.Create[/URL] for creating the bouncy ball entity, and [URL="http://wiki.garrysmod.com/page/Player/GetEyeTrace"]Player:GetEyeTrace()[/URL] for getting where the player is looking.
Ok I understand the 2 formulas to use but could you compile them into a simple block of code so that I can study that? Im not sure how to combine those 2 to get the final product
Something like this. This is just an example, so you should probably add some checks in there. [code] local function SpawnItOrWhatever(ply) //assuming the function used passes ply. local tr = ply:GetEyeTrace(); local v = ents.Create("prop_vehicle_jeep"); v:SetModel("models/buggy.mdl"); v:SetKeyValue("vehiclescript", "scripts/vehicles/jeep_test.txt"); v:SetPos(tr.HitPos) v:Spawn(); v:Activate(); end [/code]
Thanks. Worked great. Thanks for the help!
Sorry, you need to Log In to post a reply to this thread.