Raised This Month: $ Target: $400
 0% 

Slap with GetClientAimTarget


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xilver266
Member
Join Date: Apr 2011
Old 04-26-2013 , 12:57   Slap with GetClientAimTarget
Reply With Quote #1

I'm trying to do that aiming a player and pressing the E can slap him.

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
buttons IN_USE
    {
        if (
Client_IsValid(client) && IsPlayerAlive(client))
        {
            new 
target_index GetClientAimTarget(clienttrue);
            new 
target GetClientOfUserId(target_index);
            
decl Float:ClientOrigin[3],Float:TargetOrigin[3], Float:Distance;
            
            if (
IsPlayerAlive(target))
            {
                
GetClientAbsOrigin(clientClientOrigin);    
                
GetClientAbsOrigin(targetTargetOrigin);    

                
Distance GetVectorDistance(ClientOriginTargetOrigin);
                
                if (
Distance <= 100.0)
                {
                    new 
randslap GetRandomInt(10500);
                    
SlapPlayer(targetrandslaptrue);
                }            
            }
        }
    }

__________________
Xilver266 is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-26-2013 , 13:04   Re: Slap with GetClientAimTarget
Reply With Quote #2

GetClientAimTarget already returns a ClientID, not a UserID.
__________________
11530 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-26-2013 , 13:44   Re: Slap with GetClientAimTarget
Reply With Quote #3

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)

do you really want slap 66 times in second ??
__________________
Do not Private Message @me
Bacardi is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 04-26-2013 , 14:41   Re: Re: Slap with GetClientAimTarget
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)

do you really want slap 66 times in second ??
Will it make them fly. That would be awesome haha
Doc-Holiday is offline
mcpan313
Senior Member
Join Date: Mar 2010
Old 04-26-2013 , 15:11   Re: Slap with GetClientAimTarget
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)

do you really want slap 66 times in second ??
I guess he needs this

PHP Code:
new g_LastButtons[MAXPLAYERS];
public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
IsButtonPressed(clientbuttonsIN_USE))
    {
        
/* code */
    
}

    if (
IsButtonReleased(clientbuttonsIN_USE))
    {
        
/* code */
    
}

    
g_LastButtons[client] = buttons;
}

stock bool:IsButtonPressed(clientbuttonsbtn)
{
    return ((
buttons btn) == btn && (g_LastButtons[client] & btn) != btn);
}

stock bool:IsButtonReleased(clientbuttonsbtn)
{
    return ((
g_LastButtons[client] & btn) == btn && (buttons btn) != btn);

__________________
sorry, for my poor english.
mcpan313 is offline
Send a message via MSN to mcpan313
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-26-2013 , 17:07   Re: Slap with GetClientAimTarget
Reply With Quote #6

I was thinking more likely repeating timer. Ouh well. Carry on.
Bacardi 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 06:12.


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