AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Global Message + Ammo (https://forums.alliedmods.net/showthread.php?t=56982)

MeNtAL MaNiAC 06-25-2007 19:27

Global Message + Ammo
 
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)
 }



Lee 06-25-2007 19:45

Re: Global Message + Ammo
 
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. ;)

MeNtAL MaNiAC 06-25-2007 19:52

Re: Global Message + Ammo
 
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!

Lee 06-25-2007 20:15

Re: Global Message + Ammo
 
I noticed that and rewrote my post. :)


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

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