Raised This Month: $ Target: $400
 0% 

[SOLVED] Setting weapon ammo...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 04-26-2007 , 13:57   [SOLVED] Setting weapon ammo...
Reply With Quote #1

Ok I have everything just fine...but for some reason when I use this code.

Code:
public rndWEPS(id) {     new rnd     rnd = random_num(0,100)     if( rnd <= 5)     {         give_item(id, "weapon_awp")     cs_set_user_bpammo(id, CSW_AWP, 0)     cs_set_weapon_ammo(CSW_AWP, 3)     client_print(id, print_chat, "You got an awp with 3 bullets! (1/20 Chance)")     }     else if(rnd > 5 && rnd <= 15)     {         give_item(id, "weapon_p228")     cs_set_user_bpammo(id, CSW_P228, 0)     cs_set_weapon_ammo(CSW_P228, 2)     client_print(id, print_chat, "You got a P228 with 2 bullets! (1/10 Chance)")     }     else if(rnd > 15 && rnd <= 30)     {         give_item(id, "item_shield")     client_print(id, print_chat, "You got a Shield! (1/6 Chance)")     }     else if(rnd > 30 && rnd <= 60)     {         give_item(id, "weapon_hegrenade")     client_print(id, print_chat, "You got a HE Grenade! (1/3 Chance)")     } }

For some unknown reason it gives the awp 10 bullets...or the p228 a full chamber and none in the clip...I want just 3 bullets for awp... what am I doing wrong ?
bwgrubbs1 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-26-2007 , 14:05   Re: Setting weapon ammo...
Reply With Quote #2

cs_set_weapon_ammo requires the Weapon Entity Index. Not the Weapon Id Constant.

So your going to have to find the entity by owner. Ie .. "weapon_awp". Then use that Weapon Entity Index.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 04-26-2007 , 14:15   Re: Setting weapon ammo...
Reply With Quote #3

so if i did something like this ?

Code:
public rndWEPS(id) {     new rnd     new players[32], num     new i     get_players(players, num)     rnd = random_num(0,100)     if( rnd <= 100)     {         for (i=0; i < num; i++)         {         give_item(player[i], "weapon_csw_awp")         cs_set_user_bpammo(player[i], CSW_AWP, 0)         cs_set_weapon_ammo(player[i], 3)         }         client_print(player[i], print_chat, "You got an awp with 3 bullets! (1/20 Chance)")     }     else if(rnd >5 && rnd <= 15)     {         give_item(id, "weapon_csw_p228")     cs_set_user_bpammo(id, CSW_P228, 0)     cs_set_weapon_ammo(CSW_P228, 2)     client_print(id, print_chat, "You got a P228 with 2 bullets! (1/10 Chance)")     }     else if(rnd >15 && rnd <= 30)     {         give_item(id, "weapon_csw_shield")     client_print(id, print_chat, "You got a Shield! (1/6 Chance)")     }     else if(rnd >30 && rnd <= 60)     {         give_item(id, "weapon_csw_hegrenade")     client_print(id, print_chat, "You got a HE Grenade! (1/3 Chance)")     }     else(rnd >60)     {         give_item(id, "weapon_p228")     cs_set_user_bpammo(id, CSW_P228, 0)     cs_set_weapon_ammo(CSW_P228, 2)     client_print(id, print_chat, "You got a P228 with 2 bullets! (1/10 Chance)")     } }
bwgrubbs1 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-26-2007 , 14:35   Re: Setting weapon ammo...
Reply With Quote #4

No.

Not player index. Each weapon a player has a specific entity index.

Usage for engine you would do
Code:
new WeapEntIndex = find_ent_by_owner(-1, "weapon_awp", player[i], 0); if(is_ent_valid(WeapEntIndex)) {     cs_set_weapon_ammo(WeapEntIndex, 3); }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 04-26-2007 , 14:48   Re: Setting weapon ammo...
Reply With Quote #5

just a bit of a problem

Code:
    new players[32], num         new i         get_players(players, num)           new rnd     rnd = random_num(0,100)         if( rnd <= 100)         {             give_item(id, "weapon_awp")         new WeapEntIndex = find_ent_by_owner(-1, "weapon_awp", players[i], 0);         if(is_ent_valid(WeapEntIndex))         {             cs_set_weapon_ammo(WeapEntIndex, 3);         }             client_print(players[i], print_chat, "You got an awp with 3 bullets! (1/20 Chance)")         i++         }

/home/groups/amxmodx/tmp3/phpKRstlI.sma(599) : error 017: undefined symbol "is_ent_valid"
bwgrubbs1 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-26-2007 , 15:11   Re: Setting weapon ammo...
Reply With Quote #6

change that to is_valid_ent
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 04-26-2007 , 15:11   Re: Setting weapon ammo...
Reply With Quote #7

OK I have this and it works...some of the time...

Code:
    new players[32], num         new i         get_players(players, num)           new rnd     rnd = random_num(0,100)         if( rnd <= 100)         {             give_item(id, "weapon_awp")         new WeapEntIndex = find_ent_by_owner(-1, "weapon_awp", players[i], 0);         cs_set_weapon_ammo(WeapEntIndex, 3);             client_print(players[i], print_chat, "You got an awp with 3 bullets! (1/20 Chance)")         i++         }     else if(rnd > 5 && rnd <= 15)     {             give_item(id, "weapon_p228")         new WeapEntIndex = find_ent_by_owner(-1, "weapon_p228", players[i], 0);         cs_set_weapon_ammo(WeapEntIndex, 2);         client_print(id, print_chat, "You got a P228 with 2 bullets! (1/10 Chance)")         i++     }     else if(rnd > 15 && rnd <= 30)     {         give_item(id, "item_shield")         client_print(id, print_chat, "You got a Shield! (1/6 Chance)")     }     else if(rnd >30 && rnd <= 60)     {             give_item(id, "weapon_hegrenade")         client_print(id, print_chat, "You got a HE Grenade! (1/3 Chance)")     }     else if(rnd > 60 && rnd <= 100)     {         give_item(id, "weapon_p228")         client_print(id, print_chat, "...")     } }
bwgrubbs1 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-26-2007 , 15:19   Re: Setting weapon ammo...
Reply With Quote #8

It possible you need to delay the setting weapon clip ammo because of the player hasn't gotten the weapon yet.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 04-26-2007 , 15:25   Re: Setting weapon ammo...
Reply With Quote #9

OK i changed it to this...and it wont change the bullets...still gives 10

Code:
    new players[32], num         new i         get_players(players, num)           new rnd     rnd = random_num(0,100)         if( rnd <= 100)         {             give_item(id, "weapon_awp")         new WeapEntIndex = find_ent_by_owner(-1, "weapon_awp", players[i], 0);                     if(is_valid_ent(WeapEntIndex))             {             cs_set_weapon_ammo(WeapEntIndex, 3);                 client_print(players[i], print_chat, "You got an awp with 3 bullets! (1/20 Chance)")             i++             }     }     else if(rnd > 5 && rnd <= 15)     {             give_item(id, "weapon_p228")         new WeapEntIndex = find_ent_by_owner(-1, "weapon_p228", players[i], 0);                 if(is_valid_ent(WeapEntIndex))             {             cs_set_weapon_ammo(WeapEntIndex, 2);             client_print(id, print_chat, "You got a P228 with 2 bullets! (1/10 Chance)")             i++             }     }     else if(rnd > 15 && rnd <= 30)     {         give_item(id, "item_shield")         client_print(id, print_chat, "You got a Shield! (1/6 Chance)")     }     else if(rnd >30 && rnd <= 60)     {             give_item(id, "weapon_hegrenade")         client_print(id, print_chat, "You got a HE Grenade! (1/3 Chance)")     }     else if(rnd > 60 && rnd <= 100)     {         give_item(id, "weapon_p228")         client_print(id, print_chat, "...")     }
bwgrubbs1 is offline
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 04-26-2007 , 15:26   Re: Setting weapon ammo...
Reply With Quote #10

ok...i see what you mean, so just insert a wait...or some sort of pause
bwgrubbs1 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 06:38.


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