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

cs_user_has_shield( id ) ... The right way to find a shield!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ronkkrop
Member
Join Date: May 2004
Old 12-16-2004 , 15:10   cs_user_has_shield( id ) ... The right way to find a shield!
Reply With Quote #1

Well i manged to find the offset the shield is located on. It seems as though its mixed with some flags of some kind but i dont know what the other flags do.

its on offset 510, and the 25th bit (bit 24). Below i demonstrate how to use it to find if a user has a shield.

Code:
#include <amxmodx> #include <fakemeta> #include <fun> #define OFFSET_SHIELD   510 #define OFFSET_SHIELD_AMD64 559 //AMXX team forgot to put this in core.inc //returns true if server is amd64 native is_amd64_server(); public plugin_init(){         register_plugin("Shield Tell","0.1","Cr!Z");         register_clcmd("say shield", "shield_test");     register_clcmd("say shield_give", "shield_give");     } public plugin_modules(){     require_module("fakemeta");     require_module("fun"); } public shield_give( id ){     give_item( id, "weapon_shield" );     return PLUGIN_HANDLED; } public shield_test( id ){         if( cs_user_has_shield( id ) )         client_print( id, print_chat, "You have a shield!");     else         client_print( id, print_chat, "No shield" );     return PLUGIN_HANDLED; } public cs_user_has_shield( id ){     new shieldFlag;     if ( is_amd64_server() ) shieldFlag = get_pdata_int(id, OFFSET_SHIELD_AMD64, 0);     else shieldFlag = get_pdata_int(id, OFFSET_SHIELD);         return (shieldFlag & (1<<24)); }

Those of you not familiar with bitwise operators, the return checks shieldFlag's 25th bit for a 1. (It's 24 there because dont forget that there is a bit 0).

So this should solve all problems/questions regarding how to tell if somebody has a shield.


EDIT: Damaged-Soul found me the amd64 offset, thanks!
__________________
"I refuse to join any club that would have me as a member."
--Groucho Marx
Ronkkrop is offline
Send a message via ICQ to Ronkkrop Send a message via AIM to Ronkkrop Send a message via MSN to Ronkkrop Send a message via Yahoo to Ronkkrop
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 12-17-2004 , 03:37  
Reply With Quote #2

Nice :-)
Johnny got his gun 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 07:28.


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