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

[REQ] Random Weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blanko
Senior Member
Join Date: Aug 2008
Old 05-19-2014 , 17:31   [REQ] Random Weapon
Reply With Quote #1

On the first round and on every round start that you've got killed the round before, you will get a pair of weapons randomly (free of charge). Examples:

-Smokegrenade + P90
-Knife + Awp
-Desert Eagle + Hegrenade
-P228 + Molotov

Those four pair of weapons are perfect for now, I've already have the molotov plugin working on and by the simple command "say molotov", it can be given to the current player.
__________________
blanko is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-19-2014 , 17:44   Re: [REQ] Random Weapon
Reply With Quote #2

You want these four combinations to be given to the player on every round start?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
blanko
Senior Member
Join Date: Aug 2008
Old 05-19-2014 , 18:13   Re: [REQ] Random Weapon
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
You want these four combinations to be given to the player on every round start?
yes, one of these combinations, chosen randomly. unless he's still alive on round start, then he keeps the weapons he already have.
__________________
blanko is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-19-2014 , 18:53   Re: [REQ] Random Weapon
Reply With Quote #4

Do you want to strip user weapons in the beginning (if he is dead before, of course), or you use another plugins giving the player any weapons?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Old 05-20-2014, 02:19
connoisseur
This message has been deleted by connoisseur. Reason: was asking for molotov cost, but it's irrelevant.. nvm
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-20-2014 , 04:57   Re: [REQ] Random Weapon
Reply With Quote #5

Here it is! I've included a chat message too, but if you don't want it, you may delete this function and the new const aswell, because it's used only for the message. So, I've included another option too - stripping user pistols, which you can control with cvar - random_weapon_strip_previous. In other words, if the cvar is to 1, the user will have only this pistol, which the plugin gave him (in the cases where a pistol is in the bonus weapons), but if the cvar is to 0, the user will have two pistols. Here is the code:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <ColorChat>
#include <fun>
#include <cstrike>
#include <stripweapons>

#define PLUGIN "Random Weapons"
#define VERSION "1.0"
#define AUTHOR "Flicker"

new bool:Killleeeddd[33]

new const 
PREFIX[] = { "[^x03Random Weapons^x04]" }

new const 
weapons[][] = 
{
    
"",
    
"^4Smokegrenade ^1+ ^4P90",
    
"^4Knife ^1+ ^4Awp",
    
"^4Desert Eagle ^1+ ^4Hegrenade",
    
"^4P228 ^1+ ^4Molotov "
}

new 
strips

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""Spawn"1)
    
RegisterHam(Ham_Killed"player""Killed"1)
    
strips register_cvar("random_weapon_strip_previous""1")
}

public 
Killed(id)
{
    
Killleeeddd[id] = true
}
public 
Spawn(id)
{
    if(
is_user_alive(id) && Killleeeddd[id])
    {
        
Killleeeddd[id] = false
        
new Irandom random_num(14)
        new 
ReceivedWeaponNum
        
switch(Irandom)
        {
            case 
1:
            {
                
give_item(id"weapon_smokegrenade")
                
DropDaPistol(id)
                
give_item(id"weapon_p90")
                
give_item(id"ammo_57mm")
                
give_item(id"ammo_57mm")
                
ReceivedWeaponNum 1
            
}
            case 
2:
            {
                
give_item(id"weapon_awp")
                
give_item(id"ammo_338magnum")
                
give_item(id"ammo_338magnum")
                
give_item(id"ammo_338magnum")
                
ReceivedWeaponNum 2
            
}
            case 
3:
            {
                
give_item(id"weapon_hegrenade")
                
DropDaPistol(id)
                
give_item(id"weapon_deagle")
                
give_item(id"ammo_50ae")
                
give_item(id"ammo_50ae")
                
give_item(id"ammo_50ae")
                
give_item(id"ammo_50ae")
                
give_item(id"ammo_50ae")
                
cs_set_user_bpammo(idCSW_DEAGLE35)
                
ReceivedWeaponNum 3
                
            
}
            case 
4:
            {
                
give_item(id"weapon_p228")
                
give_item(id"ammo_357sig")
                
give_item(id"ammo_357sig")
                
give_item(id"ammo_357sig")
                
give_item(id"ammo_357sig")
                
client_cmd(id"say molotov")
                
ReceivedWeaponNum 4
            
}
        }
        
ColorChat(idGREEN"%s ^x01 This round you randomly received %s" PREFIXweapons[ReceivedWeaponNum])
    }
}

public 
DropDaPistol(id)
{
    if(
get_pcvar_num(strips))
        
StripWeapons(idSecondary)

I've used give_item("ammo_x") instead of including cstrike only for cs_set_user_bpammo.
The needinc stripweapons include is attached in the post, you won't be able to compile without it.
Also, I don't get the point of the Knife + Awp option, the user has knife anyways?!
Attached Files
File Type: inc stripweapons.inc (4.5 KB, 203 views)
__________________

Last edited by Flick3rR; 05-20-2014 at 04:59.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
connoisseur
Senior Member
Join Date: Jan 2012
Old 05-20-2014 , 05:03   Re: [REQ] Random Weapon
Reply With Quote #6

@Flick3rR
You'll need to reimburse the cost of molotov, if the other plugin charges money for it.
__________________
connoisseur is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-20-2014 , 06:18   Re: [REQ] Random Weapon
Reply With Quote #7

Quote:
Originally Posted by blanko View Post
I've already have the molotov plugin working on and by the simple command "say molotov", it can be given to the current player.
Did what the guy said. Isn't enough that he has already said that he wants to give the molotov by say cmd...
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-20-2014 , 06:59   Re: [REQ] Random Weapon
Reply With Quote #8

Is there a specific reason why you give ammo via give_item?
__________________
Kia is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-20-2014 , 08:23   Re: [REQ] Random Weapon
Reply With Quote #9

Read the post with the code and you will understand... Because I decided to use it insted of including cstrike module only for the ammo.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-20-2014 , 09:07   Re: [REQ] Random Weapon
Reply With Quote #10

Why don't you add the code of the include inside the plugin? Then you could compile it using a webcompiler.
__________________
Kia 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 04:56.


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