[Tutorial] Detecting Controllers[0.3z only]
#1

As it was needed on the server I work with, I thought I may aswell share it with others, but be warned, the way this is coded is for the server i work with, I will explain what it wont do.

Because it detects the camera mode (GetPlayerCameraMode), and is set to 53, it will only work on weapons like Pistol, SMG, Carbine... and not things like Sniper and Rocket Launcher.

This is only for 0.3z as it uses OnPlayerWeaponShot, this code was about 10 minutes of work, so if its slow or whatever, I apologize as I am quite new to scripting... but here you go.

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
        new string[128];
        new cmode = GetPlayerCameraMode(playerid);
        new target = GetPlayerTargetPlayer(playerid); //Reports as 65535 if auto aim is being used.
        if( hittype == BULLET_HIT_TYPE_PLAYER )
        {
            if( GetPlayerState(target) == PLAYER_STATE_WASTED || GetPlayerState(hitid) == PLAYER_STATE_WASTED)
            {
                SCM(playerid, -1, "This player is dead");
                return 0;
            }
            if( cmode == 53 )
                {
                    if( hitid != target)
                    {
                                format(string, sizeof(string), "ID:%d may be using a controller or autoaim.", playerid);
                                SendClientMessageToAll(-1, string);
                                return 0;
                    }
                }
        }
        return 1;
}
And here is a proof of concept video.

[ame]http://www.youtube.com/watch?v=PyInvWL229A[/ame]

Any feedback will be helpful so I can improve
Reply
#2

Whats the point of that non-sense?

https://sampforum.blast.hk/showthread.php?tid=254295
Reply
#3

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Whats the point of that non-sense?

https://sampforum.blast.hk/showthread.php?tid=254295
Well, that only detects the movement motions, for people who want to use controllers, but need to be limited from actually auto aim shooting, does that not make sense?

As I said above, I made this for a server where controllers are allowed, but people dont want controllers auto aiming people, which that code, does not do.

In addition, people can still enable joypad mode, and auto aim with keyboard and mouse, this stops the auto-aiming.

Can a forum staff member rename the thread to Auto Aim instead of Controllers please?
Reply
#4

Good idea but should be

pawn Код:
if( GetPlayerState(hitid) == PLAYER_STATE_WASTED || GetPlayerState(target) == PLAYER_STATE_WASTED)
not

pawn Код:
if( GetPlayerState(target) == PLAYER_STATE_WASTED || GetPlayerState(hitid) == PLAYER_STATE_WASTED)
because target is INVALID_PLAYER_ID in this case ?
Reply
#5

this is the dumbest tutorial ever. lock this
Reply
#6

Quote:
Originally Posted by Swisher
Посмотреть сообщение
this is the dumbest tutorial ever. lock this
You're a noob, so you should know you should not judge anyone by anyway. First, look at your skills then speak. This tutorial made me aware of this detection feature in SA-MP! I thought it was not possible, Nice.
Reply
#7

Good job Ben, this is pretty usefull.
Reply
#8

I don't really understand the code actually to this... How does it actually detect that it's a joypad?
Reply
#9

Quote:
Originally Posted by Swisher
Посмотреть сообщение
this is the dumbest tutorial ever. lock this
And you belong to the dumbest people around this forum. If you don't like his work, then have the manners to at least not dis it.

Plus, this could be a lot more efficient than checking for using a joypad OnPlayerUpdate, because the latter is called every god damn second, whereas if you put it under this function it is only used when needed. But that's if you only need to detect auto-aim. I think that suffices.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)