Right so I'm trying to spawn an ammo box in front of the player and when I try to run the command the console tells me it has invalid characters. I did some looking around and figured out any command that started with ent_ ran inside of RunConsoleCommand() is blocked. Is this true and if so is there away around it? Thanks.
Post the entire command you tried to run. Some commands are restricted for security purposes.
You gotta create the entities with ents.Create serverside function. ent_create would only work with sv_cheats 1 anyway.
[QUOTE=Robotboy655;47875797]You gotta create the entities with ents.Create serverside function. ent_create would only work with sv_cheats 1 anyway.[/QUOTE]
Shit I forgot about sv_cheats. Well, how could I give the player ammo in a way how you would give someone health via server side?
I know how to set the networking up, but for the life of me I cant figure out how to assign ammo to the player.
I've tried that before and this is what I get
[CODE]
[ERROR] addons/darkrp - ammo vendor/lua/entities/ammo_npc/init.lua:39: attempt to index global 'Player' (a function value)
1. func - addons/darkrp - ammo vendor/lua/entities/ammo_npc/init.lua:39
2. unknown - lua/includes/extensions/net.lua:32
[/CODE]
Code
[CODE]net.Receive( "Give.357Sig", function( bits, ply )
local playerMoney = ply:getDarkRPVar( "money" )
if playerMoney >= 100 then
ply:addMoney( -100 )
Player:GiveAmmo( 30, "fas2_ammo_556x45", false )
else
--Nothing
end
end)[/CODE]
I don't understand what it means by function value?
Player is a global function Player in your case. You have to actually get a player object ( like the ply argument in your callback function )
So what your saying is to do
ply:GiveAmmo( 30, "fas2_ammo_556x45", false ) ?
If so that's what I tried before and nothing happens. No errors, no crashes, just nothing.
As Robotboy says:
[code]net.Receive( "Give.357Sig", function( bits, ply )
if(ply:canAfford(100)) then
ply:addMoney( -100 )
ply:GiveAmmo( 30, "fas2_ammo_556x45", false )
end
end)[/code]
Edit: ninjad. Does it take the money away but not give the ammo or does nothing happen at all? If nothing happens at all then you're probably sending the net message incorrectly
No, it takes the money. I just don't get any ammo.
[editline]4th June 2015[/editline]
I'm a freaking idiot. I was using the ent name of the ammo and not the ammo itself. For example item_ammo_357 is 357. Jesus Christ, what a waste of a post. Sorry everyone, thanks for the help.
[editline]4th June 2015[/editline]
I was using fas2_ammo_556x45 but it has to be 5.56x45MM. For anyone using FA:S.
Sorry, you need to Log In to post a reply to this thread.