Raised This Month: $12 Target: $400
 3% 

Sample of how NOT to code for approval: XpMod


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 10-29-2009 , 08:14   Sample of how NOT to code for approval: XpMod
Reply With Quote #1

Description: This is a little mod i got requested to make so here it is, the idea is that you should use it with HNS (HideNSeek) when a player types /xp he gets up a menu where he can buy health, he grenade, flash (1 and 2), smoke and respawn possibility level.
For example if i buy level 1 he grenade i get 15% chanse to get a he grenade every round.
Admins with kick can take or give xp and admins with rcon can reset all xp's and levels.

Cvars:
Code:
//Xp you get when killing with any weapon except knife
xpmod_killxp 45
//Xp you get when killing with knife
xpmod_knifekillxp 35
//Xp you get when killing with knife in the head
xpmod_knifekillxphs 45
//Xp you lose if you do suicide
xpmod_xpsuicide 5
//xp your team get for winning the round
xpmod_xpwin 10
//xp you get for surviving the round
xpmod_xpsurvive 8
//Xp the different lvls cost (health)
xpmod_xphealth1 400
xpmod_xphealth2 600
xpmod_xphealth3 800
xpmod_xphealth4 1000
xpmod_xphealth5 1200
//hp you get at the different lvls
xpmod_hphealth1 10
xpmod_hphealth2 15
xpmod_hphealth3 20
xpmod_hphealth4 25
xpmod_hphealth5 30
//Xp the different lvls cost (he)
xpmod_xphe1 200
xpmod_xphe2 400
xpmod_xphe3 600
xpmod_xphe4 800
xpmod_xphe5 1000
//Xp the different lvls cost (1st flash)
xpmod_xpflash11 200
xpmod_xpflash12 400
xpmod_xpflash13 800
xpmod_xpflash14 1200
//Xp the different lvls cost (2nd flash)
xpmod_xpflash21 200
xpmod_xpflash22 400
xpmod_xpflash23 800
xpmod_xpflash24 1200
//Xp the different lvls cost (1st smoke)
xpmod_xpsmoke1 400
xpmod_xpsmoke2 600
xpmod_xpsmoke3 800
xpmod_xpsmoke4 1200
//Xp the different lvls cost (respawn)
xpmod_xprespawn1 10000
xpmod_xprespawn2 12000
xpmod_xprespawn3 14000
//Percents chanse that you get the item at that level(health)
xpmod_pthealth1 100
xpmod_pthealth2 100
xpmod_pthealth3 100
xpmod_pthealth4 100
xpmod_pthealth5 100
//Percents chanse that you get the item at that level(he)
xpmod_pthe1 15
xpmod_pthe2 23
xpmod_pthe3 37
xpmod_pthe4 46
xpmod_pthe5 63
//Percents chanse that you get the item at that level(1st flash)
xpmod_ptflash11 25
xpmod_ptflash12 50
xpmod_ptflash13 65
xpmod_ptflash14 85
//Percents chanse that you get the item at that level(2nd flash)
xpmod_ptflash21 25
xpmod_ptflash22 50
xpmod_ptflash23 65
xpmod_ptflash24 85
//Percents chanse that you get the item at that level(smoke)
xpmod_ptsmoke1 20
xpmod_ptsmoke2 45
xpmod_ptsmoke3 55
xpmod_ptsmoke4 70
//Percents chanse that you get the item at that level(respawn)
xpmod_ptrespawn1 15
xpmod_ptrespawn2 22
xpmod_ptrespawn3 33
//If player hasnt played on server hell get this much xp
xpmod_starterxp 400
//Save players xp
xpmod_savexp 1
//Since this is designed for hns well need a delay before we give the items in the beginning
xpmod_rounddelay 12.0
//Do you wish to hide the money hud
xpmod_hidemoneyhud 1
//Do you want a counter on the screen that shows the players their xp (position money hud so its recommended to remove that first)
xpmod_xponscreen 1
Commands:
- Players
- /xp - brings up the xp menu
- Admin with kick
- amx_takexp <target> <amount> - (Console) takes a players xp
- amx_givexp <target> <amount> - (Console) gives a player xp
- Admin with rcon
- /clearxpmod - resets all players xp, levels in the server and the database

Credits:
Redfalcon - Beta tester and requester and cvars are based on what he wanted.
And also thanks to all translators: here

Notes:
Requieres local compiling and download of fvault in includes
xpmod.txt goes in data/lang
Attached Files
File Type: inc fvault.inc (12.8 KB, 866 views)
File Type: sma Get Plugin or Get Source (xpmod.sma - 5402 views - 34.1 KB)
File Type: txt xpmod.txt (11.5 KB, 924 views)

Last edited by micke1101; 10-31-2009 at 15:17. Reason: stickied, changed title
micke1101 is offline
DarkSkif
Member
Join Date: Oct 2009
Location: Russia
Old 10-29-2009 , 10:57   Re: XpMod
Reply With Quote #2

Nice work.
DarkSkif is offline
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 10-29-2009 , 10:59   Re: XpMod
Reply With Quote #3

GJ =D
__________________

Last edited by Javivi; 10-29-2009 at 11:19.
Javivi is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-29-2009 , 11:03   Re: XpMod
Reply With Quote #4

You cannot post amxx files, even if it requires local compiling.
Notify the people downloading it to locally compile it until a moderator/approver uploads the compiled version for you.

Also, this code is an eyesore.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 10-29-2009 , 11:15   Re: XpMod
Reply With Quote #5

Ok fixed.

Thanks for the constructive critic
micke1101 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-29-2009 , 11:19   Re: XpMod
Reply With Quote #6

Quote:
Originally Posted by micke1101 View Post
Thanks for the constructive critic
I really don't know where to begin with how to make your code better.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 10-29-2009 , 11:23   Re: XpMod
Reply With Quote #7

Exolent, it's simple, post your xpmod ;P
__________________
Javivi is offline
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 10-29-2009 , 11:24   Re: XpMod
Reply With Quote #8

Quote:
Originally Posted by Exolent[jNr] View Post
I really don't know where to begin with how to make your code better.
Probably find a better way on load with players percent and such maybe
Make a function for the 4 lines that prints the messages in a own function those are some ive been thinking of and i meant that it was constructive out of a pros view
micke1101 is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 10-29-2009 , 11:26   Re: XpMod
Reply With Quote #9

PHP Code:
new PlayerXp[33];
new 
PlayerLevels[33][7];
new 
PlayerPercent[33][7];
new 
PlayerHp[33];
... 

PHP Code:
new PlayerXp[33], PlayerLevels[33][7], PlayerPercent[33][7], PlayerHp[33]... 
It looks much better
__________________
<VeCo> is offline
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 10-29-2009 , 11:29   Re: XpMod
Reply With Quote #10

Ok then lets do it that way
micke1101 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode