SA-MP Forums Archive
SDpistol tazer help. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SDpistol tazer help. (/showthread.php?tid=210568)



SDpistol tazer help. - Outcast - 13.01.2011

Well, I'm confused by this. I want to make when you type /tazer you get an sdpistol and if you shoot someone you taze him. I don't know what to put on OnPlayerKeyStateChange.

This is the code:
pawn Код:
new newkeys;
    new oldkeys;
    if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
     {
         for(new targetplayerid; targetplayerid < MAX_PLAYERS; targetplayerid++)
         {
             if(IsPlayerAimingAtPlayer(playerid,targetplayerid))
             {
                GameTextForPlayer(targetplayerid,"You have been tazed by a cop!",3000,3);
                ApplyAnimation(targetplayerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0, 1);
                return 1;
                }
             }
         }
    return 1;
What to do about this newkeys and oldkeys? Please help me out or give me a link for an example script so I can figure it out. I really need this for my GM I'm developing.

Thanks in advanced.


Re: SDpistol tazer help. - Toreno - 13.01.2011

You can use OnPlayerShootPlayer by wups.
https://sampforum.blast.hk/showthread.php?tid=195439

And do something like that:
pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    if(GetPlayerWeapon(shooter) == 23)
    {
        new name[MAX_PLAYER_NAME],msg[80];
        GetPlayerName(shooter,name,sizeof(name));
        GetPlayerName(target,name,sizeof(name));
        GameTextForPlayer(target, "You have been tazed by a cop!", 3000, 3);
        ApplyAnimation(target, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0, 1);
        format(msg,sizeof(msg),"* %s tazed you and did %.1f damage!",name,damage);
        SendClientMessage(target,0x33AA33AA,msg);
        format(msg,sizeof(msg),"* You tazed %s and did %.1f damage!",name,damage);
        SendClientMessage(shooter,0x33AA33AA,msg);
        return 1;
    }
    return 1;
}