AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Sample of how NOT to code for approval: XpMod (https://forums.alliedmods.net/showthread.php?t=107698)

micke1101 10-29-2009 08:14

Sample of how NOT to code for approval: XpMod
 
5 Attachment(s)
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

DarkSkif 10-29-2009 10:57

Re: XpMod
 
Nice work.

Javivi 10-29-2009 10:59

Re: XpMod
 
GJ =D

Exolent[jNr] 10-29-2009 11:03

Re: XpMod
 
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.

micke1101 10-29-2009 11:15

Re: XpMod
 
Ok fixed.

Thanks for the constructive critic

Exolent[jNr] 10-29-2009 11:19

Re: XpMod
 
Quote:

Originally Posted by micke1101 (Post 975216)
Thanks for the constructive critic

I really don't know where to begin with how to make your code better.

Javivi 10-29-2009 11:23

Re: XpMod
 
Exolent, it's simple, post your xpmod ;P

micke1101 10-29-2009 11:24

Re: XpMod
 
Quote:

Originally Posted by Exolent[jNr] (Post 975223)
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 :P
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

<VeCo> 10-29-2009 11:26

Re: XpMod
 
PHP Code:

new PlayerXp[33];
new 
PlayerLevels[33][7];
new 
PlayerPercent[33][7];
new 
PlayerHp[33];
... 

:arrow:
PHP Code:

new PlayerXp[33], PlayerLevels[33][7], PlayerPercent[33][7], PlayerHp[33]... 

It looks much better :|

micke1101 10-29-2009 11:29

Re: XpMod
 
Ok then lets do it that way


All times are GMT -4. The time now is 02:28.

Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.