Raised This Month: $ Target: $400
 0% 

Global Message + Ammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MeNtAL MaNiAC
Junior Member
Join Date: Nov 2006
Old 06-25-2007 , 19:27   Global Message + Ammo
Reply With Quote #1

I have tried for over 4 hours to get this to work. What I'm trying to do is that when the person is randomly selected to be given a weapon, they get a certain ammount of ammo and a message is shown to all players. The person recieves the weapon, but no message is shown and they have a full clip. Help please!

PHP Code:
public SeekerItems(id) {
new 
rand random_num(1,10)
 
strip_user_weapons(id)
 
give_item(id"weapon_knife")
 switch(
rand) {
  case 
1giveusp(id)
  case 
3: { 
    
give_item(id"weapon_hegrenade")
    
client_print(idprint_chat"You got a HE Grenade!"
    }
  case 
4: { 
    
give_item(id"weapon_shield"
    
client_print(idprint_chat"You got a Shield!"
    }
  case 
7giveawp(id)
 }
 
cs_set_user_nvg(id)
 
set_user_footsteps(id,0)
}
//------------------------------------------------------------------------------------------------------------
public HiderItems(id) {
new 
rand random_num(1,10)
 
strip_user_weapons(id)
 
give_item(id"weapon_flashbang")
 
give_item(id"weapon_flashbang")
 
give_item(id"weapon_smokegrenade")
 
csset_user_armor(id100.02)
 switch(
rand) {
  case 
1giveusp(id)
  case 
3: { 
    
give_item(id"weapon_hegrenade")
    
client_print(idprint_chat"You got a HE Grenade!");
    }
  case 
4: { 
    
give_item(id"weapon_shield"
    
client_print(idprint_chat"You got a Shield!");
    }
  case 
7giveawp(id)
 }
 
cs_set_user_nvg(id0)
 
set_user_footsteps(id,1)
}
//------------------------------------------------------------------------------------------------------------
public giveusp(id) {
 new 
WeapEntIndex find_ent_by_owner(-1"weapon_usp"id0);
 
give_item(id"weapon_usp")
     
cs_set_weapon_ammo(WeapEntIndex2);
 
glbprint(id1)
}
//------------------------------------------------------------------------------------------------------------
public giveawp(id) {
 new 
WeapEntIndex find_ent_by_owner(-1"weapon_awp"id0);
 
give_item(id"weapon_awp")
     
cs_set_weapon_ammo(WeapEntIndex3);
 
glbprint(id2)
}
//------------------------------------------------------------------------------------------------------------
public csset_user_armor(idFloat:amounttype) {
 
entity_set_float(id,EV_FL_armorvalueamount)
 
set_pdata_int(id,ARMORTYPE_OFFSET,type
}
//------------------------------------------------------------------------------------------------------------
glbprint(idwep) {
 if(
wep == 1) {
  new 
name[32]
  
get_user_name(idname31)
  
client_print(0print_chat"%s now has a USP!"name)
 }
 if(
wep == 2) {
  new 
name[32]
  
get_user_name(idname31)
  
client_print(0print_chat"%s now has an AWP!"name)
 }


Last edited by MeNtAL MaNiAC; 06-25-2007 at 20:05.
MeNtAL MaNiAC is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 06-25-2007 , 19:45   Re: Global Message + Ammo
Reply With Quote #2

Your problem is that you're trying to look for those weapon indexes before you've actually given the gun to the user.

As it stands, the glbprint() function is completely pointless. Not only are the local variables in that function never used, but the client_print() calls in it can replace the glbprint() calls without problem.

Code:
public giveawp(id) {     give_item(id, "weapon_awp")     new WeapEntIndex = find_ent_by_owner(-1, "weapon_awp", id, 0)     cs_set_weapon_ammo(WeapEntIndex, 3)     new name[32]     get_user_name(id, name, 31)     client_print(0, print_chat, "%s now has an AWP with 3 bullets!", name) }
http://www.amxmodx.org/funcwiki.php?...name&go=search

In future please indent your code. ;)

Last edited by Lee; 06-25-2007 at 20:14.
Lee is offline
MeNtAL MaNiAC
Junior Member
Join Date: Nov 2006
Old 06-25-2007 , 19:52   Re: Global Message + Ammo
Reply With Quote #3

Ah! Thanks for the help with the announcements! But for the ammo, I've used bpammo and realized it only changed the clips not being used. I wish to give the person a weapon, with ONLY 2 or 3 ammo, and not any reserved ammo. Thanks again!
MeNtAL MaNiAC is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 06-25-2007 , 20:15   Re: Global Message + Ammo
Reply With Quote #4

I noticed that and rewrote my post.

Last edited by Lee; 06-25-2007 at 20:24.
Lee 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 21:26.


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