A tetris minigame simulation. (Because i'm bored)
This plugin ports the well known russian Tetris game to SourceMod. Players are able to play Tetris in a menu and compare their highscores.
Just type !tetris (sm_tetris) in chat and start a new game. Try to clear as many lines as possible and reach a high score until your blocks reach the top.
Controls are intuitive. Just use your walking keys. Left and right move the current tetrimino in that direction, up rotates it clockwise and down speeds up the falling.
Players may also press jump (spacebar) or use (e) to hard drop the tetrimino and let it fall to the floor immediately.
There are some stats on the right, showing your current level, number of cleared lines, score and the next tetrimino.
Scoring is based on this tables. T-Spins aren't rewarded though..
There are 3 difficulties differing in the tetrimino fallingspeed. Each difficulty has it's own TOP 5 highscore list, which may be accessed from the !tetris main menu. Next to the global top5, players are able to check their own best scores for each difficulty.
This plugin uses clientprefs to save the sound settings of each player. Each player may individually enable/disable the sound effects or music.
sm_tetris_disableharddrop - Disable hard dropping the tetrimino instantly to the floor with the spacebar? (Default: 0)
sm_tetris_disablesounds - Disable all tetris sounds? (Default: 0)
sm_tetris_onlydead - Player has to be dead to play tetris? (Default: 0)
sm_tetris_disableinfopanel - Disable showing stats like score/cleared bars in a (Key)Hint panel while playing? (Default: 0)
Upload the tetris.smx into you sourcemod/plugins folder.
If you want to enable the tetris sounds, extract the tetris_sounds.zip into your modfolder and upload it on your fastdl, if you use one. If you don't want sounds set sm_tetris_disablesounds to 1!
Edit your databases.cfg and add a "tetris" section to save the highscores in. If you don't add one, it uses the "storage-local" sqlite database as a fallback.
If you use mysql, execute this query to create the table:
CREATE TABLE `tetris_players` ( `steamid` VARCHAR( 64 ) NOT NULL, `name` VARCHAR( 64 ) NOT NULL, `score_easy` INT NOT NULL DEFAULT '0', `score_normal` INT NOT NULL DEFAULT '0', `score_hard` INT NOT NULL DEFAULT '0', PRIMARY KEY ( `steamid` ) ) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
Change the map to load the plugin and configure it in the newly generated config file in cfg/sourcemod/plugin.tetris.cfg.
Some users' machines are unable to display UTF-8 chars ingame, so they won't be able to play this game as they will only see messy squares all over. It's clientside and i don't know how to fix that ;)
The tetris.inc include provides one native to be implemented into ALL afk managers out there!!!1
/** * Check if a player is currently playing tetris. * * @param client Client index. * @return True if the player is currently playing tetris, false otherwise. */ native bool:IsClientInTetrisGame(client);
/** * Called when a player finishes a tetris game. * * @param client The client index of the player playing tetris. * @param iLevel The tetris level the player was in. * @param iLines The number of cleared lines. * @param iScore The end score. * @param bNewHighscore True if this is a new personal highscore of the player. * @noreturn */ forward OnTetrisGameEnd(client, iLevel, iLines, iScore, bool:bNewHighscore);
12-10-11 1.0: Initial release
Fix CS:GO support (infopanel, sound, exitbutton)
Show "Back" option in game menu
Add sm_tetris_onlydead convar
Add sm_tetris_disableinfopanel convar
Add OnTetrisGameEnd forward
Use "storage-local" instead of "default" database config if "tetris" section is missing
Fix error spam when database connection isn't available yet on player connect
awsome job again dude.
anyway, u could use create table if not exist sentence for automated table create processing.
I usually don't allow the mysql users used by sourcemod plugins to create tables. Just foreseeing error spamming if that query constantly fails due to that. It's a onetimer either, so i prefer it that way. The sqlite table creation indeed uses CREATE TABLE IF NOT EXISTS