Custom Check for adding entites in DarkRP

Hello,

I am currently writing a leveling system which will work with Dark RP, I looked at the DarkRP wiki about adding Donator Entities http://code.google.com/p/darkrp/wiki/donatorentities to give me a clue how to deny access to a Entity or Job if you are under a certain level. Would it be possible to add another check for example: [LUA]AddEntity(“Money printer”, “money_printer”, “models/props_c17/consolebox01a.mdl”, 1000, 2, “/buymoneyprinter”, nil, UserGroupCheck, LevelUntillYouCanBuy).[/LUA] would I be somehow able to add LevelUntillYouCanBuy as another check?

Thanks!

Add another function like:

[lua]
function MoneyPrinterCheck( ply )

return ( UserGroupCheck( ply ) and LevelUntillYouCanBuy( ply ) ) -- could use or depending on how you want it to work

end
[/lua]

Then just do

[lua]
AddEntity(“Money printer”, “money_printer”, “models/props_c17/consolebox01a.mdl”, 1000, 2, “/buymoneyprinter”, nil, MoneyPrinterCheck )
[/lua]

Where would this be added?

also it would be in a NWInt [LUA]local current = tonumber(self:GetNWInt( “levela” ))
return current[/LUA]

You could put it anywhere in shared.lua, or you could even compact it into the AddEntity code:

[lua]AddEntity(“Money printer”, “money_printer”, “models/props_c17/consolebox01a.mdl”, 1000, 2, “/buymoneyprinter”, nil, function( ply ) return( UserGroupCheck( ply ) and LevelUntillYouCanBuy( ply ) ) end )[/lua]

I believe I have tried that before and it just says you can not buy this item or something like that how would I change that to some thing like you need to be level to buy this item?

Post the code for the functions UserGroupCheck and LevelUntillYouCanBuy.

This is took from the wiki on: http://code.google.com/p/darkrp/

The eleventh argument of AddCustomShipment and the eighth argument of AddEntity can hold a custom function that defines whether a player can buy it or not.

The setup is the same as the donator job thing. Here’s a few examples though:
[LUA]
AddEntity(“Money printer”, “money_printer”, “models/props_c17/consolebox01a.mdl”, 1000, 2, “/buymoneyprinter”, nil, function(ply) return ply:GetNWString(“usergroup”) == “Donator” end)
[/LUA][LUA]
AddCustomShipment(“AK47”, “models/weapons/w_rif_ak47.mdl”, “weapon_ak472”, 2450, 10, false, nil, false, {TEAM_GUN}, nil, function(ply) return ply:GetNWString(“usergroup”) == “Donator” end)
[/LUA] could I add another argument at the end of that. For example:
[LUA]
AddCustomShipment(“AK47”, “models/weapons/w_rif_ak47.mdl”, “weapon_ak472”, 2450, 10, false, nil, false, {TEAM_GUN}, nil, function(ply) return ply:GetNWString(“usergroup”) == “Donator” end, 15)
[/LUA]

No you can’t add another argument like that.

I think you could but it would require a lot of coding I am looking at the revision changes now for that update I might be able to figure it out from there.