SA-MP Forums Archive
A headshot command - 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)
+--- Thread: A headshot command (/showthread.php?tid=597148)



A headshot command - Avetsky - 27.12.2015

Basically, I'd like a command made with zcmd which enables headshot for a /single shot only/, if the shot doesn't hit the players head, then the feature will automatically get toggled off.


Re: A headshot command - xTURBOx - 27.12.2015

untested but complies fine
PHP код:
#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>

new allowheadshot[MAX_PLAYERS];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Blank Filterscript by your name here");
    print(
"--------------------------------------\n");
    return 
1;
}

public 
OnFilterScriptExit()
{
    return 
1;
}

#else

main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}

#endif
public OnPlayerConnect(playerid)
{
    
allowheadshot[playerid] = 0;
    return 
1;
}

public 
OnPlayerDisconnect(playeridreason)
{
    
allowheadshot[playerid] = 0;
    return 
1;
}

public 
OnPlayerTakeDamage(playerid,issueridFloat:amountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID /*&& weaponid == 34*/ && bodypart == && allowheadshot[issuerid] == 1)//uncomment weaponid == 34 if you want the player to make headshots with ONLY SNIPER
    
{
        
SetPlayerHealth(playerid0.0);
    }
    return 
1;
}
public 
OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
allowheadshot[playerid] == 1)
    {
        
allowheadshot[playerid] = 0//so when missed he can't headshot in the second try
        
SendClientMessage(playerid,-1,"You have lost your headshot ability");
    }
    return 
1;
}
CMD:headshot(playerid,params[])
{
    
allowheadshot[playerid] = 1;
    
GameTextForPlayer(playerid,"Head shot enabled",1000,3);
    
SendClientMessage(playerid,-1,"You have gained ability to headshot");
    return 
1;




Re: A headshot command - Avetsky - 27.12.2015

Код:
headshot.pwn(45) : error 025: function heading differs from prototype
headshot.pwn(53) : warning 235: public function lacks forward declaration (symbol "OnPlayerWeaponShot")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Also, how could I integrate this into the NGRP gamemode?


Re: A headshot command - GeneralAref - 27.12.2015

add
PHP код:
forward OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ); 
top of your script.


Re: A headshot command - xTURBOx - 28.12.2015

also This callback was added in SA-MP 0.3z and will not work in earlier versions!
Are you sure that you are using the latest version of samp?


Re: A headshot command - CrunchxNoy - 28.12.2015

Put It On You TOP Script
Код:
forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);



Re: A headshot command - Avetsky - 28.12.2015

Alright, I got the script running and all, but it doesn't kill with one shot.


Re: A headshot command - Akbaig - 28.12.2015

Show the line number 48 of your filterscript " headshot.pwn ", please.

Quote:
Originally Posted by Avetsky
Посмотреть сообщение
Also, how could I integrate this into the NGRP gamemode?
Open your server.cfg

Add the following in the line filterscripts:

Код:
filterscripts headshot
-Regards Noob Programmer Akbaig


Re: A headshot command - Avetsky - 28.12.2015

Nobody is dying whenever I perform a headshot.


Re: A headshot command - Boar - 28.12.2015

Quote:
Originally Posted by xTURBOx
Посмотреть сообщение
also This callback was added in SA-MP 0.3z and will not work in earlier versions!
Are you sure that you are using the latest version of samp?
^^^^