What am I doing wrong?

I just need some help debugging. The error I’m getting is "Expected function arguments near ‘==’



ITEM.Name = 'Pulse Rifle'
ITEM.Price = 32000
ITEM.Model = 'models/weapons/v_irifle.mdl'
ITEM.WeaponClass = 'weapon_ttt_ar2'
ITEM.SingleUse = false
ITEM.AllowedUserGroups = { "goatking", "2d", "raincoat", "hegemon", "the_dealer", "donator", "recentdonor", "sponsor", "trollking", "mostdope", "jr", "testmod",}


function ITEM:CanPlayerBuy(ply)
    if ply:Alive == 'true' then

    	return false

    else
	return true

end

function ITEM:OnEquip(ply)
	ply:StripWeapon( "weapon_ttt_ar2" )
	ply:StripWeapon( "weapon_ttt_hl2_shotgun" )
	ply:StripWeapon( "weapon_ttt_galil" )	
	ply:StripWeapon( "weapon_ttt_smg" )
	ply:StripWeapon( "weapon_zm_mac10" )	
	ply:StripWeapon( "weapon_ttt_famas" )	
	
	ply:Give(self.WeaponClass)
	
	ply:SelectWeapon(self.WeaponClass)
	
end


ply:Alive

you used the : operator which made it try to run the ply.Alive function
you can reference the function itself as an object with ply.Alive

if you want to run the function you must include the parenthesized arguments, even if there are none

change it to ply:Alive()

There’s a unnecessary comma at the end of your allowedusergroups table.

ITEM.AllowedUserGroups = { “goatking”, “2d”, “raincoat”, “hegemon”, “the_dealer”, “donator”, “recentdonor”, “sponsor”, “trollking”, “mostdope”, “jr”, “testmod”}

And why did you make a semi-colon for ply.Alive?



ITEM.Name = 'Pulse Rifle'
ITEM.Price = 32000
ITEM.Model = 'models/weapons/v_irifle.mdl'
ITEM.WeaponClass = 'weapon_ttt_ar2'
ITEM.SingleUse = false
ITEM.AllowedUserGroups = { "goatking", "2d", "raincoat", "hegemon", "the_dealer", "donator", "recentdonor", "sponsor", "trollking", "mostdope", "jr", "testmod",}


function ITEM:CanPlayerBuy(ply)
    if ply.Alive() == 'true' then

    	return false
    end

    else
	return true
    end

end

function ITEM:OnEquip(ply)
	ply:StripWeapon( "weapon_ttt_ar2" )
	ply:StripWeapon( "weapon_ttt_hl2_shotgun" )
	ply:StripWeapon( "weapon_ttt_galil" )	
	ply:StripWeapon( "weapon_ttt_smg" )
	ply:StripWeapon( "weapon_zm_mac10" )	
	ply:StripWeapon( "weapon_ttt_famas" )	
	
	ply:Give(self.WeaponClass)
	
	ply:SelectWeapon(self.WeaponClass)
	
end


returns these errors

[ERROR] addons/pointshop-master/lua/items/loadout/ar2.lua:15: ‘end’ expected (to close ‘function’ at line 9) near ‘else’

  1. unknown - addons/pointshop-master/lua/items/loadout/ar2.lua:0

[POINTSHOP] Item missing name: loadout/ar2.lua

[ERROR] addons/pointshop-master/lua/items/loadout/coltdep.lua:16: ‘<eof>’ expected near ‘end’

  1. unknown - addons/pointshop-master/lua/items/loadout/coltdep.lua:0

Do you want to make it so only dead can purchase?

When using else, you don’t close the statement.
For example:



if a == b then
      c = 1
else
      c = 0
end


Also, when seperating values in tables using commas, you don’t put a comma for the last one, for example:
Instead of this



Blahs = { "1", "2", "3", }


Should be this:



Blahs = { "1", "2", "3" } -- note there is no comma at the end of the last variable.




ITEM.Name = 'Pulse Rifle'
ITEM.Price = 32000
ITEM.Model = 'models/weapons/v_irifle.mdl'
ITEM.WeaponClass = 'weapon_ttt_ar2'
ITEM.SingleUse = false
ITEM.AllowedUserGroups = { "goatking", "2d", "raincoat", "hegemon", "the_dealer", "donator", "recentdonor", "sponsor", "trollking", "mostdope", "jr", "testmod"}




function ITEM:CanPlayerBuy(ply)
    if ply.Alive() == 'true' then
        return false
    else
    return true
    end


end


function ITEM:OnEquip(ply)
    ply:StripWeapon( "weapon_ttt_ar2" )
    ply:StripWeapon( "weapon_ttt_hl2_shotgun" )
    ply:StripWeapon( "weapon_ttt_galil" )    
    ply:StripWeapon( "weapon_ttt_smg" )
    ply:StripWeapon( "weapon_zm_mac10" )    
    ply:StripWeapon( "weapon_ttt_famas" )    
    
    ply:Give(self.WeaponClass)
    
    ply:SelectWeapon(self.WeaponClass)
    
end


i have an idea for a gamemode feature that has a load of weapons in it.
Tell me what you think.



corporations and randomly generated shop items, Stock
Different Corporations make different items, have different specialities, and are completely up to the player to learn which does what function best. There's a best for machineguns, cannons, missiles, energy types, etc.

The shop will generate a limited number of available items for purchase that day.
On one day, the cannon you want may be available, but it may not the second day.

You may buy stock in companies. Stocks change around daily and are based on a PLAYER-ONLY selling part. You may put up stock for sale, and another player must buy it for it to be sold. The only way to get stock in companies is to buy it with a weapon for the median price + 10% of the stock, Or to own 3 or more of that company's weapons. To reduce sporadicism, The stock will not be random. The most expensive stock will lie in the company that has weapons owned by the most people (The more guns that exist on players that are of that company, the higher the stock)
companies will have sales on random weapons of their brand, which will also affect other stocks. The sales will be from 1 to 50% off, and the sales will take points off of corporations that are not on sale by increments of how much exactly is taken off of the original prices.
Different energy types will also have their own stocks.
There is a limited number of stock, based on how many people own their items.


I’d love to add this, it’d give players something interesting to do besides fly around and shoot the shit out of people. Economy is an interesting thing to have.
I remember something similar being present in an old PS2 game named SLAI, but it was singleplayer only and the stock prices were affected by which day you where at on the calendar.

Yes, Well equip, hopefully. We’ll see.

[editline]1st September 2013[/editline]

I think you should delete this before an admin sees you posting out of topic. The New Topic button is in the top left of the forum page.

[editline]1st September 2013[/editline]

That wasn’t causing any errors, I’ve got that line of code in about 20 other files. Thanks though, you were super helpful.

The error stems from the ITEM:CanPlayerBuy function, the rest of it is correct (syntax wise) from what I can see.

[lua]
function ITEM:CanPlayerBuy( ply )
return !ply:Alive();
end
[/lua]

Ah well that’s much nicer isn’t it?

Except it doesn’t work either

oh shit wrong thread.