1. Post #1
    Gold Member
    The Anarchist's Avatar
    August 2011
    78 Posts
    I am trying to implement ShopMod on my server, but this part of the mod (the part that has to do with money) is coded for CityRP - which obviously isn't compatible with DarkRP. Where can I find the equivalents of the code, such as "ply.cityrp._Money" for DarkRP? I'm not asking you to spoon-feed me or anything, but a few pointers in the right direction would be awesome!

    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, amt )
    
    	if( cityrp != nil ) then
    		return ply.cityrp._Money >= amt
    	elseif( CUR != nil and GlobalInts != nil and CfgVars != nil ) then
    		return ply:CanAfford( amt )
    	elseif( GMRP != nil ) then
    		return ply:HasMoney( amt )
    	elseif( DevM_Function_Think ) then
    		return ply:GetNWInt( "ZD_Money" ) >= amt
    	else
    		return true
    	end
    
    end
    hook.Add( "ShopModHasMoney", "smmoneycheck", shopmod_hasmoney )
    
    //Do money
    local function shopmod_domoney( ply, amt )
    
    	if( cityrp != nil ) then
    		cityrp.player.giveMoney( ply, amt )
    	elseif( CUR != nil and GlobalInts != nil and CfgVars != nil ) then
    		ply:AddMoney( amt )
    	elseif( GMRP != nil ) then
    		ply:AddMoney( amt )
    	elseif( DevM_Function_Think ) then
    		ply:SetNWInt( "ZD_Money", ply:GetNWInt( "ZD_Money" ) + amt )
    	end
    
    end
    hook.Add( "ShopModDoMoney", "smdomoney", shopmod_domoney )
    
    local function shopmod_inv( ply, entity, amt )
    
    	if( cityrp != nil ) then
    		cityrp.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:SetOwner( ply )
    	ent:Spawn()
    	ent:Activate()
    
    end
    hook.Add( "ShopModDoSpawn", "smspawn", shopmod_spawn )
    Thanks in advance.

  2. Post #2
    Gold Member
    Saint Devil's Avatar
    January 2009
    227 Posts
    Where can I find the equivalents of the code, such as "ply.cityrp._Money" for DarkRP?
    In the DarkRP code.

    Edited:

    I did some work for you:
    p:AddMoney(amount) -- Adds money to DRP wallet
    p:CanAfford(amount) -- Returns true or false if player can afford the given 
    p.DarkRPVars.money -- The direct value of the players wallet. DO NOT EDIT THIS AS IT WILL NOT SYNC CLIENTSIDE.
    
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Lua Helper Lua Helper x 1 (list)

  3. Post #3
    Gold Member
    The Anarchist's Avatar
    August 2011
    78 Posts
    Fixed, but it won't spawn vehicles. Any ideas?

    Code:
    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:SetOwner( ply )
    	ent:Spawn()
    	ent:Activate()
    
    end

  4. Post #4
    Gold Member
    The Anarchist's Avatar
    August 2011
    78 Posts
    Have to bump this, I really need vehicles.

  5. Post #5
    shadowndacorner's Avatar
    May 2011
    195 Posts
    Is shopmod.shops a valid table? And are there any spawns set up in it?

    And where is the hook being called from?