Raised This Month: $ Target: $400
 0% 

Random options......


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 03-19-2006 , 07:29   Random options......
Reply With Quote #1

How can I, for example, assign a different starting weapon on round change? Last round, started with ak47, then next round plugin chooses at random from within itself a new primary weapon to give. So on next round, player gets auto shotgun instead. And so on for entire map. Anybody know how to do this? Thanks
organizedKaoS is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-19-2006 , 08:53  
Reply With Quote #2

sumthin' like this?
Code:
#include <amxmodx> #include <fun> #define PLUGIN "" #define VERSION "1.0" #define AUTHOR "[ --<-@ ]" #define MAX_WEAPONS 25 new g_szWeaps[MAX_WEAPONS][] = {     "ak47", "aug",     "awp", "deagle",     "elite", "famas",     "fiveseven", "g3sg1",     "galil", "glock18",     "m249", "m3",     "m4a1", "mac10",     "mp5navy", "p228",     "p90", "scout",     "sg550", "sg552",     "tmp", "ump45",     "usp", "xm1014",     "shield" } public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("ResetHud", "func", "be") } public func(id) {     new j = random_num( 0, MAX_WEAPONS - 1 )     for( new i = 0; i < MAX_WEAPONS; i++ ) {         if ( i == j ) {             new weap[25]             format(weap , 24 , "weapon_%s" , g_szWeaps[i])             give_item(id , weap)             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i] )         }     } } public ammo_up(id) {     give_item(id, "item_thighpack")     give_item(id, "weapon_hegrenade")     give_item(id, "weapon_flashbang")     give_item(id, "weapon_flashbang")     give_item(id, "item_assaultsuit")     give_item(id, "weapon_smokegrenade")     for ( new i = 0 ; i < 20 ; i++ ) {         give_item(id, "ammo_9mm")         give_item(id, "ammo_50ae")         give_item(id, "ammo_57mm" )         give_item(id, "ammo_357sig")         give_item(id, "ammo_762nato")         give_item(id, "ammo_556nato" )         give_item(id, "ammo_buckshot" )         give_item(id, "ammo_338magnum" )         give_item(id, "ammo_556natobox" )         give_item(id, "ammo_45acp")     } }
[ --<-@ ] Black Rose is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-19-2006 , 12:48  
Reply With Quote #3

ResetHUD usually is a player spawn but not round change.

Quote:
Originally Posted by amxx wiki
Precompute what can be precomputed
Better put to the global array exact weapon names.
Then your func would be:
Code:
public func(id) {             new i = random(MAX_WEAPONS)             give_item(id , g_szWeaps[i])             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i][7] ) }
VEN is offline
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 03-19-2006 , 13:56  
Reply With Quote #4

Quote:
Originally Posted by VEN
ResetHUD usually is a player spawn but not round change.

Quote:
Originally Posted by amxx wiki
Precompute what can be precomputed
Better put to the global array exact weapon names.
Then your func would be:
Code:
public func(id) {             new i = random(MAX_WEAPONS)             give_item(id , g_szWeaps[i])             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i][7] ) }
So if I define the weapon names in the plugin and use this set, on every round change, a random weapon will be given? Ill try this while I wait for a response. Thanks peeps
organizedKaoS is offline
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 03-19-2006 , 14:00  
Reply With Quote #5

Quote:
Originally Posted by [ --<-@
Black Rose]
Code:
#include #define MAX_WEAPONS 25 new g_szWeaps[MAX_WEAPONS][]
why dont you do
Code:
new g_szWeaps[25][]
wouter is offline
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 03-19-2006 , 18:52  
Reply With Quote #6

IDK
organizedKaoS is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 03-19-2006 , 21:02  
Reply With Quote #7

A good reason to use a define instead of the number itself is to maintain code readibility. That's a good programming practice.
Brad is offline
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 03-19-2006 , 21:52  
Reply With Quote #8

Quote:
Originally Posted by VEN
Better put to the global array exact weapon names.
Then your func would be:
Code:
public func(id) {             new i = random(MAX_WEAPONS)             give_item(id , g_szWeaps[i])             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i][7] ) }
That didnt seem to work for me...but this
Code:
public func(id) {     new j = random_num( 0, MAX_WEAPONS - 1 )     for( new i = 0; i < MAX_WEAPONS; i++ ) {         if ( i == j ) {             new weap[25]             format(weap , 24 , "weapon_%s" , g_szWeaps[i])             give_item(id , weap)             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i] )         }
did and yeah .....Thanks everyone who helped in here
organizedKaoS is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 03-19-2006 , 22:06  
Reply With Quote #9

Quote:
Originally Posted by organizedKaoS
Quote:
Originally Posted by VEN
Better put to the global array exact weapon names.
Then your func would be:
Code:
public func(id) {             new i = random(MAX_WEAPONS)             give_item(id , g_szWeaps[i])             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i][7] ) }
That didnt seem to work for me...but this
Code:
public func(id) {     new j = random_num( 0, MAX_WEAPONS - 1 )     for( new i = 0; i < MAX_WEAPONS; i++ ) {                     if ( i == j ) {             new weap[25]             format(weap , 24 , "weapon_%s" , g_szWeaps[i])             give_item(id , weap)             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i] )         }
did and yeah :lol: .....Thanks everyone who helped in here :lol: :lol: :lol:
Just use VEN's but change it to

Code:
public func(id) {             new i = random(MAX_WEAPONS)             new weap[25]             format(weap , 24 , "weapon_%s" , g_szWeaps[i])             give_item(id , g_szWeaps[i])             ammo_up(id)             client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i]) }
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
VEN
Veteran Member
Join Date: Jan 2005
Old 03-20-2006 , 03:55  
Reply With Quote #10

Code:
public func(id) {     new i = random(MAX_WEAPONS)     give_item(id , g_szWeaps[i])     ammo_up(id)     client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i][7] ) }
I tesed that function, it's fine.
Quote:
Better put to the global array exact weapon names.
It didn't work for you because you probably didn't specified full weapon names:
Code:
new g_szWeaps[MAX_WEAPONS][] = {     "weapon_ak47", "weapon_aug",     "weapon_awp", "weapon_deagle",     "weapon_elite", "weapon_famas",     "weapon_fiveseven", "weapon_g3sg1",     "weapon_galil", "weapon_glock18",     "weapon_m249", "weapon_m3",     "weapon_m4a1", "weapon_mac10",     "weapon_mp5navy", "weapon_p228",     "weapon_p90", "weapon_scout",     "weapon_sg550", "weapon_sg552",     "weapon_tmp", "weapon_ump45",     "weapon_usp", "weapon_xm1014",     "weapon_shield" }
Also if you still use ResetHUD, delay should be used:
Code:
public func(id) {     set_task(0.1, "func2", id) } public func2(id) {     new i = random(MAX_WEAPONS)     give_item(id , g_szWeaps[i])     ammo_up(id)     client_print( id, print_chat, "[WPN] Gave : %s", g_szWeaps[i][7] ) }

You do not have to use format method, it only seems as efficient but in fact that's not so.
VEN 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 16:36.


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