Raised This Month: $ Target: $400
 0% 

Help with WeaponChance


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lagaar
Junior Member
Join Date: May 2011
Old 08-07-2011 , 18:13   Help with WeaponChance
Reply With Quote #1

Hello!, How are you? I'm fine... I have a blockmaker and i would like create a WeaponChance block. This block, would select randomly a weapon and gives this from the player.

I hope you can help me.

Thanks!

Sorry for my bad english
lagaar is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-07-2011 , 18:26   Re: Help with WeaponChance
Reply With Quote #2

Create and array with all weapon names and give_item() a random array cell.
SpeeDeeR is offline
lagaar
Junior Member
Join Date: May 2011
Old 08-08-2011 , 11:25   Re: Help with WeaponChance
Reply With Quote #3

Can you tell me an example?
lagaar is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-08-2011 , 11:35   Re: Help with WeaponChance
Reply With Quote #4

Quote:
Originally Posted by lagaar View Post
Can you tell me an example?
He doesn't understand weapon chance blocks.

What you could do is this:

Code:
actionWeaponChance(id) {     // when player steps on block     // check cooldown if you want         // random chance for getting a weapon     if( random(100) < 30 )     {         // player beat the 30% chance for weapon                 // give the weapon (in this example, ak47)         new ent = give_item(id, "weapon_ak47");                 // set the weapon's ammo         cs_set_weapon_ammo(ent, 1); // 1 bullet in clip                 // set the backpack ammo         cs_set_user_bpammo(ent, CSW_AK47, 0); // no bp ammo     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-08-2011 , 11:32   Re: Help with WeaponChance
Reply With Quote #5

PHP Code:
new const array[] = 
{
    
"weapon_m3",
    
"weapon_m4a1",
    
"weapon_awp"
}

public function(
id)
{
    
give_item(id,array[random(charsmax(array))])

SpeeDeeR is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-08-2011 , 11:43   Re: Help with WeaponChance
Reply With Quote #6

Quote:
Originally Posted by lagaar View Post
Hello!, How are you? I'm fine...i would like create a WeaponChance block
Ooh... now I got it. Sorry.
SpeeDeeR is offline
lagaar
Junior Member
Join Date: May 2011
Old 08-08-2011 , 11:57   Re: Help with WeaponChance
Reply With Quote #7

Thanks for all! Here one example of the block.

PHP Code:
actionWeaponChance(id)
{    
        if (
is_user_alive(id) && !WeaponChanceUser[id] && get_user_team(id) == 1)     
    {
        
get_user_name(idweaponname32);
        switch (
random_num(02)) 
        { 
            case 
0show_hudmessage(0"[WeaponChance Block] A %s le toco una p228"weaponname);
        
give_item(id"weapon_p228");
        
cs_set_weapon_ammo(find_ent_by_owner(1"weapon_p228"id), 2);
            case 
1show_hudmessage(0"[WeaponChance Block] A %s le toco una Scout"weaponname);
        
give_item(id"weapon_scout");
        
cs_set_weapon_ammo(find_ent_by_owner(1"weapon_scout"id), 1);
            case 
2show_hudmessage(0"[WeaponChance Block] A %s le toco una He"weaponname);
        
give_item(id"weapon_hegrenade");
        
cs_set_weapon_ammo(find_ent_by_owner(1"weapon_hegrenade"id), 2);
        }  
    }

It's okey?
lagaar is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-08-2011 , 11:58   Re: Help with WeaponChance
Reply With Quote #8

Grenades don't have ammo.
If you want to give more than 1, use BP ammo for the player.

And I guess SpeeDeeR was right the first time.
First time I've seen a weapon chance block like this.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 03:30.


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