• Help Editing Code
    3 replies, posted
Probably a stupid and simple question.. anyway Im trying to change owner from "Shared" to the player that spawned the car. Can anyone tweak it for me? [lua]if ply:Team() == TEAM_CAR then ply:AddMoney(-230) Notify(ply, 1, 3, "You bought a Jeep for $230") local car = ents.Create("prop_vehicle_jeep_old") car:SetModel("models/buggy.mdl") car:SetKeyValue("vehiclescript","scripts/vehicles/jeep_test.txt") car:SetNWEntity("owning_ent", ply) car:SetNWString("Owner", "Shared") car:SetPos(tr.HitPos) car.nodupe = true car:Spawn() car.SID = ply.SID return "" else Notify(ply, 1, 3, "You must be a Car Dealer to buy this.") end return "" end AddChatCommand("/buyjeep", BuyJeep) [/lua]
Replace line 8 with the following. [lua]car:SetNWString("Owner", ply:Nick())[/lua]
thanks
The code would be a lot easier to read if it was indented. [lua]--Some function if ply:Team() == TEAM_CAR then ply:AddMoney(-230) Notify(ply, 1, 3, "You bought a Jeep for $230") local car = ents.Create("prop_vehicle_jeep_old") car:SetModel("models/buggy.mdl") car:SetKeyValue("vehiclescript","scripts/vehicles/jeep_test.txt") car:SetNWEntity("owning_ent", ply) car:SetNWString("Owner", ply:Nick()) car:SetPos(tr.HitPos) car.nodupe = true car:Spawn() car.SID = ply.SID return "" else Notify(ply, 1, 3, "You must be a Car Dealer to buy this.") end return "" end AddChatCommand("/buyjeep", BuyJeep) [/lua]
Sorry, you need to Log In to post a reply to this thread.