All pastes #756145 Raw Edit

Anonymous

public lua v1 · immutable
#756145 ·published 2007-10-31 06:15 UTC
rendered paste body
function attachPerk(plyr, payload)		--The following is the formula needed for an item and its possible attachemnts	if (plyr == nil) then		g_arena:message('function attachPerk(plyr, payload) has been passed and invalid player object')		return false	end	if (payload == '') then		g_arena:message('function attachPerk(plyr, payload) has been passed an invalid payload')		return false	end		local perkTable = { }	perkTable['Shotgun'] = {'Laser Sight', 'Extended Clip'}	perkTable['Rifle'] = {'Scope', 'Laser Sight'}		--The payload must be ?attach Shotgun-Laser Sight:Extended Clip	local weapon = string.sub(payload, 1, string.find('-') - 1)	local attachment = string.sub(payload, string.find(':') + 1, string.len(payload))	local payload = string.sub(payload, 1, string.find(':') -1)	if (perkTable[weapon] == nil) then		plyr:message('This is not a valid weapon')		return false	end		local validAttachment = false	for i=1, table.getn(perkTable[weapon]) do		if (perkTable[weapon][i] == attachment) then			validAttachment = true		end	end		if (validAttachment == false) then		plyr:message('This is not a valid attachment.')		return false	end		plyr:modify_inventory(payload, -1)	plyr:modify_inventory(weapon..'-'..attachment)	plyr:message('Correctly attached '..attachment)end