AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Slap with GetClientAimTarget (https://forums.alliedmods.net/showthread.php?t=214403)

Xilver266 04-26-2013 12:57

Slap with GetClientAimTarget
 
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);
                }            
            }
        }
    }



11530 04-26-2013 13:04

Re: Slap with GetClientAimTarget
 
GetClientAimTarget already returns a ClientID, not a UserID.

Bacardi 04-26-2013 13:44

Re: Slap with GetClientAimTarget
 
PHP Code:

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


do you really want slap 66 times in second ??

Doc-Holiday 04-26-2013 14:41

Re: Re: Slap with GetClientAimTarget
 
Quote:

Originally Posted by Bacardi (Post 1940471)
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

mcpan313 04-26-2013 15:11

Re: Slap with GetClientAimTarget
 
Quote:

Originally Posted by Bacardi (Post 1940471)
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);



Bacardi 04-26-2013 17:07

Re: Slap with GetClientAimTarget
 
I was thinking more likely repeating timer. Ouh well. Carry on.


All times are GMT -4. The time now is 21:54.

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