Raised This Month: $32 Target: $400
 8% 

[CS:GO] How to get 'Decoy Grenade' position?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Purixi
Junior Member
Join Date: Jul 2015
Old 07-08-2015 , 13:25   [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #1

I'm about of making plugin that teleport player to a Decoy Grenade, that he threw.
Is there any methods of making this possible?

Last edited by Purixi; 07-08-2015 at 13:25. Reason: Added more info.
Purixi is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-08-2015 , 13:38   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #2

Nice idea man! :-D
Just hook decoy_started and teleport userid to x, y, z ;-)
Looking forward that!
KissLick is offline
Purixi
Junior Member
Join Date: Jul 2015
Old 07-08-2015 , 13:41   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #3

Oh. Easy as far as it can be. Gonna give plugin source in 10 mins.
It's better to hook decoy_firing because decoy_started return wrong position.

Last edited by Purixi; 07-08-2015 at 13:42.
Purixi is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-08-2015 , 13:47   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #4

But I guess decoy_firing fires many times for one decoy...
KissLick is offline
Purixi
Junior Member
Join Date: Jul 2015
Old 07-08-2015 , 14:03   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #5

Well, it seems that this should work. Gonna test soon.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <events>

public Plugin:myinfo =
{
    
name "[Purixi] Decoy Teleporter",
    
author "Purixi",
    
description "",
    
version "1.0",
    
url ""
}

public 
OnPluginStart()
{
    
HookEvent("player_spawned"player_spawned);
    
HookEvent("decoy_firing"decoy_firing);
}

public 
player_spawned(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    
    
GivePlayerItem(client"weapon_decoy");
}

public 
decoy_firing(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    
    new 
Float:f_Pos[3];
    
f_Pos[0] = GetEventFloat(event"x");
    
f_Pos[1] = GetEventFloat(event"y");
    
f_Pos[2] = GetEventFloat(event"z");
    
    
TeleportEntity(clientNULL_VECTORNULL_VECTORf_Pos);

How about decoy_detonate then?

Last edited by Purixi; 07-08-2015 at 15:00.
Purixi is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 07-08-2015 , 14:11   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #6

-Hook decoy_detonate.
-In the code above you are setting the velocity vector instead of the position vector of the player. It should be TeleportEntity(client, f_Pos, NULL_VECTOR, NULL_VECTOR)
Darkness_ is offline
Purixi
Junior Member
Join Date: Jul 2015
Old 07-08-2015 , 14:15   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #7

Quote:
Originally Posted by Darkness_ View Post
-Hook decoy_detonate.
-In the code above you are setting the velocity vector instead of the position vector of the player. It should be TeleportEntity(client, f_Pos, NULL_VECTOR, NULL_VECTOR)
Sorry, lol. I was using TeleportEntity code from Internet, seems it's not valid.
Purixi is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-08-2015 , 14:37   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #8

As I guess:
decoy_started - decoy started firing
decoy_firing - every fire that decoy makes
decoy_detonated - that decoy explosion

decoy_started seem as the only valid solution, but if it gives bad location, you can do something like this (not tested)
PHP Code:
#include <sourcemod>
#include <sdktools>

public Plugin:myinfo =
{
    
name "[Purixi] Decoy Teleporter",
    
author "Purixi",
    
description "",
    
version "1.0",
    
url ""
}

new 
Handle:g_hTeleportedDecoys;

public 
OnPluginStart()
{
    
HookEvent("player_spawned"player_spawned);
    
HookEvent("decoy_firing"decoy_firing);
    
HookEvent("decoy_detonated"decoy_detonated);
    
HookEvent("round_start"round_start);
    
    
g_hTeleportedDecoys CreateArray();
}

public 
player_spawned(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);

    
GivePlayerItem(client"weapon_decoy");
}

public 
decoy_firing(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    new 
decoy GetEventInt(event"entityid");
    
    if (
FindValueInArray(g_hTeleportedDecoysdecoy))
        return;
    
    
PushArrayCell(g_hTeleportedDecoysdecoy);
    
    new 
Float:f_Pos[3];
    
f_Pos[0] = GetEventFloat(event"x");
    
f_Pos[1] = GetEventFloat(event"y");
    
f_Pos[2] = GetEventFloat(event"z");

    
TeleportEntity(clientf_PosNULL_VECTORNULL_VECTOR);
}

public 
decoy_detonated(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
decoy GetEventInt(event"entityid");
    new 
index FindValueInArray(g_hTeleportedDecoysdecoy);
    
    if (
index != -1)
        
RemoveFromArray(g_hTeleportedDecoysindex);
}

public 
round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    
ClearArray(g_hTeleportedDecoys);

KissLick is offline
Purixi
Junior Member
Join Date: Jul 2015
Old 07-08-2015 , 14:44   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #9

Okay, now to do not create a new thread, how can I remove entity by entityid, given from Event.
My code works correctly. It teleports me to a dead decoy using decoy_detonate event.
But I'm looking to do this fastly, so I want to use decoy_firing, then teleport player to the position and remove entity of decoy.

Last edited by Purixi; 07-08-2015 at 14:45.
Purixi is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-08-2015 , 14:51   Re: [CS:GO] How to get 'Decoy Grenade' position?
Reply With Quote #10

try AcceptEntityInput(decoy, "Kill"); ;-)
KissLick is offline
Reply


Thread Tools
Display Modes

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:58.


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