Raised This Month: $ Target: $400
 0% 

how to check bot weapon?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-20-2012 , 09:10   Re: how to check bot weapon?
Reply With Quote #1

Something like this:

Global vars:
PHP Code:
// store weapon type ids
new const weapon_type_id[] =
{
 (
<< CSW_GALIL << CSW_FAMAS << CSW_AK47 << CSW_SG552 << CSW_AUG),
 (
<< CSW_MAC10 << CSW_TMP << CSW_MP5NAVY << CSW_UMP45 << CSW_P90),
 (
<< CSW_AWP << CSW_SCOUT << CSW_G3SG1 << CSW_SG550),
 (
<< CSW_M3 << CSW_XM1014),
 (
<< CSW_GLOCK18 << CSW_USP << CSW_P228 << CSW_DEAGLE << CSW_ELITE << CSW_FIVESEVEN),
 (
<< CSW_M249),
 (
<< CSW_C4 << CSW_HEGRENADE << CSW_SMOKEGRENADE << CSW_FLASHBANG)
}
 
// store sprite names for the weapon types
new const sprite_names[][] =
{
 
"sprites/title/assault.spr",
 
"sprites/title/smg.spr",
 
"sprites/title/sniper.spr",
 
"sprites/title/shotgun.spr",
 
"sprites/title/handgun.spr",
 
"sprites/title/machinegun.spr",
 
"sprites/title/explosive.spr"
}
 
// store sprite precache id
new hudsprite[sizeof sprite_names
Precache:
PHP Code:
for(new i=0;i<sizeof sprite_names;i++) hudsprite[i] = precache_model(sprite_names[i]) 
Sprite display code:
PHP Code:
    static players[32],numi,iiid
    get_players
(players,num,"a"// get all alive players in the server
 
    
for(i=0;i<num;i++) // loop trough them...
    
{
        
id players[i// store player index in a more convenient variable
 
        
for(ii=0;ii<sizeof weapon_type_id;ii++) // loop trough all types of weapons
        
{
                 if(!(
<< get_user_weapon(id) & weapon_type_id[ii])) continue // our weapon isn't this type - continue with the others
 
                 // Else - show the sprite...
                 
message_begin(MSG_ONE_UNRELIABLE,SVC_TEMPENTITY, .player id// skip default values
                 
write_short(TE_PLAYERATTACHMENT)
                 
write_entity(id)
                 
write_coord(32)
                 
write_short(hudsprite[ii]) // display the sprite of that weapon type
                 
write_short(10// life = 10 : should be around 1 second
                 
message_end()
 
                 break 
// don't loop trough the other weapon types if we have found our
         
}
    } 
__________________

Last edited by <VeCo>; 05-20-2012 at 09:13.
<VeCo> is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-20-2012 , 09:27   Re: how to check bot weapon?
Reply With Quote #2

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

// store weapon type ids
new const weapon_type_id[] =
{
 (
<< CSW_GALIL << CSW_FAMAS << CSW_AK47 << CSW_SG552 << CSW_AUG),
 (
<< CSW_MAC10 << CSW_TMP << CSW_MP5NAVY << CSW_UMP45 << CSW_P90),
 (
<< CSW_AWP << CSW_SCOUT << CSW_G3SG1 << CSW_SG550),
 (
<< CSW_M3 << CSW_XM1014),
 (
<< CSW_GLOCK18 << CSW_USP << CSW_P228 << CSW_DEAGLE << CSW_ELITE << CSW_FIVESEVEN),
 (
<< CSW_M249),
 (
<< CSW_C4 << CSW_HEGRENADE << CSW_SMOKEGRENADE << CSW_FLASHBANG)
}
 
// store sprite names for the weapon types
new const sprite_names[][] =
{
 
"sprites/title/assault.spr",
 
"sprites/title/smg.spr",
 
"sprites/title/sniper.spr",
 
"sprites/title/shotgun.spr",
 
"sprites/title/handgun.spr",
 
"sprites/title/machinegun.spr",
 
"sprites/title/explosive.spr"
}
 
// store sprite precache id
new hudsprite[sizeof sprite_names]  

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""event_DeathMsg""a")
}
public 
plugin_precache()
{
    for(new 
i=0;i<sizeof sprite_names;i++) hudsprite[i] = precache_model(sprite_names[i]) 
}
public 
event_DeathMsg()
{
    static 
players[32],numi,iiid
    get_players
(players,num,"a"// get all alive players in the server
 
    
for(i=0;i<num;i++) // loop trough them...
    
{
        
id players[i// store player index in a more convenient variable
 
        
for(ii=0;ii<sizeof weapon_type_id;ii++) // loop trough all types of weapons
            
{
                if(!(
<< get_user_weapon(id) & weapon_type_id[ii])) continue // our weapon isn't this type - continue with the others
 
                // Else - show the sprite...
                
message_begin(MSG_ONE_UNRELIABLE,SVC_TEMPENTITY, .player id// skip default values
                
write_short(TE_PLAYERATTACHMENT)
                
write_entity(id)
                
write_coord(32)
                
write_short(hudsprite[ii]) // display the sprite of that weapon type
                
write_short(10// life = 10 : should be around 1 second
                
message_end()
 
                break 
// don't loop trough the other weapon types if we have found our
            
}
    }  

Like this?
Randomize is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-20-2012 , 09:29   Re: how to check bot weapon?
Reply With Quote #3

That will show the sprites only when somebody gets killed. If you want them to show continuously, make a thinking entity.
__________________
<VeCo> is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-20-2012 , 09:32   Re: how to check bot weapon?
Reply With Quote #4

Warning message when i compiled it Warning: Loose indentation on line 48

get_players(players,num,"a") // get all alive players in the server
Randomize is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-20-2012 , 09:33   Re: how to check bot weapon?
Reply With Quote #5

wait, why i put event death message?
Randomize is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-20-2012 , 09:37   Re: how to check bot weapon?
Reply With Quote #6

Loose indentation means the code isn't intended as the other lines (that doesn't affect the actual code, but It's good to indent the lines).
For the DeathMsg - I don't know. xD
__________________
<VeCo> is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-20-2012 , 09:43   Re: how to check bot weapon?
Reply With Quote #7

well, thank you so much ;)
Randomize is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-21-2012 , 04:24   Re: how to check bot weapon?
Reply With Quote #8

CL_ParseServerMessage: Bad server message when test the plugin @_@

Last edited by Randomize; 05-21-2012 at 04:38.
Randomize is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-21-2012 , 05:49   Re: how to check bot weapon?
Reply With Quote #9

You have mistaken the first 2 natives. The corrent message send is:

PHP Code:
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_PLAYERATTACHMENT// not write_short
write_byte(id// not write_entity
write_coord(32)
write_short(hudsprite[ii]) // display the sprite of that weapon type
write_short(10// life = 10 : should be around 1 second
message_end() 
Use MSG_BROADCAST, because you want to send the sprite to all players in the server.
__________________

Last edited by <VeCo>; 05-21-2012 at 05:50.
<VeCo> is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 05-21-2012 , 06:07   Re: how to check bot weapon?
Reply With Quote #10

okay.. Btw, if i want to show the sprites only to my team, i must add cs get user team
Randomize 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 00:28.


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