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

Help Simplifying code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
point.blank
Member
Join Date: Oct 2007
Old 10-02-2008 , 00:35   Help Simplifying code
Reply With Quote #1

I'm trying to give players the ammo they need for the guns they will be given

is there any way to simplify this:
PHP Code:
            give_item(id"ammo_45acp")        //usp
            
give_item(id"ammo_45acp")
            
give_item(id"ammo_45acp")
            
give_item(id"ammo_45acp")
            
give_item(id"ammo_45acp")
            
give_item(id"ammo_45acp")
            
give_item(id"ammo_45acp")
            
give_item(id"ammo_45acp")
            
give_item(id"ammo_45acp")        //9
        
            
give_item(id"ammo_9mm")         //glock
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm"
            
give_item(id"ammo_9mm")         //12    
            
            
give_item(id"ammo_50ae")         //deagle
            
give_item(id"ammo_50ae"
            
give_item(id"ammo_50ae"
            
give_item(id"ammo_50ae"
            
give_item(id"ammo_50ae")         //5
        
            
give_item(id"ammo_762nato")         //ak47
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")         //3    
    
            
give_item(id"ammo_762nato")         //scout
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")     
            
give_item(id"ammo_762nato")         //9    
    
            
give_item(id"ammo_556nato")        //m4a1
            
give_item(id"ammo_556nato")
            
give_item(id"ammo_556nato")        //3
    
            
give_item(id"ammo_556nato")        //aug
            
give_item(id"ammo_556nato")    
            
give_item(id"ammo_556nato")        //3
            
            
give_item(id"ammo_338magnum")     //awp
            
give_item(id"ammo_338magnum"
            
give_item(id"ammo_338magnum")     //3
    
            
give_item(id"ammo_556natobox")     //para
            
give_item(id"ammo_556natobox"
            
give_item(id"ammo_556natobox"
            
give_item(id"ammo_556natobox"
            
give_item(id"ammo_556natobox"
            
give_item(id"ammo_556natobox"
            
give_item(id"ammo_556natobox")    //7 
I was thinking something like

PHP Code:
#define AMMO_USP 9

new USPAMMO[AMMO_USP][33]
{
         
"ammo_45acp",
         
"ammo_45acp",
         
"ammo_45acp",
         
"ammo_45acp",
         
"ammo_45acp",
         
"ammo_45acp",
         
"ammo_45acp",
         
"ammo_45acp",
         
"ammo_45acp"

Not exactly sure.
__________________

Last edited by point.blank; 10-02-2008 at 00:37.
point.blank is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 10-02-2008 , 00:55   Re: Help Simplifying code
Reply With Quote #2

this is one possibility but you could store all ammo string in an array for just one single loop if you are allways giving ammo for each weapon

example:
PHP Code:
for(new i9i++)
{
    
give_item(i"ammo_45acp");
}

for(new 
i12i++)
{
    
give_item(i"ammo_9mm");

__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-02-2008 , 01:03   Re: Help Simplifying code
Reply With Quote #3

Set bpammo would work.
http://www.amxmodx.org/funcwiki.php?...r_bp&go=search
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
point.blank
Member
Join Date: Oct 2007
Old 10-02-2008 , 01:15   Re: Help Simplifying code
Reply With Quote #4

Quote:
Originally Posted by SchlumPF* View Post
this is one possibility but you could store all ammo string in an array for just one single loop if you are allways giving ammo for each weapon

example:
PHP Code:
for(new i9i++)
{
    
give_item(i"ammo_45acp");
}

for(new 
i12i++)
{
    
give_item(i"ammo_9mm");

Not always giving the ammo

Quote:
Originally Posted by connorr View Post
oh man i forgot about that, should work, thanks
__________________
point.blank is offline
AcidoX
Senior Member
Join Date: Oct 2007
Location: Vilnius
Old 10-02-2008 , 07:03   Re: Help Simplifying code
Reply With Quote #5

Lol, use AmmoX event.
__________________
Who need lockerz invite? Pm me.
AcidoX is offline
Send a message via Skype™ to AcidoX
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-02-2008 , 07:35   Re: Help Simplifying code
Reply With Quote #6

Quote:
Originally Posted by AcidoX View Post
Lol, use AmmoX event.
uh ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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:15.


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