Approved Levels-XP System

Plug-ins compatibility with Zombie Escape 1.x only!


BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#131

Post by BandiT » 2 years ago

i try this plugin and again i have this error,,,,

======= Backtrace: =========
/usr/lib/libc.so.6(+0x7968d)[0xf761d68d]
/usr/lib/libc.so.6(fclose+0x164)[0xf760a764]
/usr/lib/libnss_files.so.2(_nss_files_gethostbyname4_r+0x2a2)[0xf0995262]
/usr/lib/libc.so.6(+0xe1c92)[0xf7685c92]
/usr/lib/libc.so.6(getaddrinfo+0x12d)[0xf768720d]
cstrike/addons/amxmodx/modules/mysql_amxx_i386.so(mysql_real_connect+0xc80)[0xf1d28f90]
cstrike/addons/amxmodx/modules/mysql_amxx_i386.so(+0x246fc)[0xf1d236fc]
[0x9ab9380]
======= Memory map: ========
08048000-08049000 r--p 00000000 103:02 12059195 /opt/hlds_real3/hlds_linux
08049000-08051000 r-xp 00001000 103:02 12059195 /opt/hlds_real3/hlds_linux
08051000-08056000 r--p 00009000 103:02 12059195 /opt/hlds_real3/hlds_linux
08056000-08057000 r--p 0000d000 103:02 12059195 /opt/hlds_real3/hlds_linux
08057000-08058000 rw-p 0000e000 103:02 12059195 /opt/hlds_real3/hlds_linux
08058000-0805a000 rw-p 00000000 00:00 0
085c6000-09c5d000 rw-p 00000000 00:00 0 [heap]
ed300000-ed331000 rw-p 00000000 00:00 0
ed331000-ed400000 ---p 00000000 00:00 0
ed4fc000-ed4fd000 ---p 00000000 00:00 0
ed4fd000-edcfd000 rwxp 00000000 00:00 0
edcfd000-edcfe000 ---p 00000000 00:00 0
edcfe000-eddfe000 rwxp 00000000 00:00 0
eddfe000-eddff000 ---p 00000000 00:00 0
eddff000-edeff000 rwxp 00000000 00:00 0
edeff000-edf00000 ---p 00000000 00:00 0
edf00000-ee000000 rwxp 00000000 00:00 0
ee000000-ee021000 rw-p 00000000 00:00 0
ee021000-ee100000 ---p 00000000 00:00 0
ee1ff000-ee200000 ---p 00000000 00:00 0
ee200000-ee300000 rwxp 00000000 00:00 0
ee300000-ee321000 rw-p 00000000 00:00 0
ee321000-ee400000 ---p 00000000 00:00 0
ee4fb000-ee4fc000 ---p 00000000 00:00 0
ee4fc000-ee5fc000 rwxp 00000000 00:00 0
ee600000-ee6be000 rw-p 00000000 00:00 0
ee6be000-ee700000 ---p 00000000 00:00 0
ee700000-ee721000 rw-p 00000000 00:00 0
ee721000-ee800000 ---p 00000000 00:00 0
ee800000-ee821000 rw-p 00000000 00:00 0
ee821000-ee900000 ---p 00000000 00:00 0
eea00000-eeae2000 rw-p 00000000 00:00 0
eeae2000-eeb00000 ---p 00000000 00:00 0
eebff000-eec00000 ---p 00000000 00:00 0
eec00000-eed00000 rwxp 00000000 00:00 0
eed00000-eed79000 rw-p 00000000 00:00 0
eed79000-eee00000 ---p 00000000 00:00 0
eeefe000-eeeff000 ---p 00000000 00:00 0
eeeff000-eefff000 rwxp 00000000 00:00 0
eefff000-ef000000 ---p 00000000 00:00 0
ef000000-ef100000 rwxp 00000000 00:00 0
ef100000-ef122000 rw-p 00000000 00:00 0
ef122000-ef200000 ---p 00000000 00:00 0
ef296000-ef3f1000 r-xp 00000000 103:02 12059190 /opt/hlds_real3/libSDL2-2.0.so.0.10.0
ef3f1000-ef3f2000 ---p 0015b000 103:02 12059190 /opt/hlds_real3/libSDL2-2.0.so.0.10.0
ef3f2000-ef3f5000 r--p 0015b000 103:02 12059190 /opt/hlds_real3/libSDL2-2.0.so.0.10.0
ef3f5000-ef3f9000 rw-p 0015e000 103:02 12059190 /opt/hlds_real3/libSDL2-2.0.so.0.10.0
ef3f9000-ef3fe000 rw-p 00000000 00:00 0
ef3fe000-ef3ff000 ---p 00000000 00:00 0
ef3ff000-ef4ff000 rwxp 00000000 00:00 0
ef4ff000-ef500000 ---p 00000000 00:00 0
ef500000-ef600000 rwxp 00000000 00:00 0
ef600000-ef621000 rw-p 00000000 00:00 0
ef621000-ef700000 ---p 00000000 00:00 0
ef7fe000-ef7ff000 ---p 00000000 00:00 0
ef7ff000-ef8ff000 rwxp 00000000 00:00 0
ef8ff000-ef900000 ---p 00000000 00:00 0
ef900000-efa00000 rwxp 00000000 00:00 0
efa00000-efa21000 rw-p 00000000 00:00 0
efa21000-efb00000 ---p 00000000 00:00 0
efbff000-efc00000 ---p 00000000 00:00 0
efc00000-efd00000 rwxp 00000000 00:00 0
efd00000-efdda000 rw-p 00000000 00:00 0
efdda000-efe00000 ---p 00000000 00:00 0
efe03000-efe04000 ---p 00000000 00:00 0
efe04000-eff04000 rwxp 00000000 00:00 0
f0000000-f00b7000 rw-p 00000000 00:00 0
f00b7000-f0100000 ---p 00000000 00:00 0
f0101000-f0104000 rw-p 00000000 00:00 0
f0104000-f0105000 ---p 00000000 00:00 0
f0105000-f0971000 rwxp 00000000 00:00 0
f0971000-f0986000 r-xp 00000000 103:02 267744 /usr/lib/libresolv-2.17.so
f0986000-f0987000 r--p 00014000 103:02 267744 /usr/lib/libresolv-2.17.so
f0987000-f0988000 rw-p 00015000 103:02 267744 /usr/lib/libresolv-2.17.so
f0988000-f098a000 rw-p 00000000 00:00 0
f098a000-f098f000 r-xp 00000000 103:02 267732 /usr/lib/libnss_dns-2.17.so
f098f000-f0990000 r--p 00004000 103:02 267732 /usr/lib/libnss_dns-2.17.so
f0990000-f0991000 rw-p 00005000 103:02 267732 /usr/lib/libnss_dns-2.17.so
f0991000-f099c000 r-xp 00000000 103:02 267734 /usr/lib/libnss_files-2.17.so
f099c000-f099d000 r--p 0000a000 103:02 267734 /usr/lib/libnss_files-2.17.so
f099d000-f099e000 rw-p 0000b000 103:02 267734 /usr/lib/libnss_files-2.17.so
f099e000-f09a4000 rw-p 00000000 00:00 0
f09a4000-f09ce000 rwxp 00000000 00:00 0
f09ce000-f09cf000 ---p 00000000 00:00 0
f09cf000-f17ea000 rwxp 00000000 00:00 0
f17ea000-f184d000 rwxp 00000000 00:00 0
f184d000-f1b98000 r--s 00000000 103:02 17173010 /home/vuser101/cstrike/addons/amxmodx/data/GeoLite2-Country.mmdb
f1b98000-f1b9f000 rwxp 00000000 00:00 0
f1b9f000-f1ba9000 r-xp 00000000 103:02 17172717 /home/vuser101/cstrike/addons/amxmodx/modules/geoip_amxx_i386.so
f1ba9000-f1baa000 rw-p 0000a000 103:02 17172717 /home/vuser101/cstrike/addons/amxmodx/modules/geoip_amxx_i386.so
f1baa000-f1bb4000 rwxp 00000000 00:00 0
f1bb4000-f1bc8000 r-xp 00000000 103:02 17172715 /home/vuser101/cstrike/addons/amxmodx/modules/engine_amxx_i386.so
f1bc8000-f1bc9000 rw-p 00013000 103:02 17172715 /home/vuser101/cstrike/addons/amxmodx/modules/engine_amxx_i386.so
f1bc9000-f1bca000 rw-p 00000000 00:00 0
f1bca000-f1be8000 rwxp 00000000 00:00 0
f1be8000-f1bf0000 r-xp 00000000 103:02 17172710 /home/vuser101/cstrike/addons/amxmodx/modules/fun_amxx_i386.so
f1bf0000-f1bf1000 rw-p 00007000 103:02 17172710 /home/vuser101/cstrike/addons/amxmodx/modules/fun_amxx_i386.so
f1bf1000-f1bf2000 rw-p 00000000 00:00 0
f1bf2000-f1bfb000 rwxp 00000000 00:00 0
f1bfb000-f1c14000 r-xp 00000000 103:02 17172706 /home/vuser101/cstrike/addons/amxmodx/modules/cstrike_amxx_i386.so
f1c14000-f1c15000 rw-p 00019000 103:02 17172706 /home/vuser101/cstrike/addons/amxmodx/modules/cstrike_amxx_i386.so
f1c15000-f1c16000 rw-p 00000000 00:00 0
f1c16000-f1c19000 rwxp 00000000 00:00 0
f1c19000-f1cf9000 rw-p 00000000 00:00 0
f1cf9000-f1cff000 rwxp 00000000 00:00 0
f1cff000-f1fbc000 r-xp 00000000 103:02 17172714 /home/vuser101/cstrike/addons/amxmodx/modules/mysql_amxx_i386.so
f1fbc000-f2034000 rw-p 002bd000 103:02 17172714 /home/vuser101/cstrike/addons/amxmodx/modules/mysql_amxx_i386.so
f2034000-f203c000 rw-p 00000000 00:00 0
f203c000-f203d000 rwxp 00000000 00:00 0
f203d000-f2040000 r-xp 00000000 103:02 17172720 /home/vuser101/cstrike/addons/amxmodx/modules/sockets_amxx_i386.so
f2040000-f2041000 rw-p 00002000 103:02 17172720 /home/vuser101/cstrike/addons/amxmodx/modules/sockets_amxx_i386.so
f2041000-f2047000 r-xp 00000000 103:02 17172707 /home/vuser101/cstrike/addons/amxmodx/modules/nvault_amxx_i386.so
f2047000-f2048000 rw-p 00006000 103:02 17172707 /home/vuser101/cstrike/addons/amxmodx/modules/nvault_amxx_i386.so
f2048000-f20b3000 r-xp 00000000 103:02 17172719 /home/vuser101/cstrike/addons/amxmodx/modules/regex_amxx_i386.so
f20b3000-f20b4000 rw-p 0006a000 103:02 17172719 /home/vuser101/cstrike/addons/amxmodx/modules/regex_amxx_i386.so
f20b4000-f20b8000 rw-p 00000000 00:00 0
f20b8000-f20c1000 rwxp 00000000 00:00 0
f20c1000-f2108000 r-xp 00000000 103:02 17172713 /home/vuser101/cstrike/addons/amxmodx/modules/fakemeta_amxx_i386.so
f2108000-f2109000 rw-p 00046000 103:02 17172713 /home/vuser101/cstrike/addons/amxmodx/modules/fakemeta_amxx_i386.so
f2109000-f210c000 rw-p 00000000 00:00 0
f210c000-f2112000 rwxp 00000000 00:00 0
f2112000-f2117000 rwxp 00000000 00:00 0
f2117000-f2122000 r-xp 00000000 103:02 17172708 /home/vuser101/cstrike/addons/amxmodx/modules/csx_amxx_i386.so
f2122000-f2123000 rw-p 0000b000 103:02 17172708 /home/vuser101/cstrike/addons/amxmodx/modules/csx_amxx_i386.so
f2123000-f218b000 rw-p 00000000 00:00 0
f218b000-f2193000 rwxp 00000000 00:00 0
f2193000-f21e9000 r-xp 00000000 103:02 17172716 /home/vuser101/cstrike/addons/amxmodx/modules/hamsandwich_amxx_i386.so
f21e9000-f21ed000 rw-p 00055000 103:02 17172716 /home/vuser101/cstrike/addons/amxmodx/modules/hamsandwich_amxx_i386.so
f21ed000-f21ef000 rw-p 00000000 00:00 0
f21ef000-f2212000 rwxp 00000000 00:00 0
f2212000-f2228000 r-xp 00000000 103:02 22679403 /home/vuser101/cstrike/addons/reauthcheck/reauthcheck_mm_i386.so
f2228000-f2229000 rw-p 00016000 103:02 22679403 /home/vuser101/cstrike/addons/reauthcheck/reauthcheck_mm_i386.so
f2229000-f223b000 rw-p 00000000 00:00 0
f223b000-f2272000 r-xp 00000000 103:02 22679120 /home/vuser101/cstrike/addons/reunion/reunion_mm_i386.so
f2272000-f2273000 r--p 00036000 103:02 22679120 /home/vuser101/cstrike/addons/reunion/reunion_mm_i386.so
f2273000-f2275000 rw-p 00037000 103:02 22679120 /home/vuser101/cstrike/addons/reunion/reunion_mm_i386.so
f2275000-f2276000 rw-p 00000000 00:00 0
f2276000-f2308000 r-xp 00000000 103:02 17172688 /home/vuser101/cstrike/addons/unprecacher/unprecacher_i386.so
f2308000-f2309000 ---p 00092000 103:02 17172688 /home/vuser101/cstrike/addons/unprecacher/unprecacher_i386.so
f2309000-f230c000 r--p 00092000 103:02 17172688 /home/vuser101/cstrike/addons/unprecacher/unprecacher_i386.so
f230c000-f230d000 rw-p 00095000 103:02 17172688 /home/vuser101/cstrike/addons/unprecacher/unprecacher_i386.so
f230d000-f230e000 rw-p 00000000 00:00 0
f230e000-f2311000 rwxp 00000000 00:00 0
f2311000-f2377000 r-xp 00000000 103:02 17172705 /home/vuser101/cstrike/addons/amxmodx/modules/reapi_amxx_i386.so
f2377000-f2378000 ---p 00066000 103:02 17172705 /home/vuser101/cstrike/addons/amxmodx/modules/reapi_amxx_i386.so
f2378000-f2379000 r--p 00066000 103:02 17172705 /home/vuser101/cstrike/addons/amxmodx/modules/reapi_amxx_i386.so
f2379000-f237e000 rw-p 00067000 103:02 17172705 /home/vuser101/cstrike/addons/amxmodx/modules/reapi_amxx_i386.so
f237e000-f2387000 rw-p 00000000 00:00 0
f2387000-f23f3000 r-xp 00000000 103:02 17172698 /home/vuser101/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
f23f3000-f2403000 rwxp 0006c000 103:02 17172698 /home/vuser101/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
f2403000-f2537000 r-xp 0007c000 103:02 17172698 /home/vuser101/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
f2537000-f253a000 rw-p 001af000 103:02 17172698 /home/vuser101/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
f253a000-f2573000 rw-p 00000000 00:00 0
f2573000-f2576000 rwxp 00000000 00:00 0
f2576000-f2829000 r-xp 00000000 103:02 17052731 /home/vuser101/cstrike/dlls/cs.so
f2829000-f282a000 r--p 002b2000 103:02 17052731 /home/vuser101/cstrike/dlls/cs.so
f282a000-f2849000 rw-p 002b3000 103:02 17052731 /home/vuser101/cstrike/dlls/cs.so
f2849000-f289d000 rw-p 00000000 00:00 0
f289d000-f2901000 r-xp 00000000 103:02 17172671 /home/vuser101/cstrike/addons/metamod/dlls/metamod_i386.so
f2901000-f2902000 r--p 00063000 103:02 17172671 /home/vuser101/cstrike/addons/metamod/dlls/metamod_i386.so
f2902000-f2905000 rw-p 00064000 103:02 17172671 /home/vuser101/cstrike/addons/metamod/dlls/metamod_i386.so
f2905000-f2908000 rw-p 00000000 00:00 0
f2908000-f2919000 rwxp 00000000 00:00 0
f2919000-f511a000 rw-p 00000000 00:00 0
f511a000-f51b7000 r-xp 00000000 103:02 12059188 /opt/hlds_real3/crashhandler.so
f51b7000-f51b9000 rw-p 0009c000 103:02 12059188 /opt/hlds_real3/crashhandler.so
f51b9000-f51c1000 rw-p 00000000 00:00 0
f51c1000-f6c0b000 r-xp 00000000 103:02 12059191 /opt/hlds_real3/steamclient.so
f6c0b000-f6ca0000 r--p 01a49000 103:02 12059191 /opt/hlds_real3/steamclient.so
f6ca0000-f6cae000 rw-p 01ade000 103:02 12059191 /opt/hlds_real3/steamclient.so
f6cae000-f6d11000 rw-p 00000000 00:00 0
f6d11000-f6d17000 r--p 00000000 103:02 12059200 /opt/hlds_real3/filesystem_stdio.so
f6d17000-f6d25000 r-xp 00006000 103:02 12059200 /opt/hlds_real3/filesystem_stdio.so
f6d25000-f6d2b000 r--p 00014000 103:02 12059200 /opt/hlds_real3/filesystem_stdio.so
f6d2b000-f6d2c000 ---p 0001a000 103:02 12059200 /opt/hlds_real3/filesystem_stdio.so
f6d2c000-f6d2d000 r--p 0001a000 103:02 12059200 /opt/hlds_real3/filesystem_stdio.so
f6d2d000-f6d2e000 rw-p 0001b000 103:02 12059200 /opt/hlds_real3/filesystem_stdio.so
f6d2e000-f6d31000 rw-p 00000000 00:00 0
f6d31000-f6d38000 r-xp 00000000 103:02 267746 /usr/lib/librt-2.17.so
f6d38000-f6d39000 r--p 00006000 103:02 267746 /usr/lib/librt-2.17.so
f6d39000-f6d3a000 rw-p 00007000 103:02 267746 /usr/lib/librt-2.17.so
f6d3a000-f6d51000 r-xp 00000000 103:02 267742 /usr/lib/libpthread-2.17.so
f6d51000-f6d52000 r--p 00016000 103:02 267742 /usr/lib/libpthread-2.17.so
f6d52000-f6d53000 rw-p 00017000 103:02 267742 /usr/lib/libpthread-2.17.so
f6d53000-f6d55000 rw-p 00000000 00:00 0
f6d55000-f6d66000 r-xp 00000000 103:02 12059196 /opt/hlds_real3/libsteam_api.so
f6d66000-f6d67000 rw-p 00010000 103:02 12059196 /opt/hlds_real3/libsteam_api.so
f6d67000-f6d68000 rw-p 00000000 00:00 0
f6d68000-f6da8000 r--p 00000000 103:02 12059659 /opt/hlds_real3/engine_i486.so
f6da8000-f6e5c000 r-xp 00040000 103:02 12059659 /opt/hlds_real3/engine_i486.so
f6e5c000-f6eb1000 r--p 000f4000 103:02 12059659 /opt/hlds_real3/engine_i486.so
f6eb1000-f6eb4000 r--p 00148000 103:02 12059659 /opt/hlds_real3/engine_i486.so
f6eb4000-f6eb9000 rw-p 0014b000 103:02 12059659 /opt/hlds_real3/engine_i486.so
f6eb9000-f7474000 rw-p 00000000 00:00 0
f7474000-f7488000 r-xp 00000000 103:02 12059197 /opt/hlds_real3/libgcc_s.so.1
f7488000-f7489000 rw-p 00013000 103:02 12059197 /opt/hlds_real3/libgcc_s.so.1
f7489000-f74c9000 r-xp 00000000 103:02 267724 /usr/lib/libm-2.17.so
f74c9000-f74ca000 r--p 0003f000 103:02 267724 /usr/lib/libm-2.17.so
f74ca000-f74cb000 rw-p 00040000 103:02 267724 /usr/lib/libm-2.17.so
f74cb000-f74cc000 rw-p 00000000 00:00 0
f74cc000-f7593000 r-xp 00000000 103:02 12059204 /opt/hlds_real3/libstdc++.so.6
f7593000-f7597000 r--p 000c6000 103:02 12059204 /opt/hlds_real3/libstdc++.so.6
f7597000-f7599000 rw-p 000ca000 103:02 12059204 /opt/hlds_real3/libstdc++.so.6
f7599000-f759f000 rw-p 00000000 00:00 0
f759f000-f75a2000 r-xp 00000000 103:02 267722 /usr/lib/libdl-2.17.so
f75a2000-f75a3000 r--p 00002000 103:02 267722 /usr/lib/libdl-2.17.so
f75a3000-f75a4000 rw-p 00003000 103:02 267722 /usr/lib/libdl-2.17.so
f75a4000-f7768000 r-xp 00000000 103:02 267716 /usr/lib/libc-2.17.so
f7768000-f7769000 ---p 001c4000 103:02 267716 /usr/lib/libc-2.17.so
f7769000-f776b000 r--p 001c4000 103:02 267716 /usr/lib/libc-2.17.so
f776b000-f776c000 rw-p 001c6000 103:02 267716 /usr/lib/libc-2.17.so
f776c000-f7770000 rw-p 00000000 00:00 0
f7770000-f7771000 r-xp 00000000 00:00 0 [vdso]
f7771000-f7793000 r-xp 00000000 103:02 262777 /usr/lib/ld-2.17.so
f7793000-f7794000 r--p 00021000 103:02 262777 /usr/lib/ld-2.17.so
f7794000-f7795000 rw-p 00022000 103:02 262777 /usr/lib/ld-2.17.so
ff94d000-ff9a4000 rwxp 00000000 00:00 0 [stack]
ff9a4000-ff9a6000 rw-p 00000000 00:00 0
./hlds_r_101: line 53: 19494 Aborted ${HL} "$@"

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#132

Post by Night Fury » 2 years ago

What the heck is even that?
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#133

Post by BandiT » 2 years ago

I THINK is from my hoost provider, any saving in any data baze from level system plugin is crashing sv and showing me that error, idk wht but i think is form my hoost provider, because i try other plugin level an it-s happening same thing

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#134

Post by Raheem » 2 years ago

[mention]BandiT[/mention], my suggestion is to use VPS or dedicates server to host your servers instead of using game server. The following videos can be the start: https://www.youtube.com/playlist?list=P ... x-qDEC6F86 (https://zppv.boards.net/thread/1697/tut ... cs1-6-host). If you are not familiar with VPS/Dedicated or how to deal with them, then try find better game server hosting.
He who fails to plan is planning to fail

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#135

Post by VicKy » 2 years ago

Please Help Me I dont getting any xp for escape succes
Cvars

//Level
ze_maxlevels_increment 1.1
ze_enable_percentage_style 0
ze_max_xp_first_level 300
ze_zombie_infect 20
ze_escape_success 200.0
ze_enable_dmg 1
ze_required_dmg 5000.0
ze_dmg_award 0
ze_start_xp 50
ze_new_level_zero_xp 0
ze_add_commas_to_xp 1
ze_level_up_effects 1
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#136

Post by karan » 2 years ago

VicKy wrote: 2 years ago Please Help Me I dont getting any xp for escape succes
Cvars

//Level
ze_maxlevels_increment 1.1
ze_enable_percentage_style 0
ze_max_xp_first_level 300
ze_zombie_infect 20
ze_escape_success 200.0
ze_enable_dmg 1
ze_required_dmg 5000.0
ze_dmg_award 0
ze_start_xp 50
ze_new_level_zero_xp 0
ze_add_commas_to_xp 1
ze_level_up_effects 1
change this value ze_escape_success 200.0 to 200
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#137

Post by VicKy » 2 years ago

I did but no work
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#138

Post by VicKy » 2 years ago

i remove on zombieescape.cfg this is plugin
error is dont getting xp escape
  1. #include <zombie_escape>
  2.  
  3. // Defines
  4. #define MAX_LEVEL 101
  5. #define MAX_XP 500000
  6. #define TASK_SHOWHUD 2020
  7. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  8. #define LEVELUP "levelup_ZE/ze_levelup.wav"
  9.  
  10. enum
  11. {
  12.     Host = 0,
  13.     User,
  14.     Pass,
  15.     DB
  16. }
  17.  
  18. // Constants
  19. new const g_szLevelsVault[] = "Levels"
  20. new const g_szRanksVault[] = "Ranks"
  21. new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
  22. new const g_szTable[] =
  23. " \
  24.     ALTER TABLE `test` \
  25.     ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
  26.     ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
  27.     ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
  28. "
  29.  
  30. // Messages
  31. const Float:HUD_SPECT_X = -1.0
  32. const Float:HUD_SPECT_Y = 0.70
  33. const Float:HUD_STATS_X = -1.0
  34. const Float:HUD_STATS_Y = 0.90
  35.  
  36. const HUD_STATS_ZOMBIE_R = 200
  37. const HUD_STATS_ZOMBIE_G = 220
  38. const HUD_STATS_ZOMBIE_B = 0
  39.  
  40. const HUD_STATS_HUMAN_R = 0
  41. const HUD_STATS_HUMAN_G = 200
  42. const HUD_STATS_HUMAN_B = 210
  43.  
  44. const HUD_STATS_SPEC_R = 100
  45. const HUD_STATS_SPEC_G = 100
  46. const HUD_STATS_SPEC_B = 100
  47.  
  48. // Variables
  49. new g_iLevel[33],
  50.     g_iXP[33],
  51.     g_iMaxXP[33],
  52.     Float:g_fDamage[33],
  53.     g_MsgSync,
  54.     g_iLevelsVaultHandle,
  55.     g_iRanksVaultHandle,
  56.     Handle:g_hTuple,
  57.     Fw_LevelUP,
  58.     ForwardReturn
  59.  
  60. // Cvars
  61. new g_pCvarZombieInfect,
  62.     g_pCvarEscapeSuccess,
  63.     g_pCvarEnableDamage,
  64.     g_pCvarRequiredDamage,
  65.     g_pCvarDamageAward,
  66.     g_pCvarStartXP,
  67.     g_pCvarMaxLevelsIncrement,
  68.     g_pCvarMaxXPFirstLevel,
  69.     g_pCvarPercentageStyle,
  70.     g_pCvarStartFromZero,
  71.     g_pCvarAddCommas,
  72.     g_pCvarLevelEffects,
  73.     g_pCvarSaveType,
  74.     g_pCvarDBInfo[4]
  75.  
  76. public plugin_natives()
  77. {
  78.     register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
  79.     register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
  80.     register_native("ze_get_user_level", "native_ze_get_user_level", 1)
  81.     register_native("ze_set_user_level", "native_ze_set_user_level", 1)
  82.     register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
  83.     register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
  84. }
  85.  
  86. public plugin_precache()
  87. {
  88.     precache_sound(LEVELUP)
  89. }
  90.  
  91. public plugin_init()
  92. {
  93.     register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
  94.    
  95.     // Hook Chains
  96.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  97.  
  98.     Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
  99.    
  100.     // Cvars
  101.     g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "30")
  102.     g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "150")
  103.     g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "0")
  104.     g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "50.0")
  105.     g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
  106.     g_pCvarStartXP = register_cvar("ze_start_xp", "50")
  107.     g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.1")
  108.     g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "300")
  109.     g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
  110.     g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
  111.     g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
  112.     g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")
  113.     g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
  114.     g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
  115.     g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
  116.     g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
  117.     g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
  118.    
  119.     // Messages
  120.     g_MsgSync = CreateHudSyncObj()
  121.  
  122.     if (get_pcvar_num(g_pCvarSaveType))
  123.     {
  124.         set_task(0.1, "Delay_MySQL_Init")
  125.     }
  126. }
  127.  
  128. public plugin_end()
  129. {
  130.     if (get_pcvar_num(g_pCvarSaveType))
  131.     {
  132.         if (g_hTuple != Empty_Handle)
  133.         {
  134.             SQL_FreeHandle(g_hTuple)
  135.         }
  136.     }
  137. }
  138.  
  139. public Delay_MySQL_Init()
  140. {
  141.     MySQL_Init()
  142. }
  143.  
  144. public MySQL_Init()
  145. {
  146.     if (!get_pcvar_num(g_pCvarSaveType))
  147.         return
  148.    
  149.     new szHost[64], szUser[32], szPass[32], szDB[128]
  150.    
  151.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  152.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  153.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  154.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  155.    
  156.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  157.    
  158.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  159.     new iErrorCode, szError[512], Handle:hSQLConnection
  160.    
  161.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  162.    
  163.     if (hSQLConnection != Empty_Handle)
  164.     {
  165.         log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
  166.         SQL_FreeHandle(hSQLConnection)
  167.     }
  168.     else
  169.     {
  170.         // Disable plugin
  171.         set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
  172.     }
  173.    
  174.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  175. }
  176.  
  177. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  178. {
  179.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  180. }
  181.  
  182. public client_putinserver(id)
  183. {
  184.     if(is_user_hltv(id) || is_user_bot(id))
  185.         return
  186.    
  187.     // Just 1 second delay
  188.     set_task(1.0, "DelayLoad", id)
  189.  
  190.     // Other tasks
  191.     set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
  192.     set_task(0.1, "Check_MaxXP", id, _, _, "b")
  193. }
  194.  
  195. public DelayLoad(id)
  196. {
  197.     // Load his data
  198.     LoadData(id)
  199. }
  200.  
  201. public client_disconnected(id)
  202. {
  203.     if(is_user_hltv(id) || is_user_bot(id))
  204.         return
  205.        
  206.     remove_task(id+TASK_SHOWHUD)
  207.     remove_task(id)
  208. }
  209.  
  210. public Check_MaxXP(id)
  211. {
  212.     new iCurrentMaxXP = g_iMaxXP[id]
  213.    
  214.     new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  215.    
  216.     for (new i = 1; i <= g_iLevel[id]; i++)
  217.     {
  218.         iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  219.     }
  220.    
  221.     if (iCurrentMaxXP != iMaxXP)
  222.     {
  223.         g_iMaxXP[id] = iMaxXP
  224.     }
  225. }
  226.  
  227. public Show_Hud(taskid)
  228. {  
  229.     new iPlayer = ID_SHOWHUD
  230.    
  231.     if (!is_user_alive(iPlayer))
  232.     {
  233.         iPlayer = pev(iPlayer, pev_iuser2)
  234.        
  235.         if (!is_user_alive(iPlayer))
  236.             return
  237.     }
  238.    
  239.     if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
  240.     {
  241.         if(iPlayer != ID_SHOWHUD)
  242.         {
  243.             set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  244.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
  245.         }
  246.         else if (ze_is_user_zombie(iPlayer))
  247.         {
  248.             set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  249.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  250.         }
  251.         else
  252.         {
  253.             set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  254.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  255.         }
  256.     }
  257.     else
  258.     {
  259.         if(iPlayer != ID_SHOWHUD)
  260.         {
  261.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  262.             {
  263.                 new szSpecXP[15], szSpecMaxXP[15]
  264.                
  265.                 AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
  266.                 AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
  267.                
  268.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  269.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
  270.             }
  271.             else
  272.             {
  273.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  274.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
  275.             }  
  276.         }
  277.         else if (ze_is_user_zombie(iPlayer))
  278.         {
  279.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  280.             {
  281.                 new szZombieXP[15], szZombieMaxXP[15]
  282.                
  283.                 AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
  284.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
  285.                
  286.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  287.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
  288.             }
  289.             else
  290.             {
  291.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  292.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  293.             }
  294.         }
  295.         else
  296.         {
  297.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  298.             {
  299.                 new szHumanXP[15], szHumanMaxXP[15]
  300.                
  301.                 AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
  302.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
  303.                
  304.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  305.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
  306.             }
  307.             else
  308.             {
  309.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  310.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  311.             }
  312.         }
  313.     }
  314. }
  315.  
  316. public ze_roundend(WinTeam)
  317. {
  318.     if (WinTeam == ZE_TEAM_HUMAN)
  319.     {
  320.         for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  321.         {
  322.             if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
  323.                 continue
  324.            
  325.             g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
  326.             SaveData(id)
  327.             Check_User_Level(id)
  328.         }
  329.     }
  330.    
  331.     remove_task(TASK_SHOWHUD)
  332. }
  333.  
  334. public Check_User_Level(id)
  335. {
  336.     if(!is_user_connected(id))
  337.         return
  338.  
  339.     if(g_iXP[id] >= g_iMaxXP[id])
  340.     {
  341.         if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  342.         {
  343.             g_iXP[id] = 0
  344.         }
  345.        
  346.         new szName[32]
  347.         g_iLevel[id] ++
  348.         g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  349.         get_user_name(id, szName, charsmax(szName))
  350.         ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
  351.         ExecuteForward(Fw_LevelUP, ForwardReturn, id)
  352.        
  353.         SaveData(id)
  354.        
  355.         PlaySound(id, LEVELUP)
  356.        
  357.         if (get_pcvar_num(g_pCvarLevelEffects) != 0)
  358.         {
  359.             // Screen Fade
  360.             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
  361.             write_short(4096*2)
  362.             write_short(4096*5)
  363.             write_short(0x0001)
  364.             write_byte(random(256))
  365.             write_byte(random(256))
  366.             write_byte(random(256))
  367.             write_byte(150)
  368.             message_end()
  369.            
  370.             // Screen Shake
  371.             message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
  372.             write_short(255<<14)
  373.             write_short(10<<14)
  374.             write_short(255<<14)
  375.             message_end()
  376.         }
  377.     }
  378. }
  379.  
  380. public ze_user_infected(iVictim, iInfector)
  381. {
  382.     if (iInfector == 0)
  383.         return
  384.    
  385.     g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
  386.     SaveData(iInfector)
  387.     Check_User_Level(iInfector)
  388. }
  389.  
  390. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  391. {
  392.     // Player Damage Himself
  393.     if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
  394.         return HC_CONTINUE
  395.    
  396.     // Same Team?
  397.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  398.         return HC_CONTINUE
  399.    
  400.     // Store Damage For every Player
  401.     g_fDamage[iAttacker] += fDamage
  402.    
  403.     // Damage Calculator Equal or Higher than needed damage
  404.     if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
  405.     {
  406.         // Give Player The Coins
  407.         g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
  408.         SaveData(iAttacker)
  409.         Check_User_Level(iAttacker)
  410.        
  411.         // Rest The Damage Calculator
  412.         g_fDamage[iAttacker] = 0.0
  413.     }
  414.     return HC_CONTINUE
  415. }
  416.  
  417. public SaveData(id)
  418. {
  419.     new szAuthID[35], szName[32]
  420.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  421.     get_user_name(id, szName, charsmax(szName))
  422.    
  423.     // Set Him to max if he Higher than Max Value
  424.     if (g_iLevel[id] > MAX_LEVEL)
  425.     {
  426.         g_iLevel[id] = MAX_LEVEL
  427.     }
  428.    
  429.     if (g_iXP[id] > MAX_XP)
  430.     {
  431.         g_iXP[id] = MAX_XP
  432.     }
  433.  
  434.     if (!get_pcvar_num(g_pCvarSaveType))
  435.     {
  436.         new szData[256]
  437.         formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
  438.        
  439.         // Open the Vaults
  440.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  441.         g_iRanksVaultHandle = nvault_open(g_szRanksVault)
  442.  
  443.         // Saves His Data
  444.         nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
  445.         nvault_set(g_iRanksVaultHandle, szAuthID, szName)
  446.        
  447.         // Close Vaults
  448.         nvault_close(g_iLevelsVaultHandle)
  449.         nvault_close(g_iRanksVaultHandle)
  450.     }
  451.     else
  452.     {
  453.         new szQuery[128]
  454.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
  455.         SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
  456.     }
  457. }
  458.  
  459. public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  460. {
  461.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  462. }
  463.  
  464. public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  465. {
  466.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  467. }
  468.  
  469. public LoadData(id)
  470. {
  471.     new szData[256], szAuthID[35]
  472.    
  473.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  474.    
  475.     if (!get_pcvar_num(g_pCvarSaveType))
  476.     {
  477.         // Useless Variable
  478.         new iTimestamp, iExists
  479.        
  480.         // Open the Vault
  481.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  482.        
  483.         iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  484.        
  485.         // Close Vault
  486.         nvault_close(g_iLevelsVaultHandle)
  487.        
  488.         if (!iExists)
  489.         {
  490.             g_iLevel[id] = 0
  491.             g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
  492.             g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  493.             SaveData(id)
  494.         }
  495.         else
  496.         {
  497.             new iLevel[32], iXP[32], iMaxLevel[32]
  498.             parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
  499.            
  500.             g_iLevel[id] = str_to_num(iLevel)
  501.             g_iXP[id] = str_to_num(iXP)
  502.             g_iMaxXP[id] = str_to_num(iMaxLevel)
  503.         }
  504.     }
  505.     else
  506.     {
  507.         new szQuery[128], szData[5]
  508.         formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)
  509.      
  510.         num_to_str(id, szData, charsmax(szData))
  511.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  512.     }
  513. }
  514.  
  515. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  516. {
  517.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  518.         return
  519.    
  520.     new id = str_to_num(szData)
  521.    
  522.     // No results for this query means this is new player
  523.     if (!SQL_NumResults(hQuery))
  524.     {
  525.         new szSteamId[36], szQuery[128]
  526.         get_user_authid(id, szSteamId, charsmax(szSteamId))
  527.  
  528.         g_iLevel[id] = 0
  529.         g_iXP[id] = 0
  530.         g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  531.         return
  532.     }
  533.  
  534.     g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
  535.     g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
  536.     g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))
  537. }
  538.  
  539. public native_ze_get_user_xp(id)
  540. {
  541.     if(!is_user_connected(id))
  542.     {
  543.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  544.         return false;
  545.     }
  546.    
  547.     return g_iXP[id]
  548. }
  549.  
  550. public native_ze_set_user_xp(id, amount)
  551. {
  552.     if(!is_user_connected(id))
  553.     {
  554.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  555.         return false;
  556.     }
  557.    
  558.     g_iXP[id] = amount
  559.    
  560.     Check_User_Level(id)
  561.     return true;
  562. }
  563.  
  564. public native_ze_get_user_level(id)
  565. {
  566.     if(!is_user_connected(id))
  567.     {
  568.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  569.         return false;
  570.     }
  571.    
  572.     return g_iLevel[id]
  573. }
  574.  
  575. public native_ze_set_user_level(id, amount)
  576. {
  577.     if(!is_user_connected(id))
  578.     {
  579.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  580.         return false;
  581.     }
  582.    
  583.     g_iLevel[id] = amount
  584.    
  585.     if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  586.     {
  587.         g_iXP[id] = 0
  588.     }
  589.    
  590.     return true;
  591. }
  592.  
  593. public native_ze_get_user_max_xp(id)
  594. {
  595.     if(!is_user_connected(id))
  596.     {
  597.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  598.         return false;
  599.     }
  600.    
  601.     return g_iMaxXP[id]
  602. }
  603.  
  604. public native_ze_set_user_max_xp(id, amount)
  605. {
  606.     if(!is_user_connected(id))
  607.     {
  608.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  609.         return false;
  610.     }
  611.    
  612.     g_iMaxXP[id] = amount
  613.     return true;
  614. }
Image

nominal07
Member
Member
Indonesia
Posts: 1
Joined: 2 years ago
Contact:

#139

Post by nominal07 » 2 years ago

Test

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#140

Post by VicKy » 2 years ago

czirimbolo wrote: 4 years ago Ok here is fixed version of level system by Jack and Raheem. Double exp is working too.

Code: Select all

#include <zombie_escape>
 
// Defines
#define MAX_LEVEL 41
#define TASK_SHOWHUD 2020
#define TASK_DOUBLE 1133
#define REPEAT_TIME 60.0
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"
 
enum
{
    Host = 0,
    User,
    Pass,
    DB
}
 
new const g_iMaxLevelsXP[MAX_LEVEL] =
{
    3000, // 1
    3500, // 2
    5000, // 3
    7500, // 4
    11000, // 5
    15000, // 6
    20000, // 7
    25000, // 8
    30000, // 9
    40000, // 10
    50000, // 11
    60000, // 12
    75000, // 13
    90000, // 14
    105000, // 15
    120000, // 16
    140000, // 17
    170000, // 18
    200000, // 19
    275000, // 20
    350000, // 21
    500000, // 22
    1000000, // 23
    1750000, // 24
    3000000, // 25
    6000000, // 26
    10000000, // 27
    15000000, // 28
    20000000, // 29
    30000000, // 30
    40000000, // 31		
    62000000, // 32
    75000000, // 33
    90000000, // 34
    105000000, // 35
    125000000, // 36
    135000000, // 37
    155000000, // 38
    175000000, // 39
    200000000, // 40		
    300000000 // 41
}
 
// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
new const g_szTable[] =
" \
    ALTER TABLE `test` \
    ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
    ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0'; \
"
 
// Messages
const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.70
const Float:HUD_STATS_X = 0.01
const Float:HUD_STATS_Y = 0.22
 
const HUD_STATS_ZOMBIE_R = 200
const HUD_STATS_ZOMBIE_G = 220
const HUD_STATS_ZOMBIE_B = 0
 
const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 200
const HUD_STATS_HUMAN_B = 210
 
const HUD_STATS_SPEC_R = 100
const HUD_STATS_SPEC_G = 100
const HUD_STATS_SPEC_B = 100
 
// Variables
new g_iLevel[33],
    g_iXP[33],
    g_iMaxXP[33],
    Float:g_fDamage[33],
    g_MsgSync,
    g_iLevelsVaultHandle,
    g_iRanksVaultHandle,
    Handle:g_hTuple,
    Fw_LevelUP,
    ForwardReturn,
    bool:g_bIsDoubleHours
 
// Cvars
new g_pCvarZombieInfect,
    g_pCvarEscapeSuccess,
    g_pCvarEnableDamage,
    g_pCvarRequiredDamage,
    g_pCvarDamageAward,
    g_pCvarStartXP,
    g_pCvarPercentageStyle,
    g_pCvarStartFromZero,
    g_pCvarAddCommas,
    g_pCvarLevelEffects,
    g_pCvarSaveType,
    g_pCvarDBInfo[4],
    g_pCvarDoubleXP
 
public plugin_natives()
{
    register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
    register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
    register_native("ze_get_user_level", "native_ze_get_user_level", 1)
    register_native("ze_set_user_level", "native_ze_set_user_level", 1)
    register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
}
 
public plugin_precache()
{
    precache_sound(LEVELUP)
}
 
public plugin_init()
{
    register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
   
    // Hook Chains
    RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
 
    Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
   
    // Cvars
    g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "3")
    g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "5")
    g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
    g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "50.0")
    g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
    g_pCvarStartXP = register_cvar("ze_start_xp", "0")
    g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
    g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
    g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
    g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
    g_pCvarDoubleXP = register_cvar("ze_double_xp", "15-22")
 
    g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
    g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
    g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
    g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
    g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
   
    // Messages
    g_MsgSync = CreateHudSyncObj()
 
    if (get_pcvar_num(g_pCvarSaveType))
    {
        set_task(0.1, "Delay_MySQL_Init")
    }

    DoubleHours()

    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", TASK_DOUBLE, _, _, "b")
    }
}
 
public plugin_end()
{
    if (get_pcvar_num(g_pCvarSaveType))
    {
        if (g_hTuple != Empty_Handle)
        {
            SQL_FreeHandle(g_hTuple)
        }
    }
}
 
public Delay_MySQL_Init()
{
    MySQL_Init()
}
 
public MySQL_Init()
{
    if (!get_pcvar_num(g_pCvarSaveType))
        return
   
    new szHost[64], szUser[32], szPass[32], szDB[128]
   
    get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
    get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
    get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
    get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
   
    g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
   
    // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
    new iErrorCode, szError[512], Handle:hSQLConnection
   
    hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
   
    if (hSQLConnection != Empty_Handle)
    {
        log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
        SQL_FreeHandle(hSQLConnection)
    }
    else
    {
        // Disable plugin
        set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
    }
   
    SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}
 
public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(1.0, "DelayLoad", id)
 
    // Other tasks
    set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
   
    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", id+TASK_DOUBLE, _, _, "b")
    }
}
 
public HappyHours(taskid)
{
    DoubleHours()

    if (!g_bIsDoubleHours)
        remove_task(taskid)
   
    new szDoubleHours[32]
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    set_dhudmessage(0, 255, 0, -1.0, 0.20, 0, 0.0, 10.0)
    show_dhudmessage(0, "DOUBLE XP: %s", szDoubleHours)
}
 
public DelayLoad(id)
{
    // Load his data
    LoadData(id)
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
       
    remove_task(id+TASK_SHOWHUD)
    remove_task(id)
}
 
public Show_Hud(taskid)
{  
    new iPlayer = ID_SHOWHUD
   
    if (!is_user_alive(iPlayer))
    {
        iPlayer = pev(iPlayer, pev_iuser2)
       
        if (!is_user_alive(iPlayer))
            return
    }
   
    if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
    {
        if(iPlayer != ID_SHOWHUD)
        {
            set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
        else
        {
            set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
    }
    else
    {
        if(iPlayer != ID_SHOWHUD)
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szSpecXP[15], szSpecMaxXP[15]
               
                AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
                AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
               
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
            }  
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szZombieXP[15], szZombieMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
               
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
        else
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szHumanXP[15], szHumanMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
               
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
    }
}
 
public ze_roundend(WinTeam)
{
    if (WinTeam == ZE_TEAM_HUMAN)
    {
        new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarEscapeSuccess) * 2) : get_pcvar_num(g_pCvarEscapeSuccess)

        for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
        {
            if (!is_user_alive(id) || ze_is_user_zombie(id))
                continue
           
            Reward(id, (g_iXP[id] + iXP))
        }
    }
   
    remove_task(TASK_SHOWHUD)
}
 
public Check_User_Level(id)
{
    if (!is_user_connected(id))
        return
 
    if (g_iLevel[id] < MAX_LEVEL)
    {
    	new szName[32]

        while (g_iXP[id] > g_iMaxXP[id])
        {
            if (get_pcvar_num(g_pCvarStartFromZero) == 1)
            {
                g_iXP[id] = 0
            }

        	g_iLevel[id]++
        	g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
            get_user_name(id, szName, charsmax(szName))
            ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
            ExecuteForward(Fw_LevelUP, ForwardReturn, id)
            SaveData(id)
            PlaySound(id, LEVELUP)
           
            if (get_pcvar_num(g_pCvarLevelEffects) != 0)
            {
                // Screen Fade
                message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
                write_short(4096*2)
                write_short(4096*5)
                write_short(0x0001)
                write_byte(random(256))
                write_byte(random(256))
                write_byte(random(256))
                write_byte(150)
                message_end()
               
                // Screen Shake
                message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
                write_short(255<<14)
                write_short(10<<14)
                write_short(255<<14)
                message_end()
            }
        }
    }
}
 
public ze_user_infected(iVictim, iInfector)
{
    if (iInfector == 0)
        return
 
    new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarZombieInfect) * 2) : get_pcvar_num(g_pCvarZombieInfect)
    Reward(iInfector, (g_iXP[iInfector] + iXP))
}
 
public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
    // Player Damage Himself
    if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
        return HC_CONTINUE
   
    // Same Team?
    if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
        return HC_CONTINUE
   
    // Store Damage For every Player
    g_fDamage[iAttacker] += fDamage
   
    // Damage Calculator Equal or Higher than needed damage
    if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
    {
        // Player did damage that a multiplication of the cvar? Increase coins by this factor
        new iMultiplier = floatround(g_fDamage[iAttacker] / get_pcvar_float(g_pCvarRequiredDamage))
        new iXP = ((g_bIsDoubleHours ? (get_pcvar_num(g_pCvarDamageAward) * 2) : get_pcvar_num(g_pCvarDamageAward)) * iMultiplier)
        Reward(iAttacker, (g_iXP[iAttacker] + iXP))
       
        // Rest The Damage Calculator
        g_fDamage[iAttacker] = 0.0
    }
    return HC_CONTINUE
}
 
public Reward(id, XP)
{
    if ((g_iLevel[id] + 1) < MAX_LEVEL)
    {
        g_iXP[id] = XP
        Check_User_Level(id)
    }
    else
    {
    	if ((g_iXP[id] + XP) >= g_iMaxLevelsXP[MAX_LEVEL - 1])
        {
            g_iXP[id] = g_iMaxXP[id] = g_iMaxLevelsXP[MAX_LEVEL - 1]
        }
    }
    SaveData(id)
}
 
public SaveData(id)
{
    new szAuthID[35], szName[32]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
    get_user_name(id, szName, charsmax(szName))
 
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256]
        formatex(szData , charsmax(szData), "%i %i", g_iLevel[id], g_iXP[id])
       
        // Open the Vaults
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
        g_iRanksVaultHandle = nvault_open(g_szRanksVault)
 
        // Saves His Data
        nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
        nvault_set(g_iRanksVaultHandle, szAuthID, szName)
       
        // Close Vaults
        nvault_close(g_iLevelsVaultHandle)
        nvault_close(g_iRanksVaultHandle)
    }
    else
    {
        new szQuery[128]
        formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], szAuthID)
        SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
    }
}
 
public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public LoadData(id)
{
    new szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256], iTimestamp, iExists
       
        // Open the Vault
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
       
        iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
       
        // Close Vault
        nvault_close(g_iLevelsVaultHandle)
       
        if (!iExists)
        {
            g_iLevel[id] = 0
            g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
            SaveData(id)
        }
        else
        {
            new iLevel[32], iXP[32]
            parse(szData, iLevel, 31, iXP, 31)
           
            g_iLevel[id] = str_to_num(iLevel)
            g_iXP[id] = str_to_num(iXP)
        }
 
        g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
    }
    else
    {
        new szQuery[128], szData[5]
        formatex(szQuery, charsmax(szQuery), "SELECT * FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
   
        num_to_str(id, szData, charsmax(szData))
        SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
    }
}
 
public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
{
    if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
        return
   
    new id = str_to_num(szData)
   
    // No results for this query means this is new player
    if (!SQL_NumResults(hQuery))
    {
        g_iLevel[id] = 0
        g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
    }
    else
    {
        g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
        g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
    }
 
    g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
}
 
public native_ze_get_user_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iXP[id]
}
 
public native_ze_set_user_xp(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
    
    DoubleHours()
    new addedXP = (amount - g_iXP[id])
    new iXP = g_bIsDoubleHours ? (addedXP * 2) : addedXP
    Reward(id, g_iXP[id] + iXP)
    return true
}
 
public native_ze_get_user_level(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iLevel[id]
}
 
public native_ze_set_user_level(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    if (amount > MAX_LEVEL)
    {
        log_error(AMX_ERR_NATIVE, "Level must be less than or equal to MAX_LEVEL (%d)", MAX_LEVEL)
        return false
    }
 
    g_iLevel[id] = amount
   
    if (get_pcvar_num(g_pCvarStartFromZero) == 1)
    {
        g_iXP[id] = 0
    }
    SaveData(id)
   
    return true
}
 
public native_ze_get_user_max_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    return g_iMaxXP[id]
}
 
stock DoubleHours()
{
    new szTime[3], szDoubleHours[32], szDoubleHours_Start[32], szDoubleHours_End[32]
    get_time("%H", szTime, charsmax(szTime))
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    for (new ch = 0; ch <= charsmax(szDoubleHours); ch++)
    {
        if (szDoubleHours[ch] == '-')
            szDoubleHours[ch] = ' '
    }
   
    parse(szDoubleHours, szDoubleHours_Start, charsmax(szDoubleHours_Start), szDoubleHours_End, charsmax(szDoubleHours_End))
   
    new iTime, iDoubleHourStart, iDoubleHourEnd
   
    iTime = str_to_num(szTime)
    iDoubleHourStart = str_to_num(szDoubleHours_Start)
    iDoubleHourEnd = str_to_num(szDoubleHours_End)
   
    if (iDoubleHourEnd > iTime >= iDoubleHourStart)
    {
        g_bIsDoubleHours = true
    }
    else
    {
        g_bIsDoubleHours = false
    }
}
@karan PLease Help I am not getiing xp while escape but i getting xp on damage i dont know why!!
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#141

Post by karan » 2 years ago

VicKy wrote: 2 years ago
czirimbolo wrote: 4 years ago Ok here is fixed version of level system by Jack and Raheem. Double exp is working too.

Code: Select all

#include <zombie_escape>
 
// Defines
#define MAX_LEVEL 41
#define TASK_SHOWHUD 2020
#define TASK_DOUBLE 1133
#define REPEAT_TIME 60.0
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"
 
enum
{
    Host = 0,
    User,
    Pass,
    DB
}
 
new const g_iMaxLevelsXP[MAX_LEVEL] =
{
    3000, // 1
    3500, // 2
    5000, // 3
    7500, // 4
    11000, // 5
    15000, // 6
    20000, // 7
    25000, // 8
    30000, // 9
    40000, // 10
    50000, // 11
    60000, // 12
    75000, // 13
    90000, // 14
    105000, // 15
    120000, // 16
    140000, // 17
    170000, // 18
    200000, // 19
    275000, // 20
    350000, // 21
    500000, // 22
    1000000, // 23
    1750000, // 24
    3000000, // 25
    6000000, // 26
    10000000, // 27
    15000000, // 28
    20000000, // 29
    30000000, // 30
    40000000, // 31		
    62000000, // 32
    75000000, // 33
    90000000, // 34
    105000000, // 35
    125000000, // 36
    135000000, // 37
    155000000, // 38
    175000000, // 39
    200000000, // 40		
    300000000 // 41
}
 
// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
new const g_szTable[] =
" \
    ALTER TABLE `test` \
    ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
    ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0'; \
"
 
// Messages
const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.70
const Float:HUD_STATS_X = 0.01
const Float:HUD_STATS_Y = 0.22
 
const HUD_STATS_ZOMBIE_R = 200
const HUD_STATS_ZOMBIE_G = 220
const HUD_STATS_ZOMBIE_B = 0
 
const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 200
const HUD_STATS_HUMAN_B = 210
 
const HUD_STATS_SPEC_R = 100
const HUD_STATS_SPEC_G = 100
const HUD_STATS_SPEC_B = 100
 
// Variables
new g_iLevel[33],
    g_iXP[33],
    g_iMaxXP[33],
    Float:g_fDamage[33],
    g_MsgSync,
    g_iLevelsVaultHandle,
    g_iRanksVaultHandle,
    Handle:g_hTuple,
    Fw_LevelUP,
    ForwardReturn,
    bool:g_bIsDoubleHours
 
// Cvars
new g_pCvarZombieInfect,
    g_pCvarEscapeSuccess,
    g_pCvarEnableDamage,
    g_pCvarRequiredDamage,
    g_pCvarDamageAward,
    g_pCvarStartXP,
    g_pCvarPercentageStyle,
    g_pCvarStartFromZero,
    g_pCvarAddCommas,
    g_pCvarLevelEffects,
    g_pCvarSaveType,
    g_pCvarDBInfo[4],
    g_pCvarDoubleXP
 
public plugin_natives()
{
    register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
    register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
    register_native("ze_get_user_level", "native_ze_get_user_level", 1)
    register_native("ze_set_user_level", "native_ze_set_user_level", 1)
    register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
}
 
public plugin_precache()
{
    precache_sound(LEVELUP)
}
 
public plugin_init()
{
    register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
   
    // Hook Chains
    RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
 
    Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
   
    // Cvars
    g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "3")
    g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "5")
    g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
    g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "50.0")
    g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
    g_pCvarStartXP = register_cvar("ze_start_xp", "0")
    g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
    g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
    g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
    g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
    g_pCvarDoubleXP = register_cvar("ze_double_xp", "15-22")
 
    g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
    g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
    g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
    g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
    g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
   
    // Messages
    g_MsgSync = CreateHudSyncObj()
 
    if (get_pcvar_num(g_pCvarSaveType))
    {
        set_task(0.1, "Delay_MySQL_Init")
    }

    DoubleHours()

    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", TASK_DOUBLE, _, _, "b")
    }
}
 
public plugin_end()
{
    if (get_pcvar_num(g_pCvarSaveType))
    {
        if (g_hTuple != Empty_Handle)
        {
            SQL_FreeHandle(g_hTuple)
        }
    }
}
 
public Delay_MySQL_Init()
{
    MySQL_Init()
}
 
public MySQL_Init()
{
    if (!get_pcvar_num(g_pCvarSaveType))
        return
   
    new szHost[64], szUser[32], szPass[32], szDB[128]
   
    get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
    get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
    get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
    get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
   
    g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
   
    // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
    new iErrorCode, szError[512], Handle:hSQLConnection
   
    hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
   
    if (hSQLConnection != Empty_Handle)
    {
        log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
        SQL_FreeHandle(hSQLConnection)
    }
    else
    {
        // Disable plugin
        set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
    }
   
    SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}
 
public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(1.0, "DelayLoad", id)
 
    // Other tasks
    set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
   
    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", id+TASK_DOUBLE, _, _, "b")
    }
}
 
public HappyHours(taskid)
{
    DoubleHours()

    if (!g_bIsDoubleHours)
        remove_task(taskid)
   
    new szDoubleHours[32]
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    set_dhudmessage(0, 255, 0, -1.0, 0.20, 0, 0.0, 10.0)
    show_dhudmessage(0, "DOUBLE XP: %s", szDoubleHours)
}
 
public DelayLoad(id)
{
    // Load his data
    LoadData(id)
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
       
    remove_task(id+TASK_SHOWHUD)
    remove_task(id)
}
 
public Show_Hud(taskid)
{  
    new iPlayer = ID_SHOWHUD
   
    if (!is_user_alive(iPlayer))
    {
        iPlayer = pev(iPlayer, pev_iuser2)
       
        if (!is_user_alive(iPlayer))
            return
    }
   
    if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
    {
        if(iPlayer != ID_SHOWHUD)
        {
            set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
        else
        {
            set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
    }
    else
    {
        if(iPlayer != ID_SHOWHUD)
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szSpecXP[15], szSpecMaxXP[15]
               
                AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
                AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
               
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
            }  
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szZombieXP[15], szZombieMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
               
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
        else
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szHumanXP[15], szHumanMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
               
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
    }
}
 
public ze_roundend(WinTeam)
{
    if (WinTeam == ZE_TEAM_HUMAN)
    {
        new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarEscapeSuccess) * 2) : get_pcvar_num(g_pCvarEscapeSuccess)

        for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
        {
            if (!is_user_alive(id) || ze_is_user_zombie(id))
                continue
           
            Reward(id, (g_iXP[id] + iXP))
        }
    }
   
    remove_task(TASK_SHOWHUD)
}
 
public Check_User_Level(id)
{
    if (!is_user_connected(id))
        return
 
    if (g_iLevel[id] < MAX_LEVEL)
    {
    	new szName[32]

        while (g_iXP[id] > g_iMaxXP[id])
        {
            if (get_pcvar_num(g_pCvarStartFromZero) == 1)
            {
                g_iXP[id] = 0
            }

        	g_iLevel[id]++
        	g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
            get_user_name(id, szName, charsmax(szName))
            ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
            ExecuteForward(Fw_LevelUP, ForwardReturn, id)
            SaveData(id)
            PlaySound(id, LEVELUP)
           
            if (get_pcvar_num(g_pCvarLevelEffects) != 0)
            {
                // Screen Fade
                message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
                write_short(4096*2)
                write_short(4096*5)
                write_short(0x0001)
                write_byte(random(256))
                write_byte(random(256))
                write_byte(random(256))
                write_byte(150)
                message_end()
               
                // Screen Shake
                message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
                write_short(255<<14)
                write_short(10<<14)
                write_short(255<<14)
                message_end()
            }
        }
    }
}
 
public ze_user_infected(iVictim, iInfector)
{
    if (iInfector == 0)
        return
 
    new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarZombieInfect) * 2) : get_pcvar_num(g_pCvarZombieInfect)
    Reward(iInfector, (g_iXP[iInfector] + iXP))
}
 
public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
    // Player Damage Himself
    if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
        return HC_CONTINUE
   
    // Same Team?
    if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
        return HC_CONTINUE
   
    // Store Damage For every Player
    g_fDamage[iAttacker] += fDamage
   
    // Damage Calculator Equal or Higher than needed damage
    if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
    {
        // Player did damage that a multiplication of the cvar? Increase coins by this factor
        new iMultiplier = floatround(g_fDamage[iAttacker] / get_pcvar_float(g_pCvarRequiredDamage))
        new iXP = ((g_bIsDoubleHours ? (get_pcvar_num(g_pCvarDamageAward) * 2) : get_pcvar_num(g_pCvarDamageAward)) * iMultiplier)
        Reward(iAttacker, (g_iXP[iAttacker] + iXP))
       
        // Rest The Damage Calculator
        g_fDamage[iAttacker] = 0.0
    }
    return HC_CONTINUE
}
 
public Reward(id, XP)
{
    if ((g_iLevel[id] + 1) < MAX_LEVEL)
    {
        g_iXP[id] = XP
        Check_User_Level(id)
    }
    else
    {
    	if ((g_iXP[id] + XP) >= g_iMaxLevelsXP[MAX_LEVEL - 1])
        {
            g_iXP[id] = g_iMaxXP[id] = g_iMaxLevelsXP[MAX_LEVEL - 1]
        }
    }
    SaveData(id)
}
 
public SaveData(id)
{
    new szAuthID[35], szName[32]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
    get_user_name(id, szName, charsmax(szName))
 
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256]
        formatex(szData , charsmax(szData), "%i %i", g_iLevel[id], g_iXP[id])
       
        // Open the Vaults
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
        g_iRanksVaultHandle = nvault_open(g_szRanksVault)
 
        // Saves His Data
        nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
        nvault_set(g_iRanksVaultHandle, szAuthID, szName)
       
        // Close Vaults
        nvault_close(g_iLevelsVaultHandle)
        nvault_close(g_iRanksVaultHandle)
    }
    else
    {
        new szQuery[128]
        formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], szAuthID)
        SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
    }
}
 
public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public LoadData(id)
{
    new szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256], iTimestamp, iExists
       
        // Open the Vault
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
       
        iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
       
        // Close Vault
        nvault_close(g_iLevelsVaultHandle)
       
        if (!iExists)
        {
            g_iLevel[id] = 0
            g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
            SaveData(id)
        }
        else
        {
            new iLevel[32], iXP[32]
            parse(szData, iLevel, 31, iXP, 31)
           
            g_iLevel[id] = str_to_num(iLevel)
            g_iXP[id] = str_to_num(iXP)
        }
 
        g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
    }
    else
    {
        new szQuery[128], szData[5]
        formatex(szQuery, charsmax(szQuery), "SELECT * FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
   
        num_to_str(id, szData, charsmax(szData))
        SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
    }
}
 
public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
{
    if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
        return
   
    new id = str_to_num(szData)
   
    // No results for this query means this is new player
    if (!SQL_NumResults(hQuery))
    {
        g_iLevel[id] = 0
        g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
    }
    else
    {
        g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
        g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
    }
 
    g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
}
 
public native_ze_get_user_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iXP[id]
}
 
public native_ze_set_user_xp(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
    
    DoubleHours()
    new addedXP = (amount - g_iXP[id])
    new iXP = g_bIsDoubleHours ? (addedXP * 2) : addedXP
    Reward(id, g_iXP[id] + iXP)
    return true
}
 
public native_ze_get_user_level(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iLevel[id]
}
 
public native_ze_set_user_level(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    if (amount > MAX_LEVEL)
    {
        log_error(AMX_ERR_NATIVE, "Level must be less than or equal to MAX_LEVEL (%d)", MAX_LEVEL)
        return false
    }
 
    g_iLevel[id] = amount
   
    if (get_pcvar_num(g_pCvarStartFromZero) == 1)
    {
        g_iXP[id] = 0
    }
    SaveData(id)
   
    return true
}
 
public native_ze_get_user_max_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    return g_iMaxXP[id]
}
 
stock DoubleHours()
{
    new szTime[3], szDoubleHours[32], szDoubleHours_Start[32], szDoubleHours_End[32]
    get_time("%H", szTime, charsmax(szTime))
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    for (new ch = 0; ch <= charsmax(szDoubleHours); ch++)
    {
        if (szDoubleHours[ch] == '-')
            szDoubleHours[ch] = ' '
    }
   
    parse(szDoubleHours, szDoubleHours_Start, charsmax(szDoubleHours_Start), szDoubleHours_End, charsmax(szDoubleHours_End))
   
    new iTime, iDoubleHourStart, iDoubleHourEnd
   
    iTime = str_to_num(szTime)
    iDoubleHourStart = str_to_num(szDoubleHours_Start)
    iDoubleHourEnd = str_to_num(szDoubleHours_End)
   
    if (iDoubleHourEnd > iTime >= iDoubleHourStart)
    {
        g_bIsDoubleHours = true
    }
    else
    {
        g_bIsDoubleHours = false
    }
}
@karan PLease Help I am not getiing xp while escape but i getting xp on damage i dont know why!!
try using no max xp level system nd see viewtopic.php?f=15&t=72
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#142

Post by VicKy » 2 years ago

karan wrote: 2 years ago
VicKy wrote: 2 years ago
czirimbolo wrote: 4 years ago Ok here is fixed version of level system by Jack and Raheem. Double exp is working too.

Code: Select all

#include <zombie_escape>
 
// Defines
#define MAX_LEVEL 41
#define TASK_SHOWHUD 2020
#define TASK_DOUBLE 1133
#define REPEAT_TIME 60.0
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"
 
enum
{
    Host = 0,
    User,
    Pass,
    DB
}
 
new const g_iMaxLevelsXP[MAX_LEVEL] =
{
    3000, // 1
    3500, // 2
    5000, // 3
    7500, // 4
    11000, // 5
    15000, // 6
    20000, // 7
    25000, // 8
    30000, // 9
    40000, // 10
    50000, // 11
    60000, // 12
    75000, // 13
    90000, // 14
    105000, // 15
    120000, // 16
    140000, // 17
    170000, // 18
    200000, // 19
    275000, // 20
    350000, // 21
    500000, // 22
    1000000, // 23
    1750000, // 24
    3000000, // 25
    6000000, // 26
    10000000, // 27
    15000000, // 28
    20000000, // 29
    30000000, // 30
    40000000, // 31		
    62000000, // 32
    75000000, // 33
    90000000, // 34
    105000000, // 35
    125000000, // 36
    135000000, // 37
    155000000, // 38
    175000000, // 39
    200000000, // 40		
    300000000 // 41
}
 
// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
new const g_szTable[] =
" \
    ALTER TABLE `test` \
    ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
    ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0'; \
"
 
// Messages
const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.70
const Float:HUD_STATS_X = 0.01
const Float:HUD_STATS_Y = 0.22
 
const HUD_STATS_ZOMBIE_R = 200
const HUD_STATS_ZOMBIE_G = 220
const HUD_STATS_ZOMBIE_B = 0
 
const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 200
const HUD_STATS_HUMAN_B = 210
 
const HUD_STATS_SPEC_R = 100
const HUD_STATS_SPEC_G = 100
const HUD_STATS_SPEC_B = 100
 
// Variables
new g_iLevel[33],
    g_iXP[33],
    g_iMaxXP[33],
    Float:g_fDamage[33],
    g_MsgSync,
    g_iLevelsVaultHandle,
    g_iRanksVaultHandle,
    Handle:g_hTuple,
    Fw_LevelUP,
    ForwardReturn,
    bool:g_bIsDoubleHours
 
// Cvars
new g_pCvarZombieInfect,
    g_pCvarEscapeSuccess,
    g_pCvarEnableDamage,
    g_pCvarRequiredDamage,
    g_pCvarDamageAward,
    g_pCvarStartXP,
    g_pCvarPercentageStyle,
    g_pCvarStartFromZero,
    g_pCvarAddCommas,
    g_pCvarLevelEffects,
    g_pCvarSaveType,
    g_pCvarDBInfo[4],
    g_pCvarDoubleXP
 
public plugin_natives()
{
    register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
    register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
    register_native("ze_get_user_level", "native_ze_get_user_level", 1)
    register_native("ze_set_user_level", "native_ze_set_user_level", 1)
    register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
}
 
public plugin_precache()
{
    precache_sound(LEVELUP)
}
 
public plugin_init()
{
    register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
   
    // Hook Chains
    RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
 
    Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
   
    // Cvars
    g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "3")
    g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "5")
    g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
    g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "50.0")
    g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
    g_pCvarStartXP = register_cvar("ze_start_xp", "0")
    g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
    g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
    g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
    g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
    g_pCvarDoubleXP = register_cvar("ze_double_xp", "15-22")
 
    g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
    g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
    g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
    g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
    g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
   
    // Messages
    g_MsgSync = CreateHudSyncObj()
 
    if (get_pcvar_num(g_pCvarSaveType))
    {
        set_task(0.1, "Delay_MySQL_Init")
    }

    DoubleHours()

    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", TASK_DOUBLE, _, _, "b")
    }
}
 
public plugin_end()
{
    if (get_pcvar_num(g_pCvarSaveType))
    {
        if (g_hTuple != Empty_Handle)
        {
            SQL_FreeHandle(g_hTuple)
        }
    }
}
 
public Delay_MySQL_Init()
{
    MySQL_Init()
}
 
public MySQL_Init()
{
    if (!get_pcvar_num(g_pCvarSaveType))
        return
   
    new szHost[64], szUser[32], szPass[32], szDB[128]
   
    get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
    get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
    get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
    get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
   
    g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
   
    // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
    new iErrorCode, szError[512], Handle:hSQLConnection
   
    hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
   
    if (hSQLConnection != Empty_Handle)
    {
        log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
        SQL_FreeHandle(hSQLConnection)
    }
    else
    {
        // Disable plugin
        set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
    }
   
    SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}
 
public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(1.0, "DelayLoad", id)
 
    // Other tasks
    set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
   
    if (g_bIsDoubleHours)
    {
        set_task(REPEAT_TIME, "HappyHours", id+TASK_DOUBLE, _, _, "b")
    }
}
 
public HappyHours(taskid)
{
    DoubleHours()

    if (!g_bIsDoubleHours)
        remove_task(taskid)
   
    new szDoubleHours[32]
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    set_dhudmessage(0, 255, 0, -1.0, 0.20, 0, 0.0, 10.0)
    show_dhudmessage(0, "DOUBLE XP: %s", szDoubleHours)
}
 
public DelayLoad(id)
{
    // Load his data
    LoadData(id)
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
       
    remove_task(id+TASK_SHOWHUD)
    remove_task(id)
}
 
public Show_Hud(taskid)
{  
    new iPlayer = ID_SHOWHUD
   
    if (!is_user_alive(iPlayer))
    {
        iPlayer = pev(iPlayer, pev_iuser2)
       
        if (!is_user_alive(iPlayer))
            return
    }
   
    if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
    {
        if(iPlayer != ID_SHOWHUD)
        {
            set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
        else
        {
            set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
        }
    }
    else
    {
        if(iPlayer != ID_SHOWHUD)
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szSpecXP[15], szSpecMaxXP[15]
               
                AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
                AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
               
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
            }  
        }
        else if (ze_is_user_zombie(iPlayer))
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szZombieXP[15], szZombieMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
               
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
        else
        {
            if (get_pcvar_num(g_pCvarAddCommas) == 1)
            {
                new szHumanXP[15], szHumanMaxXP[15]
               
                AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
                AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
               
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
            }
            else
            {
                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
            }
        }
    }
}
 
public ze_roundend(WinTeam)
{
    if (WinTeam == ZE_TEAM_HUMAN)
    {
        new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarEscapeSuccess) * 2) : get_pcvar_num(g_pCvarEscapeSuccess)

        for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
        {
            if (!is_user_alive(id) || ze_is_user_zombie(id))
                continue
           
            Reward(id, (g_iXP[id] + iXP))
        }
    }
   
    remove_task(TASK_SHOWHUD)
}
 
public Check_User_Level(id)
{
    if (!is_user_connected(id))
        return
 
    if (g_iLevel[id] < MAX_LEVEL)
    {
    	new szName[32]

        while (g_iXP[id] > g_iMaxXP[id])
        {
            if (get_pcvar_num(g_pCvarStartFromZero) == 1)
            {
                g_iXP[id] = 0
            }

        	g_iLevel[id]++
        	g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
            get_user_name(id, szName, charsmax(szName))
            ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
            ExecuteForward(Fw_LevelUP, ForwardReturn, id)
            SaveData(id)
            PlaySound(id, LEVELUP)
           
            if (get_pcvar_num(g_pCvarLevelEffects) != 0)
            {
                // Screen Fade
                message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
                write_short(4096*2)
                write_short(4096*5)
                write_short(0x0001)
                write_byte(random(256))
                write_byte(random(256))
                write_byte(random(256))
                write_byte(150)
                message_end()
               
                // Screen Shake
                message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
                write_short(255<<14)
                write_short(10<<14)
                write_short(255<<14)
                message_end()
            }
        }
    }
}
 
public ze_user_infected(iVictim, iInfector)
{
    if (iInfector == 0)
        return
 
    new iXP = g_bIsDoubleHours ? (get_pcvar_num(g_pCvarZombieInfect) * 2) : get_pcvar_num(g_pCvarZombieInfect)
    Reward(iInfector, (g_iXP[iInfector] + iXP))
}
 
public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
    // Player Damage Himself
    if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
        return HC_CONTINUE
   
    // Same Team?
    if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
        return HC_CONTINUE
   
    // Store Damage For every Player
    g_fDamage[iAttacker] += fDamage
   
    // Damage Calculator Equal or Higher than needed damage
    if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
    {
        // Player did damage that a multiplication of the cvar? Increase coins by this factor
        new iMultiplier = floatround(g_fDamage[iAttacker] / get_pcvar_float(g_pCvarRequiredDamage))
        new iXP = ((g_bIsDoubleHours ? (get_pcvar_num(g_pCvarDamageAward) * 2) : get_pcvar_num(g_pCvarDamageAward)) * iMultiplier)
        Reward(iAttacker, (g_iXP[iAttacker] + iXP))
       
        // Rest The Damage Calculator
        g_fDamage[iAttacker] = 0.0
    }
    return HC_CONTINUE
}
 
public Reward(id, XP)
{
    if ((g_iLevel[id] + 1) < MAX_LEVEL)
    {
        g_iXP[id] = XP
        Check_User_Level(id)
    }
    else
    {
    	if ((g_iXP[id] + XP) >= g_iMaxLevelsXP[MAX_LEVEL - 1])
        {
            g_iXP[id] = g_iMaxXP[id] = g_iMaxLevelsXP[MAX_LEVEL - 1]
        }
    }
    SaveData(id)
}
 
public SaveData(id)
{
    new szAuthID[35], szName[32]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
    get_user_name(id, szName, charsmax(szName))
 
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256]
        formatex(szData , charsmax(szData), "%i %i", g_iLevel[id], g_iXP[id])
       
        // Open the Vaults
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
        g_iRanksVaultHandle = nvault_open(g_szRanksVault)
 
        // Saves His Data
        nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
        nvault_set(g_iRanksVaultHandle, szAuthID, szName)
       
        // Close Vaults
        nvault_close(g_iLevelsVaultHandle)
        nvault_close(g_iRanksVaultHandle)
    }
    else
    {
        new szQuery[128]
        formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], szAuthID)
        SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
    }
}
 
public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
    SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
 
public LoadData(id)
{
    new szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    if (!get_pcvar_num(g_pCvarSaveType))
    {
        new szData[256], iTimestamp, iExists
       
        // Open the Vault
        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
       
        iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
       
        // Close Vault
        nvault_close(g_iLevelsVaultHandle)
       
        if (!iExists)
        {
            g_iLevel[id] = 0
            g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
            SaveData(id)
        }
        else
        {
            new iLevel[32], iXP[32]
            parse(szData, iLevel, 31, iXP, 31)
           
            g_iLevel[id] = str_to_num(iLevel)
            g_iXP[id] = str_to_num(iXP)
        }
 
        g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
    }
    else
    {
        new szQuery[128], szData[5]
        formatex(szQuery, charsmax(szQuery), "SELECT * FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
   
        num_to_str(id, szData, charsmax(szData))
        SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
    }
}
 
public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
{
    if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
        return
   
    new id = str_to_num(szData)
   
    // No results for this query means this is new player
    if (!SQL_NumResults(hQuery))
    {
        g_iLevel[id] = 0
        g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
    }
    else
    {
        g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
        g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
    }
 
    g_iMaxXP[id] = g_iMaxLevelsXP[g_iLevel[id]]
}
 
public native_ze_get_user_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iXP[id]
}
 
public native_ze_set_user_xp(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
    
    DoubleHours()
    new addedXP = (amount - g_iXP[id])
    new iXP = g_bIsDoubleHours ? (addedXP * 2) : addedXP
    Reward(id, g_iXP[id] + iXP)
    return true
}
 
public native_ze_get_user_level(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    return g_iLevel[id]
}
 
public native_ze_set_user_level(id, amount)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    if (amount > MAX_LEVEL)
    {
        log_error(AMX_ERR_NATIVE, "Level must be less than or equal to MAX_LEVEL (%d)", MAX_LEVEL)
        return false
    }
 
    g_iLevel[id] = amount
   
    if (get_pcvar_num(g_pCvarStartFromZero) == 1)
    {
        g_iXP[id] = 0
    }
    SaveData(id)
   
    return true
}
 
public native_ze_get_user_max_xp(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false
    }
   
    return g_iMaxXP[id]
}
 
stock DoubleHours()
{
    new szTime[3], szDoubleHours[32], szDoubleHours_Start[32], szDoubleHours_End[32]
    get_time("%H", szTime, charsmax(szTime))
   
    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))
   
    for (new ch = 0; ch <= charsmax(szDoubleHours); ch++)
    {
        if (szDoubleHours[ch] == '-')
            szDoubleHours[ch] = ' '
    }
   
    parse(szDoubleHours, szDoubleHours_Start, charsmax(szDoubleHours_Start), szDoubleHours_End, charsmax(szDoubleHours_End))
   
    new iTime, iDoubleHourStart, iDoubleHourEnd
   
    iTime = str_to_num(szTime)
    iDoubleHourStart = str_to_num(szDoubleHours_Start)
    iDoubleHourEnd = str_to_num(szDoubleHours_End)
   
    if (iDoubleHourEnd > iTime >= iDoubleHourStart)
    {
        g_bIsDoubleHours = true
    }
    else
    {
        g_bIsDoubleHours = false
    }
}
@karan PLease Help I am not getiing xp while escape but i getting xp on damage i dont know why!!
try using no max xp level system nd see viewtopic.php?f=15&t=72
I Used The Default One Maxx-Xp And No-Maxxp But Both Are Not Working ( no getting xp at escape ) i dont know why

code is :-
  1. #include <zombie_escape>
  2.  
  3. // Defines
  4. #define MAX_LEVEL 60
  5. #define MAX_XP 528029013
  6. #define TASK_SHOWHUD 2020
  7. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  8. #define LEVELUP "levelup_ZE/ze_levelup.wav"
  9.  
  10. enum
  11. {
  12.     Host = 0,
  13.     User,
  14.     Pass,
  15.     DB
  16. }
  17.  
  18. // Constants
  19. new const g_szLevelsVault[] = "FuriX_LL"
  20. new const g_szRanksVault[] = "FuriX-RR"
  21. new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
  22. new const g_szTable[] =
  23. " \
  24.     ALTER TABLE `test` \
  25.     ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
  26.     ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
  27.     ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
  28. "
  29.  
  30. // Messages
  31. const Float:HUD_SPECT_X = -1.0
  32. const Float:HUD_SPECT_Y = 0.70
  33. const Float:HUD_STATS_X = -1.0
  34. const Float:HUD_STATS_Y = 0.90
  35.  
  36. const HUD_STATS_ZOMBIE_R = 200
  37. const HUD_STATS_ZOMBIE_G = 220
  38. const HUD_STATS_ZOMBIE_B = 0
  39.  
  40. const HUD_STATS_HUMAN_R = 0
  41. const HUD_STATS_HUMAN_G = 200
  42. const HUD_STATS_HUMAN_B = 210
  43.  
  44. const HUD_STATS_SPEC_R = 100
  45. const HUD_STATS_SPEC_G = 100
  46. const HUD_STATS_SPEC_B = 100
  47.  
  48. // Variables
  49. new g_iLevel[33],
  50.     g_iXP[33],
  51.     g_iMaxXP[33],
  52.     Float:g_fDamage[33],
  53.     g_MsgSync,
  54.     g_iLevelsVaultHandle,
  55.     g_iRanksVaultHandle,
  56.     Handle:g_hTuple,
  57.     Fw_LevelUP,
  58.     ForwardReturn
  59.  
  60. // Cvars
  61. new g_pCvarZombieInfect,
  62.     g_pCvarEscapeSuccess,
  63.     g_pCvarEnableDamage,
  64.     g_pCvarRequiredDamage,
  65.     g_pCvarDamageAward,
  66.     g_pCvarStartXP,
  67.     g_pCvarMaxLevelsIncrement,
  68.     g_pCvarMaxXPFirstLevel,
  69.     g_pCvarPercentageStyle,
  70.     g_pCvarStartFromZero,
  71.     g_pCvarAddCommas,
  72.     g_pCvarLevelEffects,
  73.     g_pCvarSaveType,
  74.     g_pCvarDBInfo[4]
  75.  
  76. public plugin_natives()
  77. {
  78.     register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
  79.     register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
  80.     register_native("ze_get_user_level", "native_ze_get_user_level", 1)
  81.     register_native("ze_set_user_level", "native_ze_set_user_level", 1)
  82.     register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
  83.     register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
  84. }
  85.  
  86. public plugin_precache()
  87. {
  88.     precache_sound(LEVELUP)
  89. }
  90.  
  91. public plugin_init()
  92. {
  93.     register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
  94.    
  95.     // Hook Chains
  96.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  97.  
  98.     Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
  99.    
  100.     // Cvars
  101.     g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "0")
  102.     g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "100")
  103.     g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
  104.     g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "1000.0")
  105.     g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
  106.     g_pCvarStartXP = register_cvar("ze_start_xp", "50")
  107.     g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.3")
  108.     g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "100")
  109.     g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
  110.     g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
  111.     g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
  112.     g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")
  113.     g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
  114.     g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
  115.     g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
  116.     g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
  117.     g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
  118.    
  119.     // Messages
  120.     g_MsgSync = CreateHudSyncObj()
  121.  
  122.     if (get_pcvar_num(g_pCvarSaveType))
  123.     {
  124.         set_task(0.1, "Delay_MySQL_Init")
  125.     }
  126. }
  127.  
  128. public plugin_end()
  129. {
  130.     if (get_pcvar_num(g_pCvarSaveType))
  131.     {
  132.         if (g_hTuple != Empty_Handle)
  133.         {
  134.             SQL_FreeHandle(g_hTuple)
  135.         }
  136.     }
  137. }
  138.  
  139. public Delay_MySQL_Init()
  140. {
  141.     MySQL_Init()
  142. }
  143.  
  144. public MySQL_Init()
  145. {
  146.     if (!get_pcvar_num(g_pCvarSaveType))
  147.         return
  148.    
  149.     new szHost[64], szUser[32], szPass[32], szDB[128]
  150.    
  151.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  152.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  153.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  154.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  155.    
  156.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  157.    
  158.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  159.     new iErrorCode, szError[512], Handle:hSQLConnection
  160.    
  161.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  162.    
  163.     if (hSQLConnection != Empty_Handle)
  164.     {
  165.         log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
  166.         SQL_FreeHandle(hSQLConnection)
  167.     }
  168.     else
  169.     {
  170.         // Disable plugin
  171.         set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
  172.     }
  173.    
  174.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  175. }
  176.  
  177. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  178. {
  179.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  180. }
  181.  
  182. public client_putinserver(id)
  183. {
  184.     if(is_user_hltv(id) || is_user_bot(id))
  185.         return
  186.    
  187.     // Just 1 second delay
  188.     set_task(1.0, "DelayLoad", id)
  189.  
  190.     // Other tasks
  191.     set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
  192.     set_task(0.1, "Check_MaxXP", id, _, _, "b")
  193. }
  194.  
  195. public DelayLoad(id)
  196. {
  197.     // Load his data
  198.     LoadData(id)
  199. }
  200.  
  201. public client_disconnected(id)
  202. {
  203.     if(is_user_hltv(id) || is_user_bot(id))
  204.         return
  205.        
  206.     remove_task(id+TASK_SHOWHUD)
  207.     remove_task(id)
  208. }
  209.  
  210. public Check_MaxXP(id)
  211. {
  212.     new iCurrentMaxXP = g_iMaxXP[id]
  213.    
  214.     new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  215.    
  216.     for (new i = 1; i <= g_iLevel[id]; i++)
  217.     {
  218.         iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  219.     }
  220.    
  221.     if (iCurrentMaxXP != iMaxXP)
  222.     {
  223.         g_iMaxXP[id] = iMaxXP
  224.     }
  225. }
  226.  
  227. public Show_Hud(taskid)
  228. {  
  229.     new iPlayer = ID_SHOWHUD
  230.    
  231.     if (!is_user_alive(iPlayer))
  232.     {
  233.         iPlayer = pev(iPlayer, pev_iuser2)
  234.        
  235.         if (!is_user_alive(iPlayer))
  236.             return
  237.     }
  238.    
  239.     if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
  240.     {
  241.         if(iPlayer != ID_SHOWHUD)
  242.         {
  243.             set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  244.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
  245.         }
  246.         else if (ze_is_user_zombie(iPlayer))
  247.         {
  248.             set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  249.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  250.         }
  251.         else
  252.         {
  253.             set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  254.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  255.         }
  256.     }
  257.     else
  258.     {
  259.         if(iPlayer != ID_SHOWHUD)
  260.         {
  261.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  262.             {
  263.                 new szSpecXP[15], szSpecMaxXP[15]
  264.                
  265.                 AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
  266.                 AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
  267.                
  268.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  269.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
  270.             }
  271.             else
  272.             {
  273.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  274.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
  275.             }  
  276.         }
  277.         else if (ze_is_user_zombie(iPlayer))
  278.         {
  279.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  280.             {
  281.                 new szZombieXP[15], szZombieMaxXP[15]
  282.                
  283.                 AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
  284.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
  285.                
  286.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  287.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
  288.             }
  289.             else
  290.             {
  291.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  292.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  293.             }
  294.         }
  295.         else
  296.         {
  297.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  298.             {
  299.                 new szHumanXP[15], szHumanMaxXP[15]
  300.                
  301.                 AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
  302.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
  303.                
  304.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  305.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
  306.             }
  307.             else
  308.             {
  309.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  310.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  311.             }
  312.         }
  313.     }
  314. }
  315.  
  316. public ze_roundend(WinTeam)
  317. {
  318.     if (WinTeam == ZE_TEAM_HUMAN)
  319.     {
  320.         for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  321.         {
  322.             if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
  323.                 continue
  324.            
  325.             g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
  326.             SaveData(id)
  327.             Check_User_Level(id)
  328.         }
  329.     }
  330.    
  331.     remove_task(TASK_SHOWHUD)
  332. }
  333.  
  334. public Check_User_Level(id)
  335. {
  336.     if(!is_user_connected(id))
  337.         return
  338.  
  339.     if(g_iXP[id] >= g_iMaxXP[id])
  340.     {
  341.         if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  342.         {
  343.             g_iXP[id] = 0
  344.         }
  345.        
  346.         new szName[32]
  347.         g_iLevel[id] ++
  348.        
  349.         g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  350.         get_user_name(id, szName, charsmax(szName))
  351.         ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
  352.         ExecuteForward(Fw_LevelUP, ForwardReturn, id)
  353.        
  354.         SaveData(id)
  355.        
  356.         PlaySound(id, LEVELUP)
  357.        
  358.         if (get_pcvar_num(g_pCvarLevelEffects) != 0)
  359.         {
  360.             // Screen Fade
  361.             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
  362.             write_short(4096*2)
  363.             write_short(4096*5)
  364.             write_short(0x0001)
  365.             write_byte(random(256))
  366.             write_byte(random(256))
  367.             write_byte(random(256))
  368.             write_byte(150)
  369.             message_end()
  370.            
  371.             // Screen Shake
  372.             message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
  373.             write_short(255<<14)
  374.             write_short(10<<14)
  375.             write_short(255<<14)
  376.             message_end()
  377.         }
  378.     }
  379. }
  380.  
  381. public ze_user_infected(iVictim, iInfector)
  382. {
  383.     if (iInfector == 0)
  384.         return
  385.    
  386.     g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
  387.     SaveData(iInfector)
  388.     Check_User_Level(iInfector)
  389. }
  390.  
  391. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  392. {
  393.     // Player Damage Himself
  394.     if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
  395.         return HC_CONTINUE
  396.    
  397.     // Same Team?
  398.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  399.         return HC_CONTINUE
  400.    
  401.     // Store Damage For every Player
  402.     g_fDamage[iAttacker] += fDamage
  403.    
  404.     // Damage Calculator Equal or Higher than needed damage
  405.     if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
  406.     {
  407.         // Give Player The Coins
  408.         g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
  409.         SaveData(iAttacker)
  410.         Check_User_Level(iAttacker)
  411.        
  412.         // Rest The Damage Calculator
  413.         g_fDamage[iAttacker] = 0.0
  414.     }
  415.     return HC_CONTINUE
  416. }
  417.  
  418. public SaveData(id)
  419. {
  420.     new szAuthID[35], szName[32]
  421.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  422.     get_user_name(id, szName, charsmax(szName))
  423.    
  424.     // Set Him to max if he Higher than Max Value
  425.     if (g_iLevel[id] > MAX_LEVEL)
  426.     {
  427.         g_iLevel[id] = MAX_LEVEL
  428.     }
  429.    
  430.     if (g_iXP[id] > MAX_XP)
  431.     {
  432.         g_iXP[id] = MAX_XP
  433.     }
  434.  
  435.     if (!get_pcvar_num(g_pCvarSaveType))
  436.     {
  437.         new szData[256]
  438.         formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
  439.        
  440.         // Open the Vaults
  441.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  442.         g_iRanksVaultHandle = nvault_open(g_szRanksVault)
  443.  
  444.         // Saves His Data
  445.         nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
  446.         nvault_set(g_iRanksVaultHandle, szAuthID, szName)
  447.        
  448.         // Close Vaults
  449.         nvault_close(g_iLevelsVaultHandle)
  450.         nvault_close(g_iRanksVaultHandle)
  451.     }
  452.     else
  453.     {
  454.         new szQuery[128]
  455.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
  456.         SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
  457.     }
  458. }
  459.  
  460. public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  461. {
  462.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  463. }
  464.  
  465. public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  466. {
  467.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  468. }
  469.  
  470. public LoadData(id)
  471. {
  472.     new szData[256], szAuthID[35]
  473.    
  474.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  475.    
  476.     if (!get_pcvar_num(g_pCvarSaveType))
  477.     {
  478.         // Useless Variable
  479.         new iTimestamp, iExists
  480.        
  481.         // Open the Vault
  482.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  483.        
  484.         iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  485.        
  486.         // Close Vault
  487.         nvault_close(g_iLevelsVaultHandle)
  488.        
  489.         if (!iExists)
  490.         {
  491.             g_iLevel[id] = 0
  492.             g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
  493.             g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  494.             SaveData(id)
  495.         }
  496.         else
  497.         {
  498.             new iLevel[32], iXP[32], iMaxLevel[32]
  499.             parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
  500.            
  501.             g_iLevel[id] = str_to_num(iLevel)
  502.             g_iXP[id] = str_to_num(iXP)
  503.             g_iMaxXP[id] = str_to_num(iMaxLevel)
  504.         }
  505.     }
  506.     else
  507.     {
  508.         new szQuery[128], szData[5]
  509.         formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)
  510.      
  511.         num_to_str(id, szData, charsmax(szData))
  512.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  513.     }
  514. }
  515.  
  516. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  517. {
  518.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  519.         return
  520.    
  521.     new id = str_to_num(szData)
  522.    
  523.     // No results for this query means this is new player
  524.     if (!SQL_NumResults(hQuery))
  525.     {
  526.         new szSteamId[36], szQuery[128]
  527.         get_user_authid(id, szSteamId, charsmax(szSteamId))
  528.  
  529.         g_iLevel[id] = 0
  530.         g_iXP[id] = 0
  531.         g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  532.         return
  533.     }
  534.  
  535.     g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
  536.     g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
  537.     g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))
  538. }
  539.  
  540. public native_ze_get_user_xp(id)
  541. {
  542.     if(!is_user_connected(id))
  543.     {
  544.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  545.         return false;
  546.     }
  547.    
  548.     return g_iXP[id]
  549. }
  550.  
  551. public native_ze_set_user_xp(id, amount)
  552. {
  553.     if(!is_user_connected(id))
  554.     {
  555.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  556.         return false;
  557.     }
  558.    
  559.     g_iXP[id] = amount
  560.    
  561.     Check_User_Level(id)
  562.     return true;
  563. }
  564.  
  565. public native_ze_get_user_level(id)
  566. {
  567.     if(!is_user_connected(id))
  568.     {
  569.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  570.         return false;
  571.     }
  572.    
  573.     return g_iLevel[id]
  574. }
  575.  
  576. public native_ze_set_user_level(id, amount)
  577. {
  578.     if(!is_user_connected(id))
  579.     {
  580.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  581.         return false;
  582.     }
  583.    
  584.     g_iLevel[id] = amount
  585.    
  586.     if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  587.     {
  588.         g_iXP[id] = 0
  589.     }
  590.    
  591.     return true;
  592. }
  593.  
  594. public native_ze_get_user_max_xp(id)
  595. {
  596.     if(!is_user_connected(id))
  597.     {
  598.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  599.         return false;
  600.     }
  601.    
  602.     return g_iMaxXP[id]
  603. }
  604.  
  605. public native_ze_set_user_max_xp(id, amount)
  606. {
  607.     if(!is_user_connected(id))
  608.     {
  609.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  610.         return false;
  611.     }
  612.    
  613.     g_iMaxXP[id] = amount
  614.     return true;
  615. }
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#143

Post by karan » 2 years ago

VicKy wrote: 2 years ago
karan wrote: 2 years ago
VicKy wrote: 2 years ago

@karan PLease Help I am not getiing xp while escape but i getting xp on damage i dont know why!!
try using no max xp level system nd see viewtopic.php?f=15&t=72
I Used The Default One Maxx-Xp And No-Maxxp But Both Are Not Working ( no getting xp at escape ) i dont know why

code is :-
  1. #include <zombie_escape>
  2.  
  3. // Defines
  4. #define MAX_LEVEL 60
  5. #define MAX_XP 528029013
  6. #define TASK_SHOWHUD 2020
  7. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  8. #define LEVELUP "levelup_ZE/ze_levelup.wav"
  9.  
  10. enum
  11. {
  12.     Host = 0,
  13.     User,
  14.     Pass,
  15.     DB
  16. }
  17.  
  18. // Constants
  19. new const g_szLevelsVault[] = "FuriX_LL"
  20. new const g_szRanksVault[] = "FuriX-RR"
  21. new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
  22. new const g_szTable[] =
  23. " \
  24.     ALTER TABLE `test` \
  25.     ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
  26.     ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
  27.     ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
  28. "
  29.  
  30. // Messages
  31. const Float:HUD_SPECT_X = -1.0
  32. const Float:HUD_SPECT_Y = 0.70
  33. const Float:HUD_STATS_X = -1.0
  34. const Float:HUD_STATS_Y = 0.90
  35.  
  36. const HUD_STATS_ZOMBIE_R = 200
  37. const HUD_STATS_ZOMBIE_G = 220
  38. const HUD_STATS_ZOMBIE_B = 0
  39.  
  40. const HUD_STATS_HUMAN_R = 0
  41. const HUD_STATS_HUMAN_G = 200
  42. const HUD_STATS_HUMAN_B = 210
  43.  
  44. const HUD_STATS_SPEC_R = 100
  45. const HUD_STATS_SPEC_G = 100
  46. const HUD_STATS_SPEC_B = 100
  47.  
  48. // Variables
  49. new g_iLevel[33],
  50.     g_iXP[33],
  51.     g_iMaxXP[33],
  52.     Float:g_fDamage[33],
  53.     g_MsgSync,
  54.     g_iLevelsVaultHandle,
  55.     g_iRanksVaultHandle,
  56.     Handle:g_hTuple,
  57.     Fw_LevelUP,
  58.     ForwardReturn
  59.  
  60. // Cvars
  61. new g_pCvarZombieInfect,
  62.     g_pCvarEscapeSuccess,
  63.     g_pCvarEnableDamage,
  64.     g_pCvarRequiredDamage,
  65.     g_pCvarDamageAward,
  66.     g_pCvarStartXP,
  67.     g_pCvarMaxLevelsIncrement,
  68.     g_pCvarMaxXPFirstLevel,
  69.     g_pCvarPercentageStyle,
  70.     g_pCvarStartFromZero,
  71.     g_pCvarAddCommas,
  72.     g_pCvarLevelEffects,
  73.     g_pCvarSaveType,
  74.     g_pCvarDBInfo[4]
  75.  
  76. public plugin_natives()
  77. {
  78.     register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
  79.     register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
  80.     register_native("ze_get_user_level", "native_ze_get_user_level", 1)
  81.     register_native("ze_set_user_level", "native_ze_set_user_level", 1)
  82.     register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
  83.     register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
  84. }
  85.  
  86. public plugin_precache()
  87. {
  88.     precache_sound(LEVELUP)
  89. }
  90.  
  91. public plugin_init()
  92. {
  93.     register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
  94.    
  95.     // Hook Chains
  96.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  97.  
  98.     Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
  99.    
  100.     // Cvars
  101.     g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "0")
  102.     g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "100")
  103.     g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
  104.     g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "1000.0")
  105.     g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
  106.     g_pCvarStartXP = register_cvar("ze_start_xp", "50")
  107.     g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.3")
  108.     g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "100")
  109.     g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
  110.     g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
  111.     g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
  112.     g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")
  113.     g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
  114.     g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
  115.     g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
  116.     g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
  117.     g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
  118.    
  119.     // Messages
  120.     g_MsgSync = CreateHudSyncObj()
  121.  
  122.     if (get_pcvar_num(g_pCvarSaveType))
  123.     {
  124.         set_task(0.1, "Delay_MySQL_Init")
  125.     }
  126. }
  127.  
  128. public plugin_end()
  129. {
  130.     if (get_pcvar_num(g_pCvarSaveType))
  131.     {
  132.         if (g_hTuple != Empty_Handle)
  133.         {
  134.             SQL_FreeHandle(g_hTuple)
  135.         }
  136.     }
  137. }
  138.  
  139. public Delay_MySQL_Init()
  140. {
  141.     MySQL_Init()
  142. }
  143.  
  144. public MySQL_Init()
  145. {
  146.     if (!get_pcvar_num(g_pCvarSaveType))
  147.         return
  148.    
  149.     new szHost[64], szUser[32], szPass[32], szDB[128]
  150.    
  151.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  152.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  153.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  154.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  155.    
  156.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  157.    
  158.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  159.     new iErrorCode, szError[512], Handle:hSQLConnection
  160.    
  161.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  162.    
  163.     if (hSQLConnection != Empty_Handle)
  164.     {
  165.         log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
  166.         SQL_FreeHandle(hSQLConnection)
  167.     }
  168.     else
  169.     {
  170.         // Disable plugin
  171.         set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
  172.     }
  173.    
  174.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  175. }
  176.  
  177. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  178. {
  179.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  180. }
  181.  
  182. public client_putinserver(id)
  183. {
  184.     if(is_user_hltv(id) || is_user_bot(id))
  185.         return
  186.    
  187.     // Just 1 second delay
  188.     set_task(1.0, "DelayLoad", id)
  189.  
  190.     // Other tasks
  191.     set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
  192.     set_task(0.1, "Check_MaxXP", id, _, _, "b")
  193. }
  194.  
  195. public DelayLoad(id)
  196. {
  197.     // Load his data
  198.     LoadData(id)
  199. }
  200.  
  201. public client_disconnected(id)
  202. {
  203.     if(is_user_hltv(id) || is_user_bot(id))
  204.         return
  205.        
  206.     remove_task(id+TASK_SHOWHUD)
  207.     remove_task(id)
  208. }
  209.  
  210. public Check_MaxXP(id)
  211. {
  212.     new iCurrentMaxXP = g_iMaxXP[id]
  213.    
  214.     new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  215.    
  216.     for (new i = 1; i <= g_iLevel[id]; i++)
  217.     {
  218.         iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  219.     }
  220.    
  221.     if (iCurrentMaxXP != iMaxXP)
  222.     {
  223.         g_iMaxXP[id] = iMaxXP
  224.     }
  225. }
  226.  
  227. public Show_Hud(taskid)
  228. {  
  229.     new iPlayer = ID_SHOWHUD
  230.    
  231.     if (!is_user_alive(iPlayer))
  232.     {
  233.         iPlayer = pev(iPlayer, pev_iuser2)
  234.        
  235.         if (!is_user_alive(iPlayer))
  236.             return
  237.     }
  238.    
  239.     if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
  240.     {
  241.         if(iPlayer != ID_SHOWHUD)
  242.         {
  243.             set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  244.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
  245.         }
  246.         else if (ze_is_user_zombie(iPlayer))
  247.         {
  248.             set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  249.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  250.         }
  251.         else
  252.         {
  253.             set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  254.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  255.         }
  256.     }
  257.     else
  258.     {
  259.         if(iPlayer != ID_SHOWHUD)
  260.         {
  261.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  262.             {
  263.                 new szSpecXP[15], szSpecMaxXP[15]
  264.                
  265.                 AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
  266.                 AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
  267.                
  268.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  269.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
  270.             }
  271.             else
  272.             {
  273.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  274.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
  275.             }  
  276.         }
  277.         else if (ze_is_user_zombie(iPlayer))
  278.         {
  279.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  280.             {
  281.                 new szZombieXP[15], szZombieMaxXP[15]
  282.                
  283.                 AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
  284.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
  285.                
  286.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  287.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
  288.             }
  289.             else
  290.             {
  291.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  292.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  293.             }
  294.         }
  295.         else
  296.         {
  297.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  298.             {
  299.                 new szHumanXP[15], szHumanMaxXP[15]
  300.                
  301.                 AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
  302.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
  303.                
  304.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  305.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
  306.             }
  307.             else
  308.             {
  309.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  310.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  311.             }
  312.         }
  313.     }
  314. }
  315.  
  316. public ze_roundend(WinTeam)
  317. {
  318.     if (WinTeam == ZE_TEAM_HUMAN)
  319.     {
  320.         for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  321.         {
  322.             if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
  323.                 continue
  324.            
  325.             g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
  326.             SaveData(id)
  327.             Check_User_Level(id)
  328.         }
  329.     }
  330.    
  331.     remove_task(TASK_SHOWHUD)
  332. }
  333.  
  334. public Check_User_Level(id)
  335. {
  336.     if(!is_user_connected(id))
  337.         return
  338.  
  339.     if(g_iXP[id] >= g_iMaxXP[id])
  340.     {
  341.         if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  342.         {
  343.             g_iXP[id] = 0
  344.         }
  345.        
  346.         new szName[32]
  347.         g_iLevel[id] ++
  348.        
  349.         g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  350.         get_user_name(id, szName, charsmax(szName))
  351.         ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
  352.         ExecuteForward(Fw_LevelUP, ForwardReturn, id)
  353.        
  354.         SaveData(id)
  355.        
  356.         PlaySound(id, LEVELUP)
  357.        
  358.         if (get_pcvar_num(g_pCvarLevelEffects) != 0)
  359.         {
  360.             // Screen Fade
  361.             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
  362.             write_short(4096*2)
  363.             write_short(4096*5)
  364.             write_short(0x0001)
  365.             write_byte(random(256))
  366.             write_byte(random(256))
  367.             write_byte(random(256))
  368.             write_byte(150)
  369.             message_end()
  370.            
  371.             // Screen Shake
  372.             message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
  373.             write_short(255<<14)
  374.             write_short(10<<14)
  375.             write_short(255<<14)
  376.             message_end()
  377.         }
  378.     }
  379. }
  380.  
  381. public ze_user_infected(iVictim, iInfector)
  382. {
  383.     if (iInfector == 0)
  384.         return
  385.    
  386.     g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
  387.     SaveData(iInfector)
  388.     Check_User_Level(iInfector)
  389. }
  390.  
  391. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  392. {
  393.     // Player Damage Himself
  394.     if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
  395.         return HC_CONTINUE
  396.    
  397.     // Same Team?
  398.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  399.         return HC_CONTINUE
  400.    
  401.     // Store Damage For every Player
  402.     g_fDamage[iAttacker] += fDamage
  403.    
  404.     // Damage Calculator Equal or Higher than needed damage
  405.     if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
  406.     {
  407.         // Give Player The Coins
  408.         g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
  409.         SaveData(iAttacker)
  410.         Check_User_Level(iAttacker)
  411.        
  412.         // Rest The Damage Calculator
  413.         g_fDamage[iAttacker] = 0.0
  414.     }
  415.     return HC_CONTINUE
  416. }
  417.  
  418. public SaveData(id)
  419. {
  420.     new szAuthID[35], szName[32]
  421.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  422.     get_user_name(id, szName, charsmax(szName))
  423.    
  424.     // Set Him to max if he Higher than Max Value
  425.     if (g_iLevel[id] > MAX_LEVEL)
  426.     {
  427.         g_iLevel[id] = MAX_LEVEL
  428.     }
  429.    
  430.     if (g_iXP[id] > MAX_XP)
  431.     {
  432.         g_iXP[id] = MAX_XP
  433.     }
  434.  
  435.     if (!get_pcvar_num(g_pCvarSaveType))
  436.     {
  437.         new szData[256]
  438.         formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
  439.        
  440.         // Open the Vaults
  441.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  442.         g_iRanksVaultHandle = nvault_open(g_szRanksVault)
  443.  
  444.         // Saves His Data
  445.         nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
  446.         nvault_set(g_iRanksVaultHandle, szAuthID, szName)
  447.        
  448.         // Close Vaults
  449.         nvault_close(g_iLevelsVaultHandle)
  450.         nvault_close(g_iRanksVaultHandle)
  451.     }
  452.     else
  453.     {
  454.         new szQuery[128]
  455.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
  456.         SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
  457.     }
  458. }
  459.  
  460. public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  461. {
  462.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  463. }
  464.  
  465. public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  466. {
  467.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  468. }
  469.  
  470. public LoadData(id)
  471. {
  472.     new szData[256], szAuthID[35]
  473.    
  474.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  475.    
  476.     if (!get_pcvar_num(g_pCvarSaveType))
  477.     {
  478.         // Useless Variable
  479.         new iTimestamp, iExists
  480.        
  481.         // Open the Vault
  482.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  483.        
  484.         iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  485.        
  486.         // Close Vault
  487.         nvault_close(g_iLevelsVaultHandle)
  488.        
  489.         if (!iExists)
  490.         {
  491.             g_iLevel[id] = 0
  492.             g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
  493.             g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  494.             SaveData(id)
  495.         }
  496.         else
  497.         {
  498.             new iLevel[32], iXP[32], iMaxLevel[32]
  499.             parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
  500.            
  501.             g_iLevel[id] = str_to_num(iLevel)
  502.             g_iXP[id] = str_to_num(iXP)
  503.             g_iMaxXP[id] = str_to_num(iMaxLevel)
  504.         }
  505.     }
  506.     else
  507.     {
  508.         new szQuery[128], szData[5]
  509.         formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)
  510.      
  511.         num_to_str(id, szData, charsmax(szData))
  512.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  513.     }
  514. }
  515.  
  516. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  517. {
  518.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  519.         return
  520.    
  521.     new id = str_to_num(szData)
  522.    
  523.     // No results for this query means this is new player
  524.     if (!SQL_NumResults(hQuery))
  525.     {
  526.         new szSteamId[36], szQuery[128]
  527.         get_user_authid(id, szSteamId, charsmax(szSteamId))
  528.  
  529.         g_iLevel[id] = 0
  530.         g_iXP[id] = 0
  531.         g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  532.         return
  533.     }
  534.  
  535.     g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
  536.     g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
  537.     g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))
  538. }
  539.  
  540. public native_ze_get_user_xp(id)
  541. {
  542.     if(!is_user_connected(id))
  543.     {
  544.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  545.         return false;
  546.     }
  547.    
  548.     return g_iXP[id]
  549. }
  550.  
  551. public native_ze_set_user_xp(id, amount)
  552. {
  553.     if(!is_user_connected(id))
  554.     {
  555.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  556.         return false;
  557.     }
  558.    
  559.     g_iXP[id] = amount
  560.    
  561.     Check_User_Level(id)
  562.     return true;
  563. }
  564.  
  565. public native_ze_get_user_level(id)
  566. {
  567.     if(!is_user_connected(id))
  568.     {
  569.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  570.         return false;
  571.     }
  572.    
  573.     return g_iLevel[id]
  574. }
  575.  
  576. public native_ze_set_user_level(id, amount)
  577. {
  578.     if(!is_user_connected(id))
  579.     {
  580.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  581.         return false;
  582.     }
  583.    
  584.     g_iLevel[id] = amount
  585.    
  586.     if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  587.     {
  588.         g_iXP[id] = 0
  589.     }
  590.    
  591.     return true;
  592. }
  593.  
  594. public native_ze_get_user_max_xp(id)
  595. {
  596.     if(!is_user_connected(id))
  597.     {
  598.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  599.         return false;
  600.     }
  601.    
  602.     return g_iMaxXP[id]
  603. }
  604.  
  605. public native_ze_set_user_max_xp(id, amount)
  606. {
  607.     if(!is_user_connected(id))
  608.     {
  609.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  610.         return false;
  611.     }
  612.    
  613.     g_iMaxXP[id] = amount
  614.     return true;
  615. }
post ur ze.cfg file
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#144

Post by VicKy » 2 years ago

karan wrote: 2 years ago
VicKy wrote: 2 years ago
karan wrote: 2 years ago
try using no max xp level system nd see viewtopic.php?f=15&t=72
I Used The Default One Maxx-Xp And No-Maxxp But Both Are Not Working ( no getting xp at escape ) i dont know why

code is :-
  1. #include <zombie_escape>
  2.  
  3. // Defines
  4. #define MAX_LEVEL 60
  5. #define MAX_XP 528029013
  6. #define TASK_SHOWHUD 2020
  7. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  8. #define LEVELUP "levelup_ZE/ze_levelup.wav"
  9.  
  10. enum
  11. {
  12.     Host = 0,
  13.     User,
  14.     Pass,
  15.     DB
  16. }
  17.  
  18. // Constants
  19. new const g_szLevelsVault[] = "FuriX_LL"
  20. new const g_szRanksVault[] = "FuriX-RR"
  21. new const g_szLogFile[] = "Levels.log" // MySQL Errors log file
  22. new const g_szTable[] =
  23. " \
  24.     ALTER TABLE `test` \
  25.     ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
  26.     ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
  27.     ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
  28. "
  29.  
  30. // Messages
  31. const Float:HUD_SPECT_X = -1.0
  32. const Float:HUD_SPECT_Y = 0.70
  33. const Float:HUD_STATS_X = -1.0
  34. const Float:HUD_STATS_Y = 0.90
  35.  
  36. const HUD_STATS_ZOMBIE_R = 200
  37. const HUD_STATS_ZOMBIE_G = 220
  38. const HUD_STATS_ZOMBIE_B = 0
  39.  
  40. const HUD_STATS_HUMAN_R = 0
  41. const HUD_STATS_HUMAN_G = 200
  42. const HUD_STATS_HUMAN_B = 210
  43.  
  44. const HUD_STATS_SPEC_R = 100
  45. const HUD_STATS_SPEC_G = 100
  46. const HUD_STATS_SPEC_B = 100
  47.  
  48. // Variables
  49. new g_iLevel[33],
  50.     g_iXP[33],
  51.     g_iMaxXP[33],
  52.     Float:g_fDamage[33],
  53.     g_MsgSync,
  54.     g_iLevelsVaultHandle,
  55.     g_iRanksVaultHandle,
  56.     Handle:g_hTuple,
  57.     Fw_LevelUP,
  58.     ForwardReturn
  59.  
  60. // Cvars
  61. new g_pCvarZombieInfect,
  62.     g_pCvarEscapeSuccess,
  63.     g_pCvarEnableDamage,
  64.     g_pCvarRequiredDamage,
  65.     g_pCvarDamageAward,
  66.     g_pCvarStartXP,
  67.     g_pCvarMaxLevelsIncrement,
  68.     g_pCvarMaxXPFirstLevel,
  69.     g_pCvarPercentageStyle,
  70.     g_pCvarStartFromZero,
  71.     g_pCvarAddCommas,
  72.     g_pCvarLevelEffects,
  73.     g_pCvarSaveType,
  74.     g_pCvarDBInfo[4]
  75.  
  76. public plugin_natives()
  77. {
  78.     register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
  79.     register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
  80.     register_native("ze_get_user_level", "native_ze_get_user_level", 1)
  81.     register_native("ze_set_user_level", "native_ze_set_user_level", 1)
  82.     register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
  83.     register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
  84. }
  85.  
  86. public plugin_precache()
  87. {
  88.     precache_sound(LEVELUP)
  89. }
  90.  
  91. public plugin_init()
  92. {
  93.     register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")
  94.    
  95.     // Hook Chains
  96.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  97.  
  98.     Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)
  99.    
  100.     // Cvars
  101.     g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "0")
  102.     g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "100")
  103.     g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")
  104.     g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "1000.0")
  105.     g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")
  106.     g_pCvarStartXP = register_cvar("ze_start_xp", "50")
  107.     g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.3")
  108.     g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "100")
  109.     g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "0")
  110.     g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")
  111.     g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
  112.     g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")
  113.     g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")
  114.     g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")
  115.     g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")
  116.     g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")
  117.     g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")
  118.    
  119.     // Messages
  120.     g_MsgSync = CreateHudSyncObj()
  121.  
  122.     if (get_pcvar_num(g_pCvarSaveType))
  123.     {
  124.         set_task(0.1, "Delay_MySQL_Init")
  125.     }
  126. }
  127.  
  128. public plugin_end()
  129. {
  130.     if (get_pcvar_num(g_pCvarSaveType))
  131.     {
  132.         if (g_hTuple != Empty_Handle)
  133.         {
  134.             SQL_FreeHandle(g_hTuple)
  135.         }
  136.     }
  137. }
  138.  
  139. public Delay_MySQL_Init()
  140. {
  141.     MySQL_Init()
  142. }
  143.  
  144. public MySQL_Init()
  145. {
  146.     if (!get_pcvar_num(g_pCvarSaveType))
  147.         return
  148.    
  149.     new szHost[64], szUser[32], szPass[32], szDB[128]
  150.    
  151.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  152.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  153.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  154.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  155.    
  156.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  157.    
  158.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  159.     new iErrorCode, szError[512], Handle:hSQLConnection
  160.    
  161.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  162.    
  163.     if (hSQLConnection != Empty_Handle)
  164.     {
  165.         log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
  166.         SQL_FreeHandle(hSQLConnection)
  167.     }
  168.     else
  169.     {
  170.         // Disable plugin
  171.         set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
  172.     }
  173.    
  174.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  175. }
  176.  
  177. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  178. {
  179.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  180. }
  181.  
  182. public client_putinserver(id)
  183. {
  184.     if(is_user_hltv(id) || is_user_bot(id))
  185.         return
  186.    
  187.     // Just 1 second delay
  188.     set_task(1.0, "DelayLoad", id)
  189.  
  190.     // Other tasks
  191.     set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
  192.     set_task(0.1, "Check_MaxXP", id, _, _, "b")
  193. }
  194.  
  195. public DelayLoad(id)
  196. {
  197.     // Load his data
  198.     LoadData(id)
  199. }
  200.  
  201. public client_disconnected(id)
  202. {
  203.     if(is_user_hltv(id) || is_user_bot(id))
  204.         return
  205.        
  206.     remove_task(id+TASK_SHOWHUD)
  207.     remove_task(id)
  208. }
  209.  
  210. public Check_MaxXP(id)
  211. {
  212.     new iCurrentMaxXP = g_iMaxXP[id]
  213.    
  214.     new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  215.    
  216.     for (new i = 1; i <= g_iLevel[id]; i++)
  217.     {
  218.         iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  219.     }
  220.    
  221.     if (iCurrentMaxXP != iMaxXP)
  222.     {
  223.         g_iMaxXP[id] = iMaxXP
  224.     }
  225. }
  226.  
  227. public Show_Hud(taskid)
  228. {  
  229.     new iPlayer = ID_SHOWHUD
  230.    
  231.     if (!is_user_alive(iPlayer))
  232.     {
  233.         iPlayer = pev(iPlayer, pev_iuser2)
  234.        
  235.         if (!is_user_alive(iPlayer))
  236.             return
  237.     }
  238.    
  239.     if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
  240.     {
  241.         if(iPlayer != ID_SHOWHUD)
  242.         {
  243.             set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  244.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
  245.         }
  246.         else if (ze_is_user_zombie(iPlayer))
  247.         {
  248.             set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  249.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  250.         }
  251.         else
  252.         {
  253.             set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  254.             ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
  255.         }
  256.     }
  257.     else
  258.     {
  259.         if(iPlayer != ID_SHOWHUD)
  260.         {
  261.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  262.             {
  263.                 new szSpecXP[15], szSpecMaxXP[15]
  264.                
  265.                 AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
  266.                 AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
  267.                
  268.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  269.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
  270.             }
  271.             else
  272.             {
  273.                 set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  274.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
  275.             }  
  276.         }
  277.         else if (ze_is_user_zombie(iPlayer))
  278.         {
  279.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  280.             {
  281.                 new szZombieXP[15], szZombieMaxXP[15]
  282.                
  283.                 AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
  284.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
  285.                
  286.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  287.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
  288.             }
  289.             else
  290.             {
  291.                 set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  292.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  293.             }
  294.         }
  295.         else
  296.         {
  297.             if (get_pcvar_num(g_pCvarAddCommas) == 1)
  298.             {
  299.                 new szHumanXP[15], szHumanMaxXP[15]
  300.                
  301.                 AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
  302.                 AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
  303.                
  304.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  305.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
  306.             }
  307.             else
  308.             {
  309.                 set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
  310.                 ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
  311.             }
  312.         }
  313.     }
  314. }
  315.  
  316. public ze_roundend(WinTeam)
  317. {
  318.     if (WinTeam == ZE_TEAM_HUMAN)
  319.     {
  320.         for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  321.         {
  322.             if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
  323.                 continue
  324.            
  325.             g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
  326.             SaveData(id)
  327.             Check_User_Level(id)
  328.         }
  329.     }
  330.    
  331.     remove_task(TASK_SHOWHUD)
  332. }
  333.  
  334. public Check_User_Level(id)
  335. {
  336.     if(!is_user_connected(id))
  337.         return
  338.  
  339.     if(g_iXP[id] >= g_iMaxXP[id])
  340.     {
  341.         if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  342.         {
  343.             g_iXP[id] = 0
  344.         }
  345.        
  346.         new szName[32]
  347.         g_iLevel[id] ++
  348.        
  349.         g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
  350.         get_user_name(id, szName, charsmax(szName))
  351.         ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
  352.         ExecuteForward(Fw_LevelUP, ForwardReturn, id)
  353.        
  354.         SaveData(id)
  355.        
  356.         PlaySound(id, LEVELUP)
  357.        
  358.         if (get_pcvar_num(g_pCvarLevelEffects) != 0)
  359.         {
  360.             // Screen Fade
  361.             message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
  362.             write_short(4096*2)
  363.             write_short(4096*5)
  364.             write_short(0x0001)
  365.             write_byte(random(256))
  366.             write_byte(random(256))
  367.             write_byte(random(256))
  368.             write_byte(150)
  369.             message_end()
  370.            
  371.             // Screen Shake
  372.             message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
  373.             write_short(255<<14)
  374.             write_short(10<<14)
  375.             write_short(255<<14)
  376.             message_end()
  377.         }
  378.     }
  379. }
  380.  
  381. public ze_user_infected(iVictim, iInfector)
  382. {
  383.     if (iInfector == 0)
  384.         return
  385.    
  386.     g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
  387.     SaveData(iInfector)
  388.     Check_User_Level(iInfector)
  389. }
  390.  
  391. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  392. {
  393.     // Player Damage Himself
  394.     if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
  395.         return HC_CONTINUE
  396.    
  397.     // Same Team?
  398.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  399.         return HC_CONTINUE
  400.    
  401.     // Store Damage For every Player
  402.     g_fDamage[iAttacker] += fDamage
  403.    
  404.     // Damage Calculator Equal or Higher than needed damage
  405.     if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
  406.     {
  407.         // Give Player The Coins
  408.         g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
  409.         SaveData(iAttacker)
  410.         Check_User_Level(iAttacker)
  411.        
  412.         // Rest The Damage Calculator
  413.         g_fDamage[iAttacker] = 0.0
  414.     }
  415.     return HC_CONTINUE
  416. }
  417.  
  418. public SaveData(id)
  419. {
  420.     new szAuthID[35], szName[32]
  421.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  422.     get_user_name(id, szName, charsmax(szName))
  423.    
  424.     // Set Him to max if he Higher than Max Value
  425.     if (g_iLevel[id] > MAX_LEVEL)
  426.     {
  427.         g_iLevel[id] = MAX_LEVEL
  428.     }
  429.    
  430.     if (g_iXP[id] > MAX_XP)
  431.     {
  432.         g_iXP[id] = MAX_XP
  433.     }
  434.  
  435.     if (!get_pcvar_num(g_pCvarSaveType))
  436.     {
  437.         new szData[256]
  438.         formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
  439.        
  440.         // Open the Vaults
  441.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  442.         g_iRanksVaultHandle = nvault_open(g_szRanksVault)
  443.  
  444.         // Saves His Data
  445.         nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
  446.         nvault_set(g_iRanksVaultHandle, szAuthID, szName)
  447.        
  448.         // Close Vaults
  449.         nvault_close(g_iLevelsVaultHandle)
  450.         nvault_close(g_iRanksVaultHandle)
  451.     }
  452.     else
  453.     {
  454.         new szQuery[128]
  455.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
  456.         SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
  457.     }
  458. }
  459.  
  460. public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  461. {
  462.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  463. }
  464.  
  465. public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  466. {
  467.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  468. }
  469.  
  470. public LoadData(id)
  471. {
  472.     new szData[256], szAuthID[35]
  473.    
  474.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  475.    
  476.     if (!get_pcvar_num(g_pCvarSaveType))
  477.     {
  478.         // Useless Variable
  479.         new iTimestamp, iExists
  480.        
  481.         // Open the Vault
  482.         g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
  483.        
  484.         iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  485.        
  486.         // Close Vault
  487.         nvault_close(g_iLevelsVaultHandle)
  488.        
  489.         if (!iExists)
  490.         {
  491.             g_iLevel[id] = 0
  492.             g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
  493.             g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  494.             SaveData(id)
  495.         }
  496.         else
  497.         {
  498.             new iLevel[32], iXP[32], iMaxLevel[32]
  499.             parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
  500.            
  501.             g_iLevel[id] = str_to_num(iLevel)
  502.             g_iXP[id] = str_to_num(iXP)
  503.             g_iMaxXP[id] = str_to_num(iMaxLevel)
  504.         }
  505.     }
  506.     else
  507.     {
  508.         new szQuery[128], szData[5]
  509.         formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)
  510.      
  511.         num_to_str(id, szData, charsmax(szData))
  512.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  513.     }
  514. }
  515.  
  516. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  517. {
  518.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  519.         return
  520.    
  521.     new id = str_to_num(szData)
  522.    
  523.     // No results for this query means this is new player
  524.     if (!SQL_NumResults(hQuery))
  525.     {
  526.         new szSteamId[36], szQuery[128]
  527.         get_user_authid(id, szSteamId, charsmax(szSteamId))
  528.  
  529.         g_iLevel[id] = 0
  530.         g_iXP[id] = 0
  531.         g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
  532.         return
  533.     }
  534.  
  535.     g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))
  536.     g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))
  537.     g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))
  538. }
  539.  
  540. public native_ze_get_user_xp(id)
  541. {
  542.     if(!is_user_connected(id))
  543.     {
  544.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  545.         return false;
  546.     }
  547.    
  548.     return g_iXP[id]
  549. }
  550.  
  551. public native_ze_set_user_xp(id, amount)
  552. {
  553.     if(!is_user_connected(id))
  554.     {
  555.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  556.         return false;
  557.     }
  558.    
  559.     g_iXP[id] = amount
  560.    
  561.     Check_User_Level(id)
  562.     return true;
  563. }
  564.  
  565. public native_ze_get_user_level(id)
  566. {
  567.     if(!is_user_connected(id))
  568.     {
  569.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  570.         return false;
  571.     }
  572.    
  573.     return g_iLevel[id]
  574. }
  575.  
  576. public native_ze_set_user_level(id, amount)
  577. {
  578.     if(!is_user_connected(id))
  579.     {
  580.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  581.         return false;
  582.     }
  583.    
  584.     g_iLevel[id] = amount
  585.    
  586.     if (get_pcvar_num(g_pCvarStartFromZero) == 1)
  587.     {
  588.         g_iXP[id] = 0
  589.     }
  590.    
  591.     return true;
  592. }
  593.  
  594. public native_ze_get_user_max_xp(id)
  595. {
  596.     if(!is_user_connected(id))
  597.     {
  598.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  599.         return false;
  600.     }
  601.    
  602.     return g_iMaxXP[id]
  603. }
  604.  
  605. public native_ze_set_user_max_xp(id, amount)
  606. {
  607.     if(!is_user_connected(id))
  608.     {
  609.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  610.         return false;
  611.     }
  612.    
  613.     g_iMaxXP[id] = amount
  614.     return true;
  615. }
post ur ze.cfg file
my zombie_escpe.cfg is
  1. // Zombie Escape Configuration File
  2. // You can edit anything here and it will effcet your server when you Restart it
  3.  
  4. // Humans
  5. ze_human_speed_factor 20.0      // Human Speed Factor, Will be added to his weapon speed.
  6. ze_human_gravity 800            // Human Gravity
  7. ze_human_health 300         // Human HP
  8.  
  9. // Zombies
  10. ze_zombie_speed 300.0               // Zombie Speed
  11. ze_zombie_gravity 640               // Zombie Gravity
  12. ze_first_zombies_health 40000       // First Zombies Health
  13. ze_zombie_health 20000              // Zombie Health
  14. ze_zombie_knockback 300.0           // Zombie Knockback
  15. ze_zombie_nightvision 1             // Allow Night Vision for Zombie (0 = Disabled || 1 = Enabled)
  16. ze_zombie_auto_nightvision 1        // Automatic Enable Night Vision On Infection (0 = Disabled || 1 = Enabled)
  17. ze_zombie_nightvision_density 70    // Night Vision Density
  18. ze_zombie_nvision_red 253           // Night Vision Red Color
  19. ze_zombie_nvision_green 110         // Night Vision Green Color
  20. ze_zombie_nvision_blue 110          // Night Vision Blue Color
  21.  
  22. // General
  23. ze_lighting_style d        // Map Light Style Range from a to z(a = Very Dark || z = Normal Light)
  24. ze_release_time 15         // Time to freeze zombie(s)
  25. ze_freeze_time 20          // Time to freeze all players
  26. ze_round_time 9.0          // Round Time
  27. ze_block_kill 1            // Block Kill Command
  28. ze_required_players 1      // Required players to start the game
  29. ze_human_infected_frags 1  // Frags that Zombie Will earn when infecting Human
  30. ze_infection_deaths 1      // Deaths that will be added to Infected Human when he Infected
  31. ze_escape_success_frags 3  // Frags that will Alive humans Earn if they escaped
  32. ze_block_money_hud 1       // Block HUD money message
  33. ze_block_radar_ap_hp 0     // Block Radar, Armor and Health HUD messages
  34. ze_round_end_delay 5       // Delay the round end by this time in seconds.
  35.  
  36. // Messages
  37. ze_enable_infect_notice 1       // Infect Hud Message (0 = Disabled || 1 = Enabled)
  38. ze_infect_notice_red 255        // Infection Message Red Color
  39. ze_infect_notice_green 0        // Infection Message Green Color
  40. ze_infect_notice_blue 0         // Infection Message Blue Color
  41. ze_score_message_type 1         // Type of the Score Message (0 = Disabled || 1 = dhud || 2 = hud)
  42. ze_score_message_red 200        // Score Message Red Color
  43. ze_score_message_green 100      // Score Message Green Color
  44. ze_score_message_blue 0         // Score Message Blue Color
  45. ze_speed_rank_mode 2            // Rank Message (0 = Disabled || 1 = Leader Mode || 2 = Rank Mode)
  46. ze_speed_rank_red 0             // Rank Message Color Red (For Both Leader & Normal one)
  47. ze_speed_rank_green 230         // Rank Message Color Green (For Both Leader & Normal one)
  48. ze_speed_rank_blue 255          // Rank Message Color Blue (For Both Leader & Normal one)
  49. ze_leader_glow 0                // Glow For Leader Mode (0 = Disabled || 1 = Enabled)
  50. ze_leader_random_color 1        // If you enable this the glow color will be randomly if disabled it will take RGB colors you set
  51. ze_leader_glow_red 255          // Glow Red Color
  52. ze_leader_glow_green 0          // Glow Green Color
  53. ze_leader_glow_blue 0           // Glow Blue Color
  54. ze_hud_info_mode 1              // Player Hud Information like HP, Class, Escape Coins (0 = Disabled || 1 = Hud || 2 = Dhud)
  55. ze_hud_info_commas 1            // Enable Commas To HP (0 = Disabled || 1 = Enabled)
  56. ze_hud_info_zombie_red 255      // Zombie Information Red Color
  57. ze_hud_info_zombie_green 60     // Zombie Information Green Color
  58. ze_hud_info_zombie_blue 60      // Zombie Information Blue Color
  59. ze_hud_info_human_red 60        // Human Information Red Color
  60. ze_hud_info_human_green 60      // Human Information Green Color
  61. ze_hud_info_human_blue 255      // Human Information Blue Color
  62. ze_hud_info_spec_red 100        // Spectators Information Red Color
  63. ze_hud_info_spec_green 100      // Spectators Information Green Color
  64. ze_hud_info_spec_blue 100       // Spectators Information Blue Color
  65. ze_earn_chat_notice 1           // Earn Chat Notice Like: +30 Escape Coins (0 = Disabled || 1 = Enabled)
  66.  
  67. // Escape Coins system
  68. ze_coins_save_type 0       // Where to save? (0 = nVault | 1 = MySQL)
  69. ze_escape_success_coins 100 // Coins Alive humans earn on Escape Success
  70. ze_human_infected_coins 15  // Coins Zombie Earn when infect humans
  71. ze_damage_coins 3          // Coins human take when he make X damage to zombies
  72. ze_damage_required 1000     // X Damage required so player earn ze_damage_coins
  73. ze_start_coins 500          // Coins that will given to new players
  74. ze_max_coins 50000        // Max coins can player hold in his account
  75.  
  76. // Escape Coins MySQL Information (Needed only if you used MySQL)
  77. ze_ec_host "localhost"          // Database ip
  78. ze_ec_user "username"           // Database account username
  79. ze_ec_pass "password"           // Database account password
  80. ze_ec_dbname "database name"    // Database name
  81.  
  82. // Weapons
  83. ze_buy_time 60             // Time after it the player will not be able to use Weapon Menu
  84. ze_give_HE_nade 1          // Give HE Grenade Automatically
  85. ze_give_SM_nade 1          // Give Smoke Grenade Automatically
  86. ze_give_FB_nade 1          // Give Flashbang Grenade Automatically
  87.  
  88. // Madness
  89. ze_madness_time 5.0        // Madness Time for Zombies
  90. ze_madness_color_red 255   // Madness Aura Red Color
  91. ze_madness_color_green 0   // Madness Aura Green Color
  92. ze_madness_color_blue 0    // Madness Aura Blue Color
  93.  
  94. // Fire Nade
  95. ze_fire_duration 6         // Fire Nade burning time
  96. ze_fire_damage 10          // Fire Nade Damage every second
  97. ze_fire_hud_icon 1         // Fire Icon appear when player is being burn (0 = Disabled || 1 = Enabled)
  98. ze_fire_explosion 0        // Keep the normal Explosion (0 = Disabled || 1 = Enabled)
  99. ze_fire_slowdown 0.1       // Slowdown when player being burn
  100. ze_fire_radius 240.0       // Fire Nade explosion radius
  101. ze_fire_hit_type 0         // 0 = Fire can pass through walls | 1 = Fire nade must see zombie to fire him (can't pass walls)
  102.  
  103. // Frost Nade
  104. ze_frost_duration 4        // Frost Nade Freeze Duaration
  105. ze_frost_hud_icon 1        // Frost Nade Icon while frozen (0 = Disabled || 1 = Enabled)
  106. ze_freeze_damage 0         // Allow zombie take damage while frozen? (0 = No Damage || 1 = Take Damage)
  107. ze_freeze_radius 240.0     // Frost Nade explosion Radius
  108. ze_freeze_hit_type 0       // 0 = Frost can pass through walls | 1 = Frost nade must see zombie to fire him (can't pass walls)
  109.  
  110. // Server
  111. mp_autoteambalance 0      // Stop Automatic Balancing (game.cfg)
  112. mp_roundover 0            // Must be 0 (game.cfg)
  113. mp_round_infinite 0       // Must be 0 (game.cfg)
  114. mp_roundrespawn_time 30   // Time that player can respawn as zombie if zombie chosen (game.cfg)
  115. sv_maxspeed 400           // Set this more than zombie speed (server.cfg)
  116. mp_roundtime 9.0          // Set this same as ze_round_time cvar (server.cfg)
  117. mp_freezetime 20          // Set this same as ze_freeze_time cvar (server.cfg)
  118.  
  119. // Extra-Plugins Cvars
  120. ze_shield_time 10               // Force Shield nade time in seconds
  121. ze_break_hint_type 2            // Break hint type 2 = Center Chat | 1 = HUD
  122. ze_tank_gun_team 1              // Tank gun: 0 = Disabled for all | 1 = Disabled for zombies | 2 = Disabled for humans
  123. parachute_fallspeed 75          // Parachute fall speed? Max 100
  124. nademodes_motion_enabled 0      // Disable Motion Mod (Not Needed in ZombieEscape).
  125. nademodes_satchel_enabled 0     // Disable Stachel Mod (Not Needed in ZombieEscape).
  126. nademodes_proximity_limit 10    // You can set as you want.
  127. nademodes_trip_limit 10         // You can set as you want.
  128. ze_freezing_m4a1_damage 500     // Damage required then zombie get freeze?
  129. ze_multiplier_m4a1_damage 2     // Multiple the Frost M4A1 Damage by? [Integer Factor, 1 or 2 and so on]
  130. stunrifle_barfill_time 5        // The time in seconds that needed for every bar to be filled. There are 6 bars.
  131. stunrifle_radius 500            // The electricity beam will effect players in this radius while you reloading.
  132. stunrifle_electricity_dmg 10    //  The 1 bar electricity damage is 10, If it's 2 bars the damage is 20 if 3 bars damage is 30 and so on.
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#145

Post by VicKy » 2 years ago

Please Fix The Mysql On Both
Maxx-Xp
No-Maxxp
Image

soumyadip77
Member
Member
India
Posts: 13
Joined: 6 years ago
Contact:

#146

Post by soumyadip77 » 2 years ago

I was looking to the nomaxx code where i found something confusing can anyone tell me why it is here and why

Code: Select all

new const g_szTable[] =
" \
	ALTER TABLE `test` \
	ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
"
here it is creating table right using this code

Code: Select all

public MySQL_Init()
{
	if (!get_pcvar_num(g_pCvarSaveType))
		return

	new szHost[64], szUser[32], szPass[32], szDB[128]

	get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
	get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
	get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
	get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))

	g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)

	// Let's ensure that the g_hTuple will be valid, we will access the database to make sure
	new iErrorCode, szError[512], Handle:hSQLConnection

	hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))

	if (hSQLConnection != Empty_Handle)
	{
		log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
		SQL_FreeHandle(hSQLConnection)
	}
	else
	{
		// Disable plugin
		set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
	}

	SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}

public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
	SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
but while saving there is no link to this DB. it is updating on the ze coin system DB.

Code: Select all

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))

	// Set Him to max if he Higher than Max Value
	if (g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}

	if (g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		new szData[256]
		formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])

		// Open the Vaults
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
		g_iRanksVaultHandle = nvault_open(g_szRanksVault)

		// Saves His Data
		nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
		nvault_set(g_iRanksVaultHandle, szAuthID, szName)

		// Close Vaults
		nvault_close(g_iLevelsVaultHandle)
		nvault_close(g_iRanksVaultHandle)
	}
	else
	{
		new szQuery[128]
		formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
		SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
	}
}
also while loading Level it is using same ze coin system DB

Code: Select all

public LoadData(id)
{
	new szData[256], szAuthID[35]

	get_user_authid(id, szAuthID, charsmax(szAuthID))

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		// Useless Variable
		new iTimestamp, iExists

		// Open the Vault
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)

		iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)

		// Close Vault
		nvault_close(g_iLevelsVaultHandle)

		if (!iExists)
		{
			g_iLevel[id] = 0
			g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
			g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
			SaveData(id)
		}
		else
		{
			new iLevel[32], iXP[32], iMaxLevel[32]
			parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)

			g_iLevel[id] = str_to_num(iLevel)
			g_iXP[id] = str_to_num(iXP)
			g_iMaxXP[id] = str_to_num(iMaxLevel)
		}
	}
	else
	{
		new szQuery[128], szData[5]
		formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)

		num_to_str(id, szData, charsmax(szData))
		SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
	}
}
btw i am talking about SQL not nvault

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#147

Post by z0h1r-LK » 2 years ago

soumyadip77 wrote: 2 years ago I was looking to the nomaxx code where i found something confusing can anyone tell me why it is here and why

Code: Select all

new const g_szTable[] =
" \
	ALTER TABLE `test` \
	ADD IF NOT EXISTS `Level` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `XP` int(20) NOT NULL DEFAULT '0', \
	ADD IF NOT EXISTS `Max_XP` int(20) NOT NULL DEFAULT '0'; \
"
here it is creating table right using this code

Code: Select all

public MySQL_Init()
{
	if (!get_pcvar_num(g_pCvarSaveType))
		return

	new szHost[64], szUser[32], szPass[32], szDB[128]

	get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
	get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
	get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
	get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))

	g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)

	// Let's ensure that the g_hTuple will be valid, we will access the database to make sure
	new iErrorCode, szError[512], Handle:hSQLConnection

	hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))

	if (hSQLConnection != Empty_Handle)
	{
		log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)
		SQL_FreeHandle(hSQLConnection)
	}
	else
	{
		// Disable plugin
		set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)
	}

	SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
}

public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
{
	SQL_IsFail(iFailState, iError, szError, g_szLogFile)
}
but while saving there is no link to this DB. it is updating on the ze coin system DB.

Code: Select all

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))

	// Set Him to max if he Higher than Max Value
	if (g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}

	if (g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		new szData[256]
		formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])

		// Open the Vaults
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
		g_iRanksVaultHandle = nvault_open(g_szRanksVault)

		// Saves His Data
		nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
		nvault_set(g_iRanksVaultHandle, szAuthID, szName)

		// Close Vaults
		nvault_close(g_iLevelsVaultHandle)
		nvault_close(g_iRanksVaultHandle)
	}
	else
	{
		new szQuery[128]
		formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)
		SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)
	}
}
also while loading Level it is using same ze coin system DB

Code: Select all

public LoadData(id)
{
	new szData[256], szAuthID[35]

	get_user_authid(id, szAuthID, charsmax(szAuthID))

	if (!get_pcvar_num(g_pCvarSaveType))
	{
		// Useless Variable
		new iTimestamp, iExists

		// Open the Vault
		g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)

		iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)

		// Close Vault
		nvault_close(g_iLevelsVaultHandle)

		if (!iExists)
		{
			g_iLevel[id] = 0
			g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
			g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
			SaveData(id)
		}
		else
		{
			new iLevel[32], iXP[32], iMaxLevel[32]
			parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)

			g_iLevel[id] = str_to_num(iLevel)
			g_iXP[id] = str_to_num(iXP)
			g_iMaxXP[id] = str_to_num(iMaxLevel)
		}
	}
	else
	{
		new szQuery[128], szData[5]
		formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)

		num_to_str(id, szData, charsmax(szData))
		SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
	}
}
btw i am talking about SQL not nvault
plugin is support MySQL!, You can save level in MySQL DB

soumyadip77
Member
Member
India
Posts: 13
Joined: 6 years ago
Contact:

#148

Post by soumyadip77 » 2 years ago

but code looks not good

atilla_be
Member
Member
Belgium
Posts: 5
Joined: 2 years ago
Contact:

#149

Post by atilla_be » 2 years ago

Code: Select all

AMX Mod X Compiler 1.10.0.5445
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

ze_level_system.sma(25) : error 018: initialization data exceeds declared size
ze_level_system.sma(512) : warning 204: symbol is assigned a value that is never used: "szQuery"

1 Error.
Could not locate output file ze_level_system.amx (compile failed).
console

Code: Select all

L 11/17/2021 - 12:33:22: [AMXX] Plugin "ze_items_level.amxx" failed to load: Plugin uses an unknown function (name "ze_get_user_level") - check your modules.ini.

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#150

Post by z0h1r-LK » 2 years ago

atilla_be wrote: 2 years ago

Code: Select all

AMX Mod X Compiler 1.10.0.5445
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

ze_level_system.sma(25) : error 018: initialization data exceeds declared size
ze_level_system.sma(512) : warning 204: symbol is assigned a value that is never used: "szQuery"

1 Error.
Could not locate output file ze_level_system.amx (compile failed).
console

Code: Select all

L 11/17/2021 - 12:33:22: [AMXX] Plugin "ze_items_level.amxx" failed to load: Plugin uses an unknown function (name "ze_get_user_level") - check your modules.ini.
sent me .sma

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests