All pastes #520064 Raw Edit

123

public lua v1 · immutable
#520064 ·published 2007-05-29 20:56 UTC
rendered paste body
sql.Query("CREATE TABLE IF NOT EXISTS [prefered-model] ( [UniqueID] INTEGER NOT NULL PRIMARY KEY, [Model] TEXT DEFAULT \'"..defaultmodel.."\' NOT NULL );" --this will create the table so that we can store shitlocal meta = FindMetaTable("Player")function meta:StoreModel( model )	local uid = self:UniqueID()	local model = sql.SQLStr( model ) -- sql.SQLStr makes a string safe to be put into a database(escapes backslashes mostly)		local q = sql.QueryValue( "SELECT [Model] FROM [prefered-model] WHERE [UniqueID] = "..uid.." LIMIT 1;" ) --This is how we will test if the player has already been submitted before		if q then		sql.Query("UPDATE [prefered-model] SET [Model] = \'" .. model .. "\' WHERE [UniqueID] = " .. uid .. " LIMIT 1;" ) -- The player has been submitted before, we are jsut updating them	else		sql.Query("INSERT INTO [prefered-model] ( [UniqueID], [Model] ) VALUES ( "..uid..", \'"..model.."\' );") -- Here we insert into the database	end	endfunction meta:GetPrefModel( )	model = sql.QueryValue("SELECT [Model] FROM [prefered-model] WHERE [UniqueID] = "..self:UniqueID().." LIMIT 1;" )		return modelend