Raised This Month: $ Target: $400
 0% 

[Not Solved] The help of professional programmers is required.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-05-2019 , 08:20   [Not Solved] The help of professional programmers is required.
Reply With Quote #1

Hello! Please help create code
The player comes to the corpse presses "E" and in the chat writes the nick of the corpse
Hennesy is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 06-05-2019 , 09:02   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #2

on player_death event create prop_ragdoll and set m_hOwnerEntity to event caller.
create onplayerruncmd action, check if buttons & IN_USE then get client aim, create max distance and get m_hOwnerEntity from client aim.
farawayf is offline
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-05-2019 , 09:52   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #3

Quote:
Originally Posted by farawayf View Post
on player_death event create prop_ragdoll and set m_hOwnerEntity to event caller.
create onplayerruncmd action, check if buttons & IN_USE then get client aim, create max distance and get m_hOwnerEntity from client aim.
Unfortunately I could not do it. Can you give the ready code?
Hennesy is offline
SZOKOZ
Member
Join Date: Jan 2014
Old 06-05-2019 , 13:11   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #4

Well TTT has this functionality. Take a good read https://github.com/Bara/TroubleinTer.../scripting/ttt
__________________
May still be available for SM scripting. Just look at my Steam profile regarding my availability.
My Steam
SZOKOZ is offline
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-05-2019 , 14:07   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #5

Quote:
Originally Posted by SZOKOZ View Post
Well TTT has this functionality. Take a good read https://github.com/Bara/TroubleinTer.../scripting/ttt
I did not find a solution. The issue is urgent
Hennesy is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 06-05-2019 , 16:58   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #6

If you look around in the repository SZOKOZ linked you'll find a solution.

Kolapsicle is offline
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-06-2019 , 04:13   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #7

Quote:
Originally Posted by Kolapsicle View Post
If you look around in the repository SZOKOZ linked you'll find a solution.

Unfortunately I could not do it. Can you give the ready code?
Hennesy is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 06-06-2019 , 10:37   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #8

try. not tested

PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart() {
    
HookEvent("player_death"PlayerDeath);
}

public 
void PlayerDeath(Event event, const char[] namebool dontBroadcast) {
    
int owner GetClientOfUserId(event.GetInt("userid"));
    
    if (!
IsValidClient(owner))
        return;
        
    
int ragdoll GetEntPropEnt(ownerProp_Send"m_hRagdoll");
    if (
ragdoll 0) {
        
AcceptEntityInput(ragdoll"kill"00);
    }
    
    
int ragdollentity CreateEntityByName("prop_ragdoll");
    
char mdl[PLATFORM_MAX_PATH];
    
GetClientModel(ownermdlsizeof(mdl));
    
DispatchKeyValue(ragdollentity"model"mdl);
    
    
SetEntPropEnt(ragdollentityProp_Send"m_hOwnerEntity"owner);
    
SetEntProp(ragdollentityProp_Data"m_nSolidType"6);
    
SetEntProp(ragdollentityProp_Data"m_CollisionGroup"5);
    
    
ActivateEntity(ragdollentity);
    
    if (
DispatchSpawn(ragdollentity)) {
        
float origin[3], angles[3], velocity[3];
        
        
GetClientAbsOrigin(ownerorigin);
        
GetClientAbsAngles(ownerangles);
        
GetEntPropVector(ownerProp_Data"m_vecAbsVelocity"velocity);
        
float speed GetVectorLength(velocity);
        if (
speed >= 500) {
            
TeleportEntity(ragdollentityoriginanglesNULL_VECTOR);
        }
        else {
            
TeleportEntity(ragdollentityoriginanglesvelocity);
        }
    }
    
SetEntProp(ragdollentityProp_Data"m_CollisionGroup"2);
}

public 
Action OnPlayerRunCmd(int clientint &buttons) {
    if (!
IsValidClient(client))
        return 
Plugin_Continue;
        
    if (!
IsPlayerAlive(client))
        return 
Plugin_Continue;
        
        
int pressed GetEntProp(clientProp_Data"m_afButtonPressed");
    if (
pressed IN_USE) {
        
int aim GetClientAimTarget(clientfalse);
        if (
aim 0) {
            
float aimpos[3], targetpos[3], vec[3];
            
            
GetClientEyePosition(clientaimpos);
            
GetEntPropVector(aimProp_Data"m_vecOrigin"targetpos);
            
MakeVectorFromPoints(aimpostargetposvec);
            
            if (
GetVectorLength(vec) > 120.0) {
                return 
Plugin_Continue;
            }
            
            
int owner GetEntPropEnt(aimProp_Send"m_hOwnerEntity");
            
PrintToChat(client"Body owner is %d"owner);
        }
    }
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client) {
    if (
client <= || client MaxClients)
        return 
false;
        
    if (!
IsValidEntity(client))
        return 
false;
        
    if (!
IsClientInGame(client))
        return 
false;

    return 
true;


Last edited by farawayf; 06-06-2019 at 11:02. Reason: v2
farawayf is offline
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-06-2019 , 10:53   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #9

Quote:
Originally Posted by farawayf View Post
try. not tested

PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart() {
    
HookEvent("player_death"PlayerDeath);
}

public 
void PlayerDeath(Event event, const char[] namebool dontBroadcast) {
    
int owner GetClientOfUserId(event.GetInt("userid"));
    
    if (!
IsValidClient(owner))
        return;
        
    
int ragdoll GetEntPropEnt(ownerProp_Send"m_hRagdoll");
    if (
ragdoll 0) {
        
AcceptEntityInput(ragdoll"kill"00);
    }
    
    
int ragdollentity CreateEntityByName("prop_ragdoll");
    
char mdl[PLATFORM_MAX_PATH];
    
GetClientModel(ownermdlsizeof(mdl));
    
DispatchKeyValue(ragdollentity"model"mdl);
    
    
SetEntPropEnt(ragdollentityProp_Send"m_hOwnerEntity"owner);
    
SetEntProp(ragdollentityProp_Data"m_nSolidType"6);
    
SetEntProp(ragdollentityProp_Data"m_CollisionGroup"5);
    
    
ActivateEntity(ragdollentity);
    
    if (
DispatchSpawn(ragdollentity)) {
        
float origin[3], angles[3], velocity[3];
        
        
GetClientAbsOrigin(ownerorigin);
        
GetClientAbsAngles(ownerangles);
        
GetEntPropVector(ownerProp_Data"m_vecAbsVelocity"velocity);
        
float speed GetVectorLength(velocity);
        if (
speed >= 500) {
            
TeleportEntity(ragdollentityoriginanglesNULL_VECTOR);
        }
        else {
            
TeleportEntity(ragdollentityoriginanglesvelocity);
        }
    }
    
SetEntProp(ragdollentityProp_Data"m_CollisionGroup"2);
}

public 
Action OnPlayerRunCmd(int clientint &buttons) {
    if (!
IsValidClient(client))
        return 
Plugin_Continue;
        
    if (!
IsPlayerAlive(client))
        return 
Plugin_Continue;
        
    if (
buttons IN_USE) {
        
int aim GetClientAimTarget(clientfalse);
        if (
aim 0) {
            
float aimpos[3], targetpos[3], vec[3];
            
            
GetClientEyePosition(clientaimpos);
            
GetEntPropVector(aimProp_Data"m_vecOrigin"targetpos);
            
MakeVectorFromPoints(aimpostargetposvec);
            
            if (
GetVectorLength(vec) > 120.0) {
                return 
Plugin_Continue;
            }
            
            
int owner GetEntPropEnt(aimProp_Send"m_hOwnerEntity");
            
PrintToChat(client"Body owner is %d"owner);
        }
    }
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client) {
    if (
client <= || client MaxClients)
        return 
false;
        
    if (!
IsValidEntity(client))
        return 
false;
        
    if (!
IsClientInGame(client))
        return 
false;

    return 
true;

Everything works as it should, except that when you press "E" chat so floods that the server is disconnected.
Hennesy is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 06-06-2019 , 11:02   Re: [Not Solved] The help of professional programmers is required.
Reply With Quote #10

Quote:
Originally Posted by Hennesy View Post
Everything works as it should, except that when you press "E" chat so floods that the server is disconnected.
try edited version
farawayf 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 04:56.


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