Raised This Month: $ Target: $400
 0% 

Hostage Interaction in CSS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 06-17-2009 , 14:04   Hostage Interaction in CSS
Reply With Quote #1

Making a script to allow terrorists to get hostages to follow them..

Relevant code:
For on plugin start:
Code:
g_LeaderOffset = FindSendPropOffs("CHostage", "m_leader");
On an event with a "hostage" ID:
Code:
   new LeaderInfo = GetEntData(Hostage_ID, g_LeaderOffset);
   PrintToServer("Leader information: %i", LeaderInfo);
When the hostage is NOT following anyone, the LeaderInfo will return 0.
When the hostage IS following a CT, the LeaderInfo will return a large int resembling a STEAM ID but the ID is invalid. I'm expecting a userid here and not getting it.

I read something about the GetEntData function having some problems with this type of set up and wondering which function I should be using here.
databomb is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 06-17-2009 , 16:36   Re: Hostage Interaction in CSS
Reply With Quote #2

I tried:

Code:
g_HealthOffset = FindSendPropOffs("CHostage", "m_iHealth");
and firing it on the same event with a valid hostage ID.. it worked fine, the PrintToServer returned the correct health of the hostage every time.

Also, the mleader number is the same every time the hostage is following the same person. Any ideas on what this number is? Kind of green with this framework so it's likely something simple I'm overlooking.
databomb is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 06-17-2009 , 16:38   Re: Hostage Interaction in CSS
Reply With Quote #3

CHostage::m_leader is an entity, use GetEntDataEnt2 instead.
__________________
plop
p3tsin is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 06-17-2009 , 18:07   Re: Hostage Interaction in CSS
Reply With Quote #4

Thanks p3tsin, I switched to GetEntDataEnt2 function and it is doing better than before. My results are all exactly 1 less than anticipated, when no one is following it returns -1 and when someone is following the userid is returned minus 1. I'm not exactly sure why but I could just code around it now that I know...
databomb is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 06-17-2009 , 18:29   Re: Hostage Interaction in CSS
Reply With Quote #5

If it's an entity then it'll return the client id, not the user id.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 06-17-2009 , 20:08   Re: Hostage Interaction in CSS
Reply With Quote #6

DJ Tsunami, I did some testing.

Code:
   new LeaderID = GetEntDataEnt2(Hostage_ID, g_LeaderOffset);
   new LeaderUserID = -1;
   if (LeaderID != -1)
   {
      LeaderUserID = GetClientUserId(LeaderID);
   }
if LeaderID is not -1 then someone is following, I fired the event during this time and got errors complaining that the client index (userid -1) was not valid. So I've confirmed it is giving me a userid back and not a client index. At first I was worried because my testing scenario might have overlooked this but I added more bots and people and found this was the case. Any idea why the mleader returns (userid - 1)?
databomb is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 06-17-2009 , 22:29   Re: Hostage Interaction in CSS
Reply With Quote #7

Just an update: I've gotten it to work with the code around of (leaderid = userid - 1). Right now I'm trying to figure out how to modify a hostage's collision properties so that a terrorist can't lead the hostages to a corner and then block himself in... apparently only CTs can 'nudge' the hostages!
databomb is offline
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 06-17-2009 , 23:47   Re: Hostage Interaction in CSS
Reply With Quote #8

Interesting, the hostages have COLLISION_GROUP_PLAYER but act differently when nudged by a T or a CT... I can change the group to COLLISION_GROUP_DEBRIS_TRIGGER and the nudging stops, both T and CT can pass through the hostage... unfortunately, this might lead to players hiding 'inside' the hostages..

Is anyone familiar with how this nudging action works between the CTs and hostages?
databomb is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 06-18-2009 , 06:56   Re: Hostage Interaction in CSS
Reply With Quote #9

Quote:
Originally Posted by databomb View Post
DJ Tsunami, I did some testing.

Code:
   new LeaderID = GetEntDataEnt2(Hostage_ID, g_LeaderOffset);
   new LeaderUserID = -1;
   if (LeaderID != -1)
   {
      LeaderUserID = GetClientUserId(LeaderID);
   }
if LeaderID is not -1 then someone is following, I fired the event during this time and got errors complaining that the client index (userid -1) was not valid. So I've confirmed it is giving me a userid back and not a client index. At first I was worried because my testing scenario might have overlooked this but I added more bots and people and found this was the case. Any idea why the mleader returns (userid - 1)?
Yeah... the reason it seems to be returning userid-1 is because it actually gives you a client index and not the userid, just as Tsunami stated.

Quote:
Originally Posted by databomb View Post
Interesting, the hostages have COLLISION_GROUP_PLAYER but act differently when nudged by a T or a CT... I can change the group to COLLISION_GROUP_DEBRIS_TRIGGER and the nudging stops, both T and CT can pass through the hostage... unfortunately, this might lead to players hiding 'inside' the hostages..

Is anyone familiar with how this nudging action works between the CTs and hostages?
I think its safe to assume thats handled in the hostage's Touch function. Possibly hooking and overriding it would stop nudging altogether.
__________________
plop
p3tsin is offline
Timiditas
Senior Member
Join Date: Apr 2009
Old 06-18-2009 , 17:15   Re: Hostage Interaction in CSS
Reply With Quote #10

Quote:
Originally Posted by DJ Tsunami View Post
If it's an entity then it'll return the client id, not the user id.
What exactly is the difference in these two? I BET I already mixed them up in some of my lines...
__________________

Timiditas 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:27.


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