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

about percentage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fearmelfice
Junior Member
Join Date: Apr 2012
Old 06-24-2012 , 07:56   about percentage
Reply With Quote #1

help me, i want to make a hud message which announce me when the clip is 50% and 10%
but i dont know what script i must write?

thanks, sorry if my english bad
fearmelfice is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-24-2012 , 14:22   Re: about percentage
Reply With Quote #2

I give you concept and links to function wikis you will need. But you're gonna have to write the code yourself. or go to the request section.

CreateHudSyncObj() http://www.amxmodx.org/funcwiki.php?go=func&id=1064
new weapon = cs_get_user_weapon(id) http://www.amxmodx.org/funcwiki.php?go=func&id=738
http://www.amxmodx.org/funcwiki.php?go=func&id=207
new Float:percent = (cs_get_weapon_ammo(id) / clipSize[weapon]) * 100 //This will get % of clip left
if(percent == 50 || percent == 10)
show_hudmessage(id, "Your clip is at ^%%d!", percent)
http://www.amxmodx.org/funcwiki.php?go=func&id=29

NOTE: clipSize you'll have to write yourself. It'll be an array of the clip size of that weapon. i.e. CSW_M4A1 = 30, CSW_FAMAS = 25, CSW_M249 = 100 etc etc
PHP Code:
new clip clipSize[CSW_M4A1]    //clip will then equal 30 
put it all in a weapon fire hook. so it gets run after each shot. (not sure what you'd want to use for that)

Know what? I actually think i'll have fun writing this. So i might even do it for you, if you need. But i don't have time today. So if you're willing to wait untill tomorrow or something, PM me and i'll get it for you when i can. Otherwise, if you can't write it (it should be real simple) just post in request.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-24-2012 at 14:24.
Liverwiz is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-24-2012 , 18:13   Re: about percentage
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
show_hudmessage(id, "Your clip is at ^%%d!", percent)
This won't work. That will display:

PHP Code:
Your clip is at %d
%% Means that the second % will be used as an unformatted character in the string.

Use:

PHP Code:
show_hudmessage(id"Your clip is at %%%d!"percent
And best way to hook weapon fire is http://forums.alliedmods.net/showthread.php?t=54887
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-24-2012 , 18:19   Re: about percentage
Reply With Quote #4

Quote:
Originally Posted by hornet View Post
Use:
PHP Code:
show_hudmessage(id"Your clip is at %%%d!"percent
Better
PHP Code:
show_hudmessage(id"Your clip is at %d%%!"percent
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-24-2012 , 18:32   Re: about percentage
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
Better
PHP Code:
show_hudmessage(id"Your clip is at %d%%!"percent
Is that by opinion or American standard? Haha :p I though % symbols usually come before the number ( regardless of pronounciation )
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-24-2012 at 18:33.
hornet is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-24-2012 , 19:08   Re: about percentage
Reply With Quote #6

Quote:
Originally Posted by hornet View Post
Is that by opinion or American standard? Haha :p I though % symbols usually come before the number ( regardless of pronounciation )
Well, his original post had it behind the number, so you would think he would want it displayed that way regardless of how different countries display it
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
fearmelfice
Junior Member
Join Date: Apr 2012
Old 06-24-2012 , 19:08   Re: about percentage
Reply With Quote #7

ummm... i will try it by myself first, but if i'm failed, i will go to request section

ok thanks to you all
fearmelfice is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-24-2012 , 19:57   Re: about percentage
Reply With Quote #8

Quote:
Originally Posted by YamiKaitou View Post
Well, his original post had it behind the number, so you would think he would want it displayed that way regardless of how different countries display it
I see



Also, fearmelfice, I forgot to mention, use floatround() rather than defining percent as a float.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
fearmelfice
Junior Member
Join Date: Apr 2012
Old 06-24-2012 , 20:03   Re: about percentage
Reply With Quote #9

okay hornet
fearmelfice is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-24-2012 , 21:16   Re: about percentage
Reply With Quote #10

Quote:
Originally Posted by Liverwiz View Post
new Float:percent = (cs_get_weapon_ammo(id) / clipSize[weapon]) * 100 //This will get % of clip left
if(percent == 50 || percent == 10)
You are performing integer division which will give you an integer (0 in this case). Also, you can never use the comparison operator (==) with floating point numbers.
__________________
fysiks 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 19:35.


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