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

Help, weapon id and hudmessage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AceVentura
Member
Join Date: Mar 2020
Location: Ontario, Canada
Old 03-29-2020 , 07:14   Help, weapon id and hudmessage
Reply With Quote #1

Hi,

i have few problems with a certain plugin.

Prob 1.

I tried to add new kill by grenade.
i Added new Point_HE;
Code:
new Point_HE; public plugin_init(){     register_event("DeathMsg", "eDeath", "a")         Point_HE = registercvar("amx_point_he" "3" ) }


i tried to add
Code:
new weapon = get_user_weapon(attacker) if (weapon == CSW_HEGRENADE){ CromChat(attacker, "You recieved #%d points for bombing #%s", get_pcvar_num(Point_HE), victim_name)

But it still counts as normal kill and give players 1 point.
and this is eDeath Event without get_user_weapon line
Spoiler


Prob 2. HUD SYNC.

Hud won't display actual points.
This is what i did:
also added this to eDeath event above
Code:
UpdatePoints(attacker)
Code:
#define UPDATE_INTERVAL         1.0 new gHudSync; public plugin_init() {         set_task( UPDATE_INTERVAL, "UpdatePoints", _, _, _, "b" );         gHudSync = CreateHudSyncObj( ); } public UpdatePoints(id) {     set_hudmessage( 255, 255, 255, 0.0, 0.30, 0, 6.0, UPDATE_INTERVAL + 0.1 );     ShowSyncHudMsg( id, gHudSync, "[ Points: %d / %d ]", PlayerPoints[id], get_pcvar_num(VIP_Cost) ); }

ss: https://i.postimg.cc/mrfKyZkx/de-dust20019.png
__________________
So.. animals CAN sense evil!
AceVentura is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-29-2020 , 07:45   Re: Help, weapon id and hudmessage
Reply With Quote #2

1. "get_user_weapon" returns the weapon that you're currently holding. When you kill a player, you're probably no longer holding the HE grenade in your hands.

Use "read_data(4, buffer[], len)" to get the weapon that killed the player in the "DeathMsg" event. For HE grenade, this will be equal to "grenade".

2. You have no "id" in that function. Since it's set in "plugin_init", id will always be 0.
__________________

Last edited by OciXCrom; 03-29-2020 at 07:45.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
AceVentura
Member
Join Date: Mar 2020
Location: Ontario, Canada
Old 03-29-2020 , 11:13   Re: Help, weapon id and hudmessage
Reply With Quote #3

PROB.1 solved!
Thank you!


2Unsolved. Still wont show player's points on screen.

Here:
Code:
#define UPDATE_INTERVAL         1.0 new PlayerPoints[33] new gHudSync; public plugin_init() { register_event("DeathMsg", "eDeath", "a") set_task( UPDATE_INTERVAL, "UpdatePoints", _, _, _, "b" );     gHudSync = CreateHudSyncObj( ); } public eDeath() {     new attacker = read_data(1)     new victim = read_data(2)     new headshot = read_data(3)     new szWeapon[10]     read_data(4, szWeapon, charsmax ( szWeapon ) )         new victim_name[32];     get_user_name(victim, victim_name, charsmax(victim_name))         if(!is_user_connected(attacker)) {                 return PLUGIN_HANDLED     }         if(is_user_vip(attacker)){                 return PLUGIN_HANDLED             }         if(cs_get_user_team(attacker) != cs_get_user_team(victim)){         if( equal( szWeapon, "grenade" ) ){             PlayerPoints[attacker] += get_pcvar_num(Point_HE);             CromChat(attacker,"&x04%s&x03 You recieved&x04 #%d points&x03 for bombing&x04 #%s ", MESSAGE_PREFIX,get_pcvar_num(Point_HE),victim_name)                     }         else {             if (headshot){                 PlayerPoints[attacker] += get_pcvar_num(Point_Hs)                 CromChat(attacker, "&x04%s&x03 You recieved&x04 #%d points&x03 for headshotting&x04 #%s ", MESSAGE_PREFIX,get_pcvar_num(Point_Hs), victim_name)                             }             else{                 PlayerPoints[attacker] += get_pcvar_num(Point_Kill);                 CromChat(attacker,"&x04%s&x03 You recieved&x04 #%d point&x03 for killing&x04 #%s ", MESSAGE_PREFIX,get_pcvar_num(Point_Kill),victim_name)             }                     }     }         else{                 if(attacker == victim) {             if(PlayerPoints[attacker] > get_pcvar_num(Point_Suicide))                 PlayerPoints[attacker] -= get_pcvar_num(Point_Suicide)                         else                 PlayerPoints[attacker] = 0         }                 else {             if(PlayerPoints[attacker] > get_pcvar_num(Point_TeamKill))                 PlayerPoints[attacker] -= get_pcvar_num(Point_TeamKill)                         else                 PlayerPoints[attacker] = 0         }     }             UpdatePoints(attacker)     if(get_pcvar_num(SavePoints))         SaveData(attacker)     return PLUGIN_HANDLED;     } public UpdatePoints() {     set_hudmessage( 255, 255, 255, 0.0, 0.30, 0, 6.0, UPDATE_INTERVAL + 0.1 );     ShowSyncHudMsg( 0, gHudSync, "[ Points: %d / %d ]", PlayerPoints[id], get_pcvar_num(VIP_Cost) ); }
__________________
So.. animals CAN sense evil!
AceVentura is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-29-2020 , 11:19   Re: Help, weapon id and hudmessage
Reply With Quote #4

use get_players() and loop through every player.

PHP Code:
new iPlayers[32], iNumid;
get_players(iPlayersiNum);

for(new 
iiNumi++)
{
    
id iPlayers[i]
    
//Show HudMessage.

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
AceVentura
Member
Join Date: Mar 2020
Location: Ontario, Canada
Old 03-29-2020 , 11:33   Re: Help, weapon id and hudmessage
Reply With Quote #5

Solved, Thank you! @Napoleon_be + karma
__________________
So.. animals CAN sense evil!
AceVentura 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 19:36.


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