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

Bitsums and weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-24-2013 , 07:19   Bitsums and weapons
Reply With Quote #1

Why this code doesn't get all weapons?
PHP Code:
#include <amxmodx>

new Cvar_Weapons

public plugin_init()
{
    
Cvar_Weapons register_cvar("ttt_weapons""abcdefghijklmnopqrstuvwxyz")
    
    
register_clcmd("say wpn""weap")
}

public 
weap(id)
{
    new 
weapons[30], weapidweapname[20]
    
get_pcvar_string(Cvar_Weaponsweapons29)
    new 
flags read_flags(weapons)
    
    
//client_print(id, 3, "%s", weapons)
    //client_print(id, 3, "flags: %d", flags)
        
    
for(weapid CSW_P228;weapid <= CSW_P90;weapid++)
    {
        if(
flags & (1<<weapid))
        {
            if(
get_weaponname(weapidweapname19))
                
client_print(id3"%d - %s"weapidweapname)
        }
    }

Prints:
Code:
1 - weapon_p228
3 - weapon_scout
4 - weapon_hegrenade
5 - weapon_xm1014
6 - weapon_c4
7 - weapon_mac10
8 - weapon_aug
9 - weapon_smokegrenade
10 - weapon_elite
11 - weapon_fiveseven
12 - weapon_ump45
13 - weapon_sg550
14 - weapon_galil
15 - weapon_famas
16 - weapon_usp
17 - weapon_glock18
18 - weapon_awp
19 - weapon_mp5navy
20 - weapon_m249
21 - weapon_m3
22 - weapon_m4a1
23 - weapon_tmp
24 - weapon_g3sg1
25 - weapon_flashbang
__________________
alan_el_more is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-24-2013 , 07:37   Re: Bitsums and weapons
Reply With Quote #2

Because there are only 25 flags (from a to z).
__________________
hleV is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-24-2013 , 09:53   Re: Bitsums and weapons
Reply With Quote #3

somebody knows which flag for (1<<31)?
__________________
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-24-2013 , 13:46   Re: Bitsums and weapons
Reply With Quote #4

Try "abcdefghijklmnopqrstuvwxyz{|}>?@"


Edit :

Seems to work :

Code:
#1 33 read_flags("!") == 1 | 1<<0 == 1
#1 65 read_flags("A") == 1 | 1<<0 == 1
#1 97 read_flags("a") == 1 | 1<<0 == 1
#2 34 read_flags(""") == 2 | 1<<1 == 2
#2 66 read_flags("B") == 2 | 1<<1 == 2
#2 98 read_flags("b") == 2 | 1<<1 == 2
#3 35 read_flags("#") == 4 | 1<<2 == 4
#3 67 read_flags("C") == 4 | 1<<2 == 4
#3 99 read_flags("c") == 4 | 1<<2 == 4
#4 36 read_flags("$") == 8 | 1<<3 == 8
#4 68 read_flags("D") == 8 | 1<<3 == 8
#4 100 read_flags("d") == 8 | 1<<3 == 8
#5 37 read_flags("%") == 16 | 1<<4 == 16
#5 69 read_flags("E") == 16 | 1<<4 == 16
#5 101 read_flags("e") == 16 | 1<<4 == 16
#6 38 read_flags("&") == 32 | 1<<5 == 32
#6 70 read_flags("F") == 32 | 1<<5 == 32
#6 102 read_flags("f") == 32 | 1<<5 == 32
#7 39 read_flags("'") == 64 | 1<<6 == 64
#7 71 read_flags("G") == 64 | 1<<6 == 64
#7 103 read_flags("g") == 64 | 1<<6 == 64
#8 40 read_flags("(") == 128 | 1<<7 == 128
#8 72 read_flags("H") == 128 | 1<<7 == 128
#8 104 read_flags("h") == 128 | 1<<7 == 128
#9 41 read_flags(")") == 256 | 1<<8 == 256
#9 73 read_flags("I") == 256 | 1<<8 == 256
#9 105 read_flags("i") == 256 | 1<<8 == 256
#10 42 read_flags("*") == 512 | 1<<9 == 512
#10 74 read_flags("J") == 512 | 1<<9 == 512
#10 106 read_flags("j") == 512 | 1<<9 == 512
#11 43 read_flags("+") == 1024 | 1<<10 == 1024
#11 75 read_flags("K") == 1024 | 1<<10 == 1024
#11 107 read_flags("k") == 1024 | 1<<10 == 1024
#12 44 read_flags(",") == 2048 | 1<<11 == 2048
#12 76 read_flags("L") == 2048 | 1<<11 == 2048
#12 108 read_flags("l") == 2048 | 1<<11 == 2048
#13 45 read_flags("-") == 4096 | 1<<12 == 4096
#13 77 read_flags("M") == 4096 | 1<<12 == 4096
#13 109 read_flags("m") == 4096 | 1<<12 == 4096
#14 46 read_flags(".") == 8192 | 1<<13 == 8192
#14 78 read_flags("N") == 8192 | 1<<13 == 8192
#14 110 read_flags("n") == 8192 | 1<<13 == 8192
#15 47 read_flags("/") == 16384 | 1<<14 == 16384
#15 79 read_flags("O") == 16384 | 1<<14 == 16384
#15 111 read_flags("o") == 16384 | 1<<14 == 16384
#16 48 read_flags("0") == 32768 | 1<<15 == 32768
#16 80 read_flags("P") == 32768 | 1<<15 == 32768
#16 112 read_flags("p") == 32768 | 1<<15 == 32768
#17 49 read_flags("1") == 65536 | 1<<16 == 65536
#17 81 read_flags("Q") == 65536 | 1<<16 == 65536
#17 113 read_flags("q") == 65536 | 1<<16 == 65536
#18 50 read_flags("2") == 131072 | 1<<17 == 131072
#18 82 read_flags("R") == 131072 | 1<<17 == 131072
#18 114 read_flags("r") == 131072 | 1<<17 == 131072
#19 51 read_flags("3") == 262144 | 1<<18 == 262144
#19 83 read_flags("S") == 262144 | 1<<18 == 262144
#19 115 read_flags("s") == 262144 | 1<<18 == 262144
#20 52 read_flags("4") == 524288 | 1<<19 == 524288
#20 84 read_flags("T") == 524288 | 1<<19 == 524288
#20 116 read_flags("t") == 524288 | 1<<19 == 524288
#21 53 read_flags("5") == 1048576 | 1<<20 == 1048576
#21 85 read_flags("U") == 1048576 | 1<<20 == 1048576
#21 117 read_flags("u") == 1048576 | 1<<20 == 1048576
#22 54 read_flags("6") == 2097152 | 1<<21 == 2097152
#22 86 read_flags("V") == 2097152 | 1<<21 == 2097152
#22 118 read_flags("v") == 2097152 | 1<<21 == 2097152
#23 55 read_flags("7") == 4194304 | 1<<22 == 4194304
#23 87 read_flags("W") == 4194304 | 1<<22 == 4194304
#23 119 read_flags("w") == 4194304 | 1<<22 == 4194304
#24 56 read_flags("8") == 8388608 | 1<<23 == 8388608
#24 88 read_flags("X") == 8388608 | 1<<23 == 8388608
#24 120 read_flags("x") == 8388608 | 1<<23 == 8388608
#25 57 read_flags("9") == 16777216 | 1<<24 == 16777216
#25 89 read_flags("Y") == 16777216 | 1<<24 == 16777216
#25 121 read_flags("y") == 16777216 | 1<<24 == 16777216
#26 58 read_flags(":") == 33554432 | 1<<25 == 33554432
#26 90 read_flags("Z") == 33554432 | 1<<25 == 33554432
#26 122 read_flags("z") == 33554432 | 1<<25 == 33554432
#27 59 read_flags(";") == 67108864 | 1<<26 == 67108864
#27 91 read_flags("[") == 67108864 | 1<<26 == 67108864
#27 123 read_flags("{") == 67108864 | 1<<26 == 67108864
#28 60 read_flags("<") == 134217728 | 1<<27 == 134217728
#28 92 read_flags("\") == 134217728 | 1<<27 == 134217728
#28 124 read_flags("|") == 134217728 | 1<<27 == 134217728
#29 61 read_flags("=") == 268435456 | 1<<28 == 268435456
#29 93 read_flags("]") == 268435456 | 1<<28 == 268435456
#29 125 read_flags("}") == 268435456 | 1<<28 == 268435456
#30 62 read_flags(">") == 536870912 | 1<<29 == 536870912
#30 94 read_flags("^") == 536870912 | 1<<29 == 536870912
#30 126 read_flags("~") == 536870912 | 1<<29 == 536870912
#31 63 read_flags("?") == 1073741824 | 1<<30 == 1073741824
#31 95 read_flags("_") == 1073741824 | 1<<30 == 1073741824
#32 32 read_flags(" ") == 2147483648 | 1<<31 == 2147483648
#32 64 read_flags("@") == 2147483648 | 1<<31 == 2147483648
#32 96 read_flags("`") == 2147483648 | 1<<31 == 2147483648

Edit2 :
If you need to use get_flags, then you need to use following stock and to put it either in a .inc file, either BEFORE plugin_init().

PHP Code:
#define get_flags UTIL_GetFlags
stock UTIL_GetFlags(flagsoutput[], len)
{
    static const 
szAllFlags[] = "abcdefghijklmnopqrstuvwxyz{|}>?@";
    for(new 
iji<32 && i<leni++)
    {
        if( 
flags 1<<)
        {
            
output[j++] = szAllFlags[i];
        }
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-24-2013 at 17:50.
ConnorMcLeod is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-24-2013 , 20:19   Re: Bitsums and weapons
Reply With Quote #5

Ty but i have a question, how i can use that stock ?
__________________
alan_el_more is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-25-2013 , 04:43   Re: Bitsums and weapons
Reply With Quote #6

The same way you would use the default get_flags, so you ask, it means you don't need to use it.
get_flags is the "reversion" or read_flags, from integer value you retrieve the string, but reading amxx sources, it appears that it only supports flags between 1<<0 and 1<<25.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 10-25-2013 , 06:48   Re: Bitsums and weapons
Reply With Quote #7

Ty, i'll use it
__________________
alan_el_more 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 10:51.


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