Can anyone tell me whats wrong with this script..??
6 replies, posted
Hope this is the right Section!
My question was.. Can anyone tell me whats wrong with this Script..??
DarkRP changed the way it handles money, this script is designed to be a npc shop script, its a hook lua file for my server, this is my current edit, right now it says "not enough money!!!!"
because it doesnt understand the way darkrp handles money
thanks!!
[CODE]//ShopMod Hooks
//You MUST edit the functions below to work with your RP. Some RP gamemodes are already set up here.
//RP gamemodes currently set up:
//CityRP
//Has Money
local function shopmod_hasmoney( ply, amount )
return ply:CanAfford(amount)
end
hook.Add( "ShopModHasMoney", "smmoneycheck", shopmod_hasmoney )
//Do money
local function shopmod_domoney( ply, amount )
ply:AddMoney(amount)
end
hook.Add( "ShopModDoMoney", "smdomoney", shopmod_domoney )
local function shopmod_inv( ply, entity, amount )
ply:Give( entity )
end
hook.Add( "ShopModDoInventory", "sminv", shopmod_inv )
local function shopmod_spawn( ply, entity, amount, id )
local vec = shopmod.shops[id]["spawns"][math.random( 1, #shopmod.shops[id]["spawns"] )]
local ent = ents.Create( entity )
ent:SetPos( vec )
ent:Spawn()
ent:Activate()
end
hook.Add( "ShopModDoSpawn", "smspawn", shopmod_spawn )[/CODE]
or even this
[CODE] //ShopMod Hooks
//You MUST edit the functions below to work with your RP. Some RP gamemodes are already set up here.
//RP gamemodes currently set up:
//darkrp
//Has Money
local function shopmod_hasmoney( ply, amt )
if( darkrp != nil ) then
return ply.darkrp._Money >= amt
elseif( RPArrestedPlayers != nil && DB != nil && RPVersion != nil ) then
return ply:CanAfford( amt )
elseif( GMRP != nil ) then
return ply:HasMoney( amt )
else
return true
end
end
hook.Add( "ShopModHasMoney", "smmoneycheck", shopmod_hasmoney )
//Do money
local function shopmod_domoney( ply, amt )
if( darkrp != nil ) then
darkrp.player.giveMoney( ply, amt )
elseif( RPArrestedPlayers != nil && DB != nil && RPVersion != nil ) then
ply:AddMoney( amt )
elseif( GMRP != nil ) then
ply:AddMoney( amt )
end
end
hook.Add( "ShopModDoMoney", "smdomoney", shopmod_domoney )
local function shopmod_inv( ply, entity, amt )
if( darkrp != nil ) then
darkrp.inventory.update( ply, entity, 1 )
elseif( GMRP != nil ) then
GMRP.AddToInventory( ply, entity )
else
ply:Give( entity )
end
end
hook.Add( "ShopModDoInventory", "sminv", shopmod_inv )
local function shopmod_spawn( ply, entity, amt, id )
local vec = shopmod.shops[id]["spawns"][math.random( 1, #shopmod.shops[id]["spawns"] )]
local ent = ents.Create( entity )
ent:SetPos( vec )
ent:Spawn()
ent:Activate()
end
hook.Add( "ShopModDoSpawn", "smspawn", shopmod_spawn )
[/CODE]
Why so many hooks? You shouldn't do custom hooks if you don't know how they work.
first one I edited from an edit (makes no sense)
second one was the original mod creators attempt at making it darkrp compadible.. the only thing is.. he didnt do a very good job.. the first one above with either amt or amount ( ) used to work as I hear, so we could just work off of the first one, although darkrp might have changed the way it handles money, any ideas..??
plObj.DarkRPvars.money, iirc.
[QUOTE=BL00DB4TH;35289570]plObj.DarkRPvars.money, iirc.[/QUOTE]
wait.. what..??
could you edit my code and show me..??
I know little about the DarkRP gamemode...
[QUOTE=makermod1;35291250]wait.. what..??
could you edit my code and show me..??
I know little about the DarkRP gamemode...[/QUOTE]
You're not going to learn a damn thing by having people spoonfeed you. Fuck about with the code, post errors, and ask what they mean.
I assume you don't know much about Lua period, much less DarkRP. That means that you're pretty much going to have to learn how not to script, and in doing that you'll learn how to script.
[QUOTE=makermod1;35287750]Hope this is the right Section!
My question was.. Can anyone tell me whats wrong with this Script..??
DarkRP changed the way it handles money, this script is designed to be a npc shop script, its a hook lua file for my server, this is my current edit, right now it says "not enough money!!!!"
because it doesnt understand the way darkrp handles money
thanks!!
[CODE]*code*
[/CODE][/QUOTE]
It appears you ripped this from GmodRP. Copying and pasting something from one script and adding it to another doesn't mean it will work perfectly. From what I can tell, there are even functions in there that are not defined in DarkRP such as "GMRP.AddToInventory". It seems you are either going to have to rewrite this yourself (with the help of us here at facepunch, of course), or post in the requests section and hope someone whips it into shape for you. I highly suggest you learn lua instead of plugging/playing, but it's entirely your choice. Best of luck to you.
Sorry, you need to Log In to post a reply to this thread.