搜索
查看: 1956|回复: 0

[AMXX 带源码] bet.amxx

[复制链接]
发表于 2010-5-3 08:25:24 | 显示全部楼层 |阅读模式 来自 中国–江苏–苏州
Bet
v2.2
by Filip Vili?i? (Vilicic)



Notes to plugin approver:

Plugin still under development.
Please put as author: Filip Vilicic.
Thanks.

The story:

I made this plugin about 9 months ago and it had a lot of bugs. Then 3 months ago I worked again on it and fixed a lot of bugs and upgraded whole plugin. Then I used it on one server and after a few suggestions fixed (hopefully) all bugs. I made 15-20 plugins, but this is first one I made publicly available. Others are either small helpful plugins that could not be generalized and published or have bugs and I am to lazy to get rid of them. Anyway, I hope you like the plugin. Cheers.

Short description:

Player can bet which team will win. After successful placing of a bet, player will loose money (amount of a bet), and at and of the round (if player placed bet for the winning team) he will get deserved money. The amount player will get is determined by odds system. There are two odds systems available:

New (How to set-up) (What is the formula? :))
Calculation is based on number of alive players, their stats and time left in current round. Player stats is made of three components:
Frags
Deaths
Health
Old (How to set-up)
Calculation is based only on number of alive players
Installation:
Text file goes in "addons\amxmodx\data\lang\" folder
The sma file must be compiled locally/online and the output .amxx file will go in "addons\amxmodx\plugins\" folder
Add "bet.amxx" line in "addons\amxmodx\configs\plugins.ini"
Usage:
Simply follow installation instructions. If you would like to customize plugin or use advanced commands read further.

Cvar list:

bet_oddssystem <0|1> (def. 1) - Determinates what odds calculating system to use, new or old one. Comparison.
To set-up new odds system:

bet_oddssystem 1
To set-up old odds system:

bet_oddssystem 0
bet_chatenabled <0|1> (def. 1) - Will clients interaction with bet plugin be public (printed in chat)
bet_mustbedead <0|1> (def. 1) - If set to zero player can bet when alive, if set to one player can't bet when alive.
bet_adsenabled <0|1> (def. 1) - If set to one player will see help on how to bet after each death, if set to zero he will not see it.
Command list:

amx_advertisebet - Advertises plugin to all players immediately. Takes no parameters. Needs ADMIN_CVAR access.
say /advertisebet - Advertises plugin to all players immediately. Takes no parameters. Needs ADMIN_CVAR access.
Detailed description:

For a player to place a successful bet he/she must satisfy these conditions:

Bet is properly formatted
Both teams are alive (at least one team member is alive)
Player placing bet is dead
Player placing bet has more (or same) amount of money that is provided
Player that dies gets this message (sort of advertising the script):
"^x01 ^x03 **Type ^x04 ^"bet^" ^x03 for help with betting! Type ^x04 ^"odds^" ^x03 for chances to win! **"

Proper full bet is:

bet TEAM AMOUNT

Examples:

bet ct 500
bet t all
bet t half
Plugin responses to following bet's are:

bet -> Use ^"bet team amount^" to bet. Examples: ^"bet t all^" or ^"bet ct 250^" or ^"bet t half^"
bet t OR bet ct -> Amount not provided. Please type ^"bet^" to get further help.
bet lol OR bet lol 100 -> Invalid team name ^"%s^". Please use t or ct to target a team.
bet ct lol -> Invalid amount ^"%s^". Please use all, half or any other numeric amount.
bet ct 15000 (while having 5000) -> You have $ %d, you can not bet $ %d.
If player is alive -> You can only bet if you are dead.
If one of the teams is dead -> You can not bet when one of the teams is dead!
If player has no money -> You don't have money to bet with!
If bet is already placed -> You have already placed your bet!
bet t all -> Bet placed. Odds are %d to %d You stand to win $ %d on top of your $ %d bet.
odds -> Odds are %d to %d. OR Odds are %d to %d if you bet for terrorists.
At the end of the round player receives one of the following messages:

You won $ %d.
You lost your $ %d bet.
For curious ones, the correct formula for new odds system is (currently):

All players are "worth" between 0.5 and 2.0.
Only alive players worth is calculated
Each player with negative frags has starting worth of 0.0 (eg. real worth will be 0.5)
Each player with frags+deaths <= 4 has starting worth of 1.0 else his starting worth will be = frags / (deaths + 1)
Starting worth is changed based on players health and we get the real worth of player.
[Health]; [Real worth]
1 - 10; Starting worth * 0.25
11 - 20; Starting worth * 0.35
21 - 40; Starting worth * 0.5
41 - 60; Starting worth * 0.75
61 - 80; Starting worth
81 - 100;Starting worth * 1.25
If real worth is less than 0.5 it is changed to 0.5 and if real worth is larger than 2.0 it is changed to 2.0
All Real worth's are summed up together to get Simple odds (float)
From simple odds we get real odds (the ones that are used).
If round is ended or freezetime is active real odds are simple odds else formula tests if map is de_ and if bomb is planted. Based on that we have three cases:
Map is not de_
[Time remaining]; [Real odds]
0 - 5; CT odds * 5
6 - 10; CT odds * 2
11 - 15; CT odds * 1.5
16 - 30; CT odds * 1.15
31+; No change
Map is de_ and c4 is planted:
[Time until explosion]; [Real odds]
0 - 5; T odds * 2
6 - 10; T odds * 1.5
11 - 25; No change
26+; CT odds * 1.2
Map is de_ and c4 is not planted:
[Time remaining]; [Real odds]
0 - 5; CT odds * 5
6 - 10; CT odds * 2
11 - 15; CT odds * 1.5
16 - 30; CT odds * 1.15
31+; No change
Real odds are then used as odds.
Formula is still to be improved. Suggestions are welcome.

Mods supported:

Counter-Strike 1.6
To do:

Translate to other languages.
Add few more things to new odds system.

Contributors:

Special thanks to: Nextra (for invaluable help, code contribution and ideas), ConnorMcLeod (for providing and giving full access to his source code for determining time left (time until explosion) in round)
Bug reporters: DarkGod, Nextra, ditmesteam

Translators: crazyeffect (nl), Nextra (de), rdrag (ru), i.898.i (sk, cz), peaces (tc), eforie (ro)
Contributors: aarons, YamiKaitou

Appeal:
If any of you know language that is not supported please translate it.

List of missing translations:

Turkish (tr)
French (fr)
Swedish (sv)
Danish (da)
Poland (pl)
Spanish (es)
Brazil Portuguese (bp)
Finish (fi)
l33t (ls)
Bulgarian (bg)
Hungarian (hu)
Lithuania (lt)
Macedonian (mk)
Change log:

v2.2

New odds system upgraded. It now checks if c4 is planted and time before c4 explosion or if c4 is not planted time before round end (Thanks to: ConnorMcLeod)
Code reorganized
v2.1

Odds system improved (odds are divided by their greatest common divisor)
Added CsTeams type specifier when declaring team variable
Improved code performance when calculating odds (Code first checks if user is in spectators before calculating).
v2.0

Added new odds system
Added cvar for choosing odds system (bet_oddssystem)
Old change log:
Code:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表