im wondering how can i make a bought weapon not spawn on the floor but spawn into player weapon slot?
probably want to go to gamemodes/darkrp/gamemode/modules/base/sv_purchasing.lua
and edit somewhere around line 70
make it give the player a weapon instead of create a "spawned_weapon"
[editline]26th April 2017[/editline]
i suggest first editting something like the gunlab to give the player the p226 instead of spawn it, this will be simpler
have a look at a custom money printers code to see how they give money directly to the player instead of spawning money on the printer... should be an easy edit :)
[QUOTE=bloodmasked;52152026]probably want to go to gamemodes/darkrp/gamemode/modules/base/sv_purchasing.lua
and edit somewhere around line 70
make it give the player a weapon instead of create a "spawned_weapon"
[editline]26th April 2017[/editline]
i suggest first editting something like the gunlab to give the player the p226 instead of spawn it, this will be simpler
have a look at a custom money printers code to see how they give money directly to the player instead of spawning money on the printer... should be an easy edit :)[/QUOTE]
[url]http://corefiles.darkrp.eu/[/url]
On-topic: Try this. Untested.
[lua]
hook.Add( "playerBoughtPistol", "autopickup", function( ply, weaponTable, weaponEntity, price )
weaponEntity:Use( ply )
end )
[/lua]
References:
[url]http://wiki.darkrp.com/index.php/Hooks/Server/playerBoughtPistol[/url]
[url]http://wiki.garrysmod.com/page/ENTITY/Use[/url]
[QUOTE=Fruitwesp;52152284][url]http://corefiles.darkrp.eu/[/url][/QUOTE]
I hate how that autoplays, makes me jump out of my chair every time I open the website.
The suggested method above should work, but this might be a bit more reliable. Not tested, but I think it should work. (It really depends if defineChatCommand allows you to overwrite pre-existing commands)
lua/autorun/server/sv_whatever.lua:
[code]
local function BuyPistol(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
if not GAMEMODE.Config.enablebuypistol then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("disabled", "/buy", ""))
return ""
end
if GAMEMODE.Config.noguns then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("disabled", "/buy", ""))
return ""
end
local shipment = DarkRP.getShipmentByName(args)
if not shipment or not shipment.separate then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("unavailable", DarkRP.getPhrase("weapon_")))
return ""
end
local canbuy, suppress, message, price = hook.Call("canBuyPistol", DarkRP.hooks, ply, shipment)
if not canbuy then
message = message or DarkRP.getPhrase("incorrect_job", "/buy")
if not suppress then DarkRP.notify(ply, 1, 4, message) end
return ""
end
local cost = price or shipment.getPrice and shipment.getPrice(ply, shipment.pricesep) or shipment.pricesep or 0
ply:Give(shipment.entity)
if shipment.onBought then
shipment.onBought(ply, shipment, weapon)
end
hook.Call("playerBoughtPistol", nil, ply, shipment, weapon, cost)
if IsValid(weapon) then
ply:addMoney(-cost)
DarkRP.notify(ply, 0, 4, DarkRP.getPhrase("you_bought", args, DarkRP.formatMoney(cost)))
else
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("unable", "/buy", args))
end
return ""
end
DarkRP.defineChatCommand("buy", BuyPistol, 0.2)
[/code]
[QUOTE=Fruitwesp;52152284][url]http://corefiles.darkrp.eu/[/url]
On-topic: Try this. Untested.
[lua]
hook.Add( "playerBoughtPistol", "autopickup", function( ply, weaponTable, weaponEntity, price )
weaponEntity:Use( ply )
end )
[/lua]
References:
[url]http://wiki.darkrp.com/index.php/Hooks/Server/playerBoughtPistol[/url]
[url]http://wiki.garrysmod.com/page/ENTITY/Use[/url][/QUOTE]
i tried this and it did not work, maybe i placed the file wrong? i put it in autorun server
[QUOTE=Fruitwesp;52152284][url]http://corefiles.darkrp.eu/[/url]
On-topic: Try this. Untested.
[lua]
hook.Add( "playerBoughtPistol", "autopickup", function( ply, weaponTable, weaponEntity, price )
weaponEntity:Use( ply )
end )
[/lua]
References:
[url]http://wiki.darkrp.com/index.php/Hooks/Server/playerBoughtPistol[/url]
[url]http://wiki.garrysmod.com/page/ENTITY/Use[/url][/QUOTE]
Why not just remove the weapon entity and give the player the weapon (-class)?
[QUOTE=Slowboi;52154058]The suggested method above should work, but this might be a bit more reliable. Not tested, but I think it should work. (It really depends if defineChatCommand allows you to overwrite pre-existing commands)
lua/autorun/server/sv_whatever.lua:
[code]
local function BuyPistol(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
if not GAMEMODE.Config.enablebuypistol then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("disabled", "/buy", ""))
return ""
end
if GAMEMODE.Config.noguns then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("disabled", "/buy", ""))
return ""
end
local shipment = DarkRP.getShipmentByName(args)
if not shipment or not shipment.separate then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("unavailable", DarkRP.getPhrase("weapon_")))
return ""
end
local canbuy, suppress, message, price = hook.Call("canBuyPistol", DarkRP.hooks, ply, shipment)
if not canbuy then
message = message or DarkRP.getPhrase("incorrect_job", "/buy")
if not suppress then DarkRP.notify(ply, 1, 4, message) end
return ""
end
local cost = price or shipment.getPrice and shipment.getPrice(ply, shipment.pricesep) or shipment.pricesep or 0
ply:Give(shipment.entity)
if shipment.onBought then
shipment.onBought(ply, shipment, weapon)
end
hook.Call("playerBoughtPistol", nil, ply, shipment, weapon, cost)
if IsValid(weapon) then
ply:addMoney(-cost)
DarkRP.notify(ply, 0, 4, DarkRP.getPhrase("you_bought", args, DarkRP.formatMoney(cost)))
else
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("unable", "/buy", args))
end
return ""
end
DarkRP.defineChatCommand("buy", BuyPistol, 0.2)
[/code][/QUOTE]
i tried this aswell dont seem to work lol hmmmmmmm
so when the gun dealer buys guns from tab menu it just spawns it on the floor same as every other job that has a weap they can buy
Sorry, you need to Log In to post a reply to this thread.