This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Zombie Plague: How to make AmmoPack rewards float?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZarZar
New Member
Join Date: Nov 2023
Location: Germany
Old 11-04-2023 , 11:36   Zombie Plague: How to make AmmoPack rewards float?
Reply With Quote #1

Hi Guys,
is it possible to make Ammo Packs float System?
Example: when player cause 400 hit damage to other player(Zombie) the default Ammo Pack reward is (1 AP)
-how can i make AP reward float (0.1 AP)?

Last edited by ZarZar; 11-04-2023 at 14:48.
ZarZar is offline
Leech_v2
Senior Member
Join Date: Mar 2011
Location: Chinese GuangDong
Old 11-04-2023 , 14:48   Re: Zombie Plague: How to make AmmoPack rewards float?
Reply With Quote #2

Add Float: tags to all functions, variables, constants, array, parameters, args related to it, and change all integer literals to floating-point literal literals.Replace all functions that return integers with floating point numbers.
In all ZP source code and header file.

like this:
PHP Code:
//new db_ammopacks[33]
new Float:db_ammopacks[33]
//new g_ammopacks[33] // ammo pack count
new Float:g_ammopacks[33// ammo pack count
//g_ammopacks[attacker] += get_pcvar_num(cvar_ammoinfect)
g_ammopacks[attacker] += get_pcvar_float(cvar_ammoinfect)
//if (g_ammopacks[id] < 1)
if (g_ammopacks[id] <= 0.0)
//if (g_ammopacks[id] < ArrayGetCell(g_extraitem_cost, itemid))
if (g_ammopacks[id] < Float:ArrayGetCell(g_extraitem_costitemid))
//g_ammopacks[id] -= ArrayGetCell(g_extraitem_cost, itemid)
g_ammopacks[id] -= Float:ArrayGetCell(g_extraitem_costitemid)
//"%d", g_ammopacks
"%f"g_ammopacks
//static function()return g_ammopacks
static Float:function()return g_ammopacks
//static function(id, amount) g_ammopacks[id] = amount
static function(idFloat:amountg_ammopacks[id] = amount
//const ItemCost = 10
const Float:ItemCost 10.0 
The calculation of floating point numbers has errors. The farther the value is from 0, the greater the error. Therefore, it is not recommended to use floating point numbers.

You can divide an integer by ten and display it as a floating-point number in Hud to preserve a certain degree of accuracy

such as:

1000 is displayed as 100.0-- "%. 1f", float (1000)/10.0

1005 is displayed as 100.5-- "%. 1f", float (1005)/10.0
Leech_v2 is offline
Old 11-04-2023, 16:01
ZarZar
This message has been deleted by ZarZar.
ZarZar
New Member
Join Date: Nov 2023
Location: Germany
Old 11-04-2023 , 16:05   Re: Zombie Plague: How to make AmmoPack rewards float?
Reply With Quote #3

Quote:
Originally Posted by Leech_v2 View Post
Add Float: tags to all functions, variables, constants, array, parameters, args related to it, and change all integer literals to floating-point literal literals.Replace all functions that return integers with floating point numbers.
In all ZP source code and header file.

like this:
PHP Code:
//new db_ammopacks[33]
new Float:db_ammopacks[33]
//new g_ammopacks[33] // ammo pack count
new Float:g_ammopacks[33// ammo pack count
//g_ammopacks[attacker] += get_pcvar_num(cvar_ammoinfect)
g_ammopacks[attacker] += get_pcvar_float(cvar_ammoinfect)
//if (g_ammopacks[id] < 1)
if (g_ammopacks[id] <= 0.0)
//if (g_ammopacks[id] < ArrayGetCell(g_extraitem_cost, itemid))
if (g_ammopacks[id] < Float:ArrayGetCell(g_extraitem_costitemid))
//g_ammopacks[id] -= ArrayGetCell(g_extraitem_cost, itemid)
g_ammopacks[id] -= Float:ArrayGetCell(g_extraitem_costitemid)
//"%d", g_ammopacks
"%f"g_ammopacks
//static function()return g_ammopacks
static Float:function()return g_ammopacks
//static function(id, amount) g_ammopacks[id] = amount
static function(idFloat:amountg_ammopacks[id] = amount
//const ItemCost = 10
const Float:ItemCost 10.0 
The calculation of floating point numbers has errors. The farther the value is from 0, the greater the error. Therefore, it is not recommended to use floating point numbers.

You can divide an integer by ten and display it as a floating-point number in Hud to preserve a certain degree of accuracy

such as:

1000 is displayed as 100.0-- "%. 1f", float (1000)/10.0

1005 is displayed as 100.5-- "%. 1f", float (1005)/10.0
==================================

wow looks useful tutorial
AmmoPack system was an Example, actuly i want add Float to 'Gold System' if u edite the main code and make it Float for me, it will be a big favor.. i have uploaded Gold sys files.
Attached Files
File Type: zip gold_sys.zip (43.0 KB, 17 views)

Last edited by ZarZar; 11-04-2023 at 16:22.
ZarZar is offline
Reply



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

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

Forum Jump


All times are GMT -4. The time now is 13:21.


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